-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete legend for multiple colored bars in one trace #1560
Comments
You're correct. The current behavior isn't great and is far from perfect in every situation. But, can I ask, what's the desired behavior in your mind? I don't think we should try plotting a rainbow-like legend item with the colors of all the trace's points. Maybe we could hash the legend item? Something else? |
from @r1z1a in #1634 - there the use case was a trace that started all one color but during interactions one or another point (bars in that case too, though this applies to at least scatter as well) would change. @r1z1a 's suggestion:
It's important that whatever solution we end up with depend only on the current state, not on its history, so while this suggestion is tempting as it produces the "right" result in that specific case, it's not viable in general. One way we could solve this would be to explicitly specify legend styling. In principle this would need to be fairly involved, replicating all the |
@alexcjohnson From my perspective the legend color should stay the original color plotted and only if you re-style whole trace it should then be changed. You say you want to depend on current state of the trace, so whats the current state of a trace with 100 scatter markers that are colored red and green for instance. Should a trace legend be an Array of colors used for the plot? Should it be the First color? Maybe the color that appears the most in the trace. I personally think this is the whole restyle() issue. Its great when you want to change whole trace, but when it comes to single points in a trace, it can become very hard, and fair few issues are coming from that. |
Another example (If I understand the problem here) is that I would like to compare 2 properties: temperature and pressure. Each property should be assigned to its own axis (because of the property unit - tempearature unit (Celsius) and pressure unit (Pascal)). So how can I show barchart with legend groupped by sources (A and B)? Each source should have its own color and every property that comes from that source should have the color of its own source. Like in this example: https://codepen.io/morris4life/pen/eepZNV?editors=0010 |
Now in #3735 |
I noticed that Plotly.js construct legend item per trace rather than per color: https://github.com/plotly/plotly.js/blob/master/src/components/legend/get_legend_data.js#L43-L71. Thus if markers in a trace are colored differently, the legend could only show the color of the first item.
Here is an example:
I tried to make some changes to draw the legend items correctly. But the filtering functionality breaks. And I failed to find a way to fix the filter as the current implementation is based on the concept of "trace".
The text was updated successfully, but these errors were encountered: