Replace two traces in a callback with extendData that are of unequal size

Hi everyone,

I have a Dash app running with a figure (scatter3d) containing 3 traces. The last trace is huge and the first two are much smaller. To prevent the entire figure to be replotted in my callback, I like to use extendData to replace the data in the smaller first two traces.

However, I’m able to replace the data in either one of the traces but not both using the extendData property:

The first trace is of length N1 and the second of length N2. I’m using julia (but I guess the python version is similar).

callback!(
    app,
    Output("graph", "extendData"),
    Input("year-slider-2", "value"),
) do value
    N1 = 5 
    return [Dict("x"=>[randn(N1)],:y=>[randn(N1)],:z=>[randn(N1)]),[0],N1] # update first trace 
end

Replacing the second trace is also possible by replacing it to

N2 = 10 
return [Dict("x"=>[randn(N2)],:y=>[randn(N2)],:z=>[randn(N2)]),[1],N2] # update second 

But how do I replace both traces with N1 and N2 being unequal. I tried different combos but none seem to work.

The documentation say: that maxPoints (optional) is either an integer defining the maximum number of points allowed or an object with key:value pairs matching updateData. I was not able to parse the “key:value pairs matching updateData” part for this to work.

I figured it out. If I return maxPoints as a dict with same keys it seems to work:

return [Dict(:x=>[randn(N1),randn(N2)],:y=>[randn(N1),randn(N2)],:z=>[randn(N1),randn(N2)]),[0,1],Dict(:x=>[N1,N2],:y=>[N1,N2],:z=>[N1,N2])] # update both traces