Skip to content

Commit

Permalink
Allow removing legend (apache#5932)
Browse files Browse the repository at this point in the history
(cherry picked from commit 71f014e)
  • Loading branch information
betodealmeida authored and mistercrunch committed Sep 21, 2018
1 parent ede4141 commit a0c36d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export const controls = {
clearable: false,
default: 'tr',
choices: [
[null, 'None'],
['tl', 'Top left'],
['tr', 'Top right'],
['bl', 'Bottom left'],
Expand Down
6 changes: 3 additions & 3 deletions superset/assets/src/visualizations/Legend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -19,15 +19,15 @@ 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;
}

const categories = Object.entries(this.props.categories).map(([k, v]) => {
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)}
Expand Down

0 comments on commit a0c36d1

Please sign in to comment.