plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.92k stars 1.86k forks source link

why Plotly.react() is as slow as Plotly.newPlot()? updating single trace of many #5674

Open KestutisMa opened 3 years ago

KestutisMa commented 3 years ago

Hi, I am trying to redraw only single trace in a plot of many traces (biophysical data). I tried to follow instructions in react-plotly and plotlyjs documentation: https://plotly.com/javascript/plotlyjs-function-reference/#plotlyreact Plot is updated but I don't see any performance improvement if I change only single element of data or all data elements: Here is MWE in codepen Briefly, I generated sample data 100 traces of 10000 points and changing only first trace with:

  data[0].x =  [...Array(10).keys()].map( c=> c/10) //change only first trace
  data[0].y =  [...Array(10).keys()].map( c=> Math.random())
  Plotly.react('myDiv', data, layout);

Drawing plot containing single trace takes just a split of second, but if I had already drawn many traces and I want to redraw only single trace, it takes same time as to redraw all traces (few seconds). Am I doing something wrong?

hp8wvvvgnj6asjm7 commented 3 years ago

same issue over here..

robert-lieck commented 6 months ago

I am having the same/related issue in a Plotly Dash Python app. I have some rather complex "background" traces that are static and a very small, dynamically changing "indicator" trace (typically only a single marker indicating a location in the figure).

The fact that the entire figure is redrawn every time essentially makes Plotly unusable for this kind of highly reactive applications. Not sure how easy it is to fix this, but it would make a huge difference. As it stands, I will probably need to move away from Plotly.

Interestingly, without Dash, just using a slider, this does not seem to be a problem (see e.g. https://robert-lieck.github.io/musicflower/auto_examples/plot_time_traces.html).

@chriddyp It sounded like this is something you would also like to see working (https://community.plotly.com/t/is-it-possible-to-update-just-layout-not-whole-figure-of-graph-in-callback/8300). Could you provide an update on the status quo and whether we can hope for a solution any time soon?

By the way, many thanks for this amazing framework, I have used it in a many visualisation apps and love it for its convenient Python API and the great visualisation capabilities (esp. for complex 3D figures)!