Skip to content

Commit a44a349

Browse files
committed
Hide legend tab when not needed
1 parent 7b16fd2 commit a44a349

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/DefaultEditor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DefaultEditor extends Component {
2929
this.hasMenus = this.hasMenus.bind(this);
3030
this.hasSliders = this.hasSliders.bind(this);
3131
this.hasColorbars = this.hasColorbars.bind(this);
32+
this.hasLegend = this.hasLegend.bind(this);
3233
}
3334

3435
hasTransforms() {
@@ -65,6 +66,10 @@ class DefaultEditor extends Component {
6566
return this.context.fullData.some(d => traceHasColorbar({}, d));
6667
}
6768

69+
hasLegend() {
70+
return this.context.fullData.some(t => t.showlegend !== undefined); // eslint-disable-line no-undefined
71+
}
72+
6873
hasMaps() {
6974
const {
7075
layout: {geo, mapbox},
@@ -89,7 +94,7 @@ class DefaultEditor extends Component {
8994
<StyleTracesPanel group={_('Style')} name={_('Traces')} />
9095
{this.hasAxes() && <StyleAxesPanel group={_('Style')} name={_('Axes')} />}
9196
{this.hasMaps() && <StyleMapsPanel group={_('Style')} name={_('Maps')} />}
92-
<StyleLegendPanel group={_('Style')} name={_('Legend')} />
97+
{this.hasLegend() && <StyleLegendPanel group={_('Style')} name={_('Legend')} />}
9398
{this.hasColorbars() && <StyleColorbarsPanel group={_('Style')} name={_('Color Bars')} />}
9499
<StyleNotesPanel group={_('Style')} name={_('Annotation')} />
95100
<StyleShapesPanel group={_('Style')} name={_('Shapes')} />

0 commit comments

Comments
 (0)