Add ability to disable legend trace toggling
See original GitHub issueSome folks don’t want it apparently; we should make this optional.
Maybe a boolean layout.legend.tracetoggle
attribute?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:14
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Plotly: How to toggle traces with a button similar to clicking ...
The problem is that if I use one of those buttons, it does hide all the other traces but it also removes them...
Read more >Plotly.js selectively disable legend trace toggling - CodePen
1. /* this will prevent trace 2 from toggling from the legend ; 2. ; 3. /* hides the svg dom element...
Read more >Python Plotly - How to customize legend? - GeeksforGeeks
In plotly, we can customize the legend by changing order, changing orientation, we can either hide or show the legend and other ...
Read more >Using the Trace tool | Apigee Edge
How to use Trace; How to read a trace; Transaction map legend ... Click the Enable Apigee Support to Trace toggle to disable...
Read more >Plotly subplots with individual legends
So users are left to choose between being able to toggle traces (very useful) or being able to display readable legends (essential). You...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also had this need to disable trace toggling, but only for a particular trace, not for all. I wanted to have like a “background trace” that would be displayed in the legend but be untogglable. After digging around for hours in the plugin’s js , I made an accidental discovery while inspecting the chart’s svg dom elements: There is a special transparent element overlaying each trace in the legend (.legendtoggle). This element has the attached js click handler responsible for toggling the corresponding trace. By making this element unclickable, we circumvent the need for any new js hacks or changing the plugin api. Here is the workaround, using only a few lines of css: http://codepen.io/tudor-sv/pen/vXEZYG Of course this method could also be used to make all legend items untogglable…
This seems to be possible now with the
plotly_legendclick
&plotly_legenddoubleclick
event hooks by returning false from the custom event handler. See https://stackoverflow.com/questions/51029619/what-is-the-right-way-to-override-default-event-handler-behaviors-e-g-toggle-t