Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removing legend #5932

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,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