-
-
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
Add ability to disable legend trace toggling #665
Comments
I have implemented it could you check it, please? I have created a pull-request in my own fork as stated in the guidelines. |
@hectorip you're off to a great start. I think that's all you need. A couple recommendations before making your PR to the main repo:
Thanks for your efforts 🍻 |
@etpinard @hectorip What do you think about returning false from a callback to disable the default behavior? I have a branch of plotly where I've added a plotly_legend_toggle event so I can know when to apply some custom scaling to the chart when a user toggles a trace. It seems like there could be other uses for being able to influence the behavior of a toggle or react to it happening. |
We could, but the plotly.js @john-soklaski To treat the custom handler case, we would need a config option as proposed in #65 - which isn't at all incompatible with the |
@etpinard That makes sense, thanks. Glad to see it would still be a possibility :) |
I also had this need to disable trace toggling, but only for a particular trace, not for all. |
I have a related issue. I don't want to disable legend trace toggling in general, but I'd like to include a hyperlink in my trace name so that a page with more detail on that trace can load. I am okay with the trace toggling on click anywhere not within my |
Any ETA on when this feature would be merged into plotly? |
Now doable using: Plotly.newPlot('graph', {}).then(gd => {
gd.on('plotly_legendclick', () => false}
}) I'll leave this ticket open, as something like hectorip#1 could offer another viable of doing this. |
Hi @etpinard, I'm using reactjs wrapper for Plotly ( Unfortunately I cannot figure out what proper syntax should be in that case. This phrase doesn't work:
Will appreciate a lot your help! |
@AllaSorokina I'm no React expert, but something like import React from 'react';
import createPlotlyComponent from 'react-plotly.js/factory';
const Plot = createPlotlyComponent(Plotly);
class App extends React.Component {
render() {
return (
<Plot
data={[
{
x: [1, 2, 3],
y: [2, 6, 3],
type: 'scatter',
mode: 'lines+points',
marker: {color: 'red'},
},
{type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
]}
layout={{width: 320, height: 240, title: 'A Fancy Plot'}}
onLegendDoubleClick={() => false}}
/>
);
}
} should work. If it doesn't, please ask your question again on https://community.plot.ly/ |
This seems to be possible now with the |
Seems like this issue can be closed now, per this comment, right? |
@etpinard OK, so this issue is really about providing a better way rather than simply making it possible. Fair enough |
What's the current status of this functionality? |
Some folks don't want it apparently; we should make this optional.
Maybe a boolean
layout.legend.tracetoggle
attribute?The text was updated successfully, but these errors were encountered: