I’ve been spending the last few weeks getting into the weeds with Dash Leaflet, which is an outstanding library (thanks @Emil !). There is a hideout concept which allows for super quick filtering (which I use with geojsons) and can be done clientside. I’ve played around with hiding/showing traces in a callback via the “figure”, but I’m not sure if there is a better way of doing it. Right now, if I want a graph that filters via some input, I can search the figure data via a loop and find which trace to expose and set the others to hidden. But with leaflet, I can filter via the hideout and there is no need to loop anything (or really write much code at all).
For example:
I would then create a figure with let’s say ~100 traces (Trace1-Trace100) but want to quickly filter the traces without having to loop through the entire figure. Applying the leaflet concept, the dcc.Figure could have a hideout prop that sets which traces are visible. I could then populate the entire graph (100 traces) but use the hideout client side to quickly filter the chart.
A simple code example would be:
fig = go.Figure()
for i in range(0,100):
fig.add_trace(go.Scatter(
x=SOMEDATA,
y=SOMEDATA,
name=f'Trace{i}'
))
myHideout = ["Trace1","Trace2","Trace3"]
dcc.Graph(figure=fig,hideout=myHideout)
And the graph would only show those traces and I could set the hideout via a callback (clientside) and it would automatically filter the graph. Does anything like this exist now? Or is it best to just loop through the fig[‘data’] (loop or list comprehension)?