Allow removing legend (#5932)

This commit is contained in:
Beto Dealmeida 2018-09-19 13:32:07 -07:00 committed by GitHub
parent b9e3159f7c
commit 71f014e9b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -259,6 +259,7 @@ export const controls = {
clearable: false,
default: 'tr',
choices: [
[null, 'None'],
['tl', 'Top left'],
['tr', 'Top right'],
['bl', 'Bottom left'],

View File

@ -7,7 +7,7 @@ const propTypes = {
categories: PropTypes.object,
toggleCategory: PropTypes.func,
showSingleCategory: PropTypes.func,
position: PropTypes.oneOf(['tl', 'tr', 'bl', 'br']),
position: PropTypes.oneOf([null, 'tl', 'tr', 'bl', 'br']),
};
const defaultProps = {
@ -19,7 +19,7 @@ const defaultProps = {
export default class Legend extends React.PureComponent {
render() {
if (Object.keys(this.props.categories).length === 0) {
if (Object.keys(this.props.categories).length === 0 || this.props.position === null) {
return null;
}
@ -27,7 +27,7 @@ export default class Legend extends React.PureComponent {
const style = { color: 'rgba(' + v.color.join(', ') + ')' };
const icon = v.enabled ? '\u25CF' : '\u25CB';
return (
<li>
<li key={k}>
<a
href="#"
onClick={() => this.props.toggleCategory(k)}