Comments (8)
hi @NirRazor
What do you mean when you say you want the second legend to toggle entire legend groups.
If a user would click Shape1 or Shape2, both would turn off?
from plotly.js.
hi @NirRazor What do you mean when you say you want the second legend to toggle entire legend groups. If a user would click Shape1 or Shape2, both would turn off?
In my current setup, I have a graph that displays multiple time series, which are collectively represented under legend
. Additionally, this graph includes various shapes, specifically vertical lines that represent historical events. These events are categorized and linked to legend2
. My goal is to implement distinct interactive behaviors for items associated with each legend. For instance, interacting with an element in legend
should toggle the visibility of its corresponding time series. Similarly, interacting with an element in legend2
should control the visibility of the shapes within the same category, functioning as a 'toggle group'.
However the interactive behaviors like itemclick
, itemdoubleclick
, and groupclick
are currently being governed solely by the configuration set for the first legend in the graph. I provided an example, where the itemclick functionality for legend2
is disabled because it's set to 'False' in the configuration for legend
. This problem persists for itemdoubleclick
and groupclick
interactions as well. From the layout reference it is expected that these interactive behaviors are legend specific and not Figure specific.
from plotly.js.
Thanks for the explanation @NirRazor .
When I ran your coded above, the legends worked for me as expected. I'm assuming that you are looking for a different type of legend behavior, which is not fully clear to me yet.
Do you mind speaking to the code you shared in the very first post. If you were able to accomplish what you're looking for, what would we see? What would happen if I clicked on legend 2 in your graph?
Feel free to share images and annotations to explain your desired result.
from plotly.js.
Thank you for your response. To clarify, my goal is to have two legends with distinct interactive behaviors:
Legend 1 (Time Series): Each item in this legend corresponds to a time series on the graph. The desired behavior here is standard ā clicking on an item should toggle the visibility of its corresponding time series (individual trace toggling).
Legend 2 (Historical Events): This legend relates to various shapes (like vertical lines) representing historical events. The key here is that I want to toggle groups of these shapes together. For example, if 'Legend2' contains categories A, B, and C, clicking on A should toggle the visibility of all shapes under category A, and similarly for B and C.
In my example that I have provided I just try to explain the issue that is preventing me to do so. The issue is that all the legends are inheriting the behavior of the first legend. So, if I set itemclick: false in the first legend, the second legend also inherits this non-interactive behavior, which is not intended.
Ideally, In my example above here's what should happen:
If I click on a time series name in 'Legend 1', nothing should happen (as its toggle behavior is disabled)
If I click a shape in 'Legend 2', only that specific shape should toggle on/off.
(Due to the unexpected behavior, both legends toggle behavior is disabled)
I hope this better explains the specific functionality I'm trying to achieve.
from plotly.js.
from plotly.js.
Thanks for the reminder @NirRazor .
I'll take a deeper look into this tomorrow and get back to you with any findings.
from plotly.js.
Thanks @NirRazor - confirmed, this is a bug, click behavior was never updated to support multiple legends. I'll move this to the plotly.js repo and comment on where the fix is needed.
from plotly.js.
The problem is right here, click handler needs to refer to the specific legend being clicked, rather than fullLayout.legend
:
plotly.js/src/components/legend/handle_click.js
Lines 14 to 16 in 08e06bd
from plotly.js.
Related Issues (20)
- hoversubplots="axis" with hovermode="x" on stacked traces, shows x-axis label on first trace
- Feature Request: GeoJSON Layer Display
- Handle empty data in heatmaps
- Documentation for heatmap, boxplot, etc
- different spacing between tick labels and axis title with multi line text
- Colorbar Orientation Change Causes Render Issue
- Support `text-shadow` in SVG text
- Support `text-overflow` in SVG text
- Support `user-select` text from the graph elements HOT 2
- Clickmode "event+select" activated and Clicking outside of Graph calls onUpdate incorrectly HOT 1
- how can we set tick for bar
- Need help with multiple axes and subplots
- Hovertemplate use html tag is not working
- [FR] Change the height of the legend graphic (specifically for fill)
- Plotly-basic.js + table HOT 2
- Display tooltips on zero value bars HOT 2
- Histograms on splom diagonals HOT 3
- Improve `scattermapbox.textfont` family options and descriptions
- Y-axis autoscaling with X-axis range change
- how to replace the color chunk in top heatmap
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotly.js.