Skip to content

Toggle select for in legend doesnt work on color label #3627

Closed
@henrykeithturner

Description

@henrykeithturner

Hi all,

I initially asked about this on the plotly forum at https://community.plot.ly/t/toggle-select-for-in-legend-doesnt-work-on-color-label/20736, and so now i'm following it up here!

I’ve noticed a minor issue when you have a chart with a legend, that if you want to remove a particular trace then you can click either on the word in the legend or to the left of the accompanying coloured square. If you click on the coloured square itself then nothing happens, which seems counter intuitive since (when using bar charts) the square coloured box looks like a button which you’re suppose to click (and i keep finding people instinctively try to click that first to toggle on a particular trace).

I’ve attached an example where you can see that clicking on the square coloured boxes in the legend does nothing, but clicking on the word does.

For the bar chart case this seems to be because the “legendbar” element is in front of the “legendtoggle” index.

Can this behaviour be changed, because it’s causing a bit of confusion with people instinctively trying to click the coloured box first to switch off traces?

Many Thanks!

Harry

from plotly import version
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

trace1 = go.Bar(
x=[‘giraffes’, ‘orangutans’, ‘monkeys’],
y=[20, 14, 23],
name=‘SF Zoo’
)
trace2 = go.Bar(
x=[‘giraffes’, ‘orangutans’, ‘monkeys’],
y=[12, 18, 29],
name=‘LA Zoo’
)

data = [trace1, trace2]
layout = go.Layout(
barmode=‘group’
)

trace1 = go.Bar(
x=[‘giraffes’, ‘orangutans’, ‘monkeys’],
y=[20, 14, 23],
name=‘SF Zoo’
)
trace2 = go.Bar(
x=[‘giraffes’, ‘orangutans’, ‘monkeys’],
y=[12, 18, 29],
name=‘LA Zoo’
)

data = [trace1, trace2]
layout = go.Layout(
barmode=‘stack’
)

fig = py.graph_objs.Figure(data=data, layout=layout)
py.offline.iplot(fig)

Metadata

Metadata

Assignees

Labels

bugsomething broken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions