My flask app is able to create and update a graph by calling newPlot. I would instead like to update the plot by calling either update or react. When I replace newPlot with either of these functions I get the following error:
Uncaught TypeError: Plotly.react is not a function
or
Uncaught TypeError: Plotly.update is not a function
Plotly.react claims to have the same signature as Plotly.newPlot, but I’m having difficulty finding documentations on how Plotly.update expects its arguments. Do I need to modify my data?
Python code:
graph = dict(
data=[go.Scatter(
x = xData,
y = yData
)],
layout=dict(
title='Plot title,
yaxis=dict(
title="Y Axis"
),
xaxis=dict(
title="X Axis"
),
datarevision = "2",
)
)
# Convert the figures to JSON
graphJSON = json.dumps(graph, cls=plotly.utils.PlotlyJSONEncoder)
return graphJSON
Javascript:
$.post('/updatePlot',
function(response) {
var figure = JSON.parse(response);
Plotly.react("graph-0", figure.data, figure.layout);
})
}