✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐍Plotly, Coiled CEOs Discuss Partnering & ML Experts show us how Dash + Dask apps work Register for the Webinar.

Get state of current chart

Is there any way to get information about state of given plotly chart? E.g. I have 4 line traces in a chart and the user has selected two of them, I want to fetch this information to know which two traces have been clicked.

Just lookup .data and .layout of the graph <div>:

var gd = document.getElementById('graph')

gd.data // => current data
gd.layout // => current layout

This gives me the entire data that was initially plotted and not only the one that is being displayed currently. E.g. I have 4 traces and I clicked on 2 traces in legend to display them. Now I want to know which traces are being displayed.


gd.data.filter(trace => trace.visible === true)
1 Like