question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to disable legend trace toggling

See original GitHub issue

Some folks don’t want it apparently; we should make this optional.

Maybe a boolean layout.legend.tracetoggle attribute?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:14
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
tudor-svcommented, Sep 5, 2016

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…

1reaction
jacobqcommented, Jun 25, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found