react-plotly.js icon indicating copy to clipboard operation
react-plotly.js copied to clipboard

How to rerender figure without page refresh?

Open antonio-hickey opened this issue 4 years ago • 2 comments

So i have a chart that works perfect by default, but I have a button to add the data for a new trace. When clicked it updates the data but my figure/chart does not update/rerender/change. Ideally I want my new trace to be added to the figure when button is clicked, any advice on how to tackle this?

Here's my code: <Plot data={chartData} layout={chartLayout} style={chartStyle} /> where chatData is the variable I'm updating with the data for the new trace

Thanks.

antonio-hickey avatar Sep 19 '21 22:09 antonio-hickey

Have you managed to make this work ? I have a somewhat similar issue: https://github.com/plotly/react-plotly.js/issues/298

GeorgeFlorian avatar Oct 13 '22 07:10 GeorgeFlorian

You need to make sure chartData is a state variable and you are updating it with setChartData. The answer on this stackoverflow post should be what you are looking for: https://stackoverflow.com/questions/70068221/react-plotly-js-re-draws-graph-component-when-data-point-is-changed/73889261#73889261

msimoni18 avatar Dec 11 '22 01:12 msimoni18