Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Plots with different ids sharing same legend

Hello,
I have three different graphs each with an unique id and callbacks with the same input, that have the same legend entries. Is there a way for an easier overview, that I have one legend for all three figures and if I select or deselect an entry that all three figures are updated?
Also is there a way for showing the plot title only once for all three graph, because I have the same title for all three?

Thank you!

You’ll be able to achieve this using custom legend click handlers:

function handler(d) {
     // use field in 'd' to determine which items to update
     Plotly.restyle('graph', {/**/})
     Plotly.restyle('graph2', {/**/})
     Plotly.restyle('graph3', {/**/})
}

Plotly.newPlot('graph', [/**/], {/**/}).then(gd => {
  gd.on('plotly_legendclick', handler)
})
Plotly.newPlot('graph2', [/**/], {/**/}).then(gd => {
  gd.on('plotly_legendclick', handler)
})
Plotly.newPlot('graph3', [/**/], {/**/}).then(gd => {
  gd.on('plotly_legendclick', handler)
})