Hi
I am trying to get a basic plotly.js graph to update using the “update” method, but the graph simply empties itself. As far as I can tell I am sending the correct parameters, but the help I can find online is mainly for the Python version and I’m stuck. I’d be grateful if someone can point out what I’m doing wrong here?
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div>
<div id="PlotlyTest"></div>
</div>
<script type="text/javascript">
var data = [{
x: ['UK','Spain'],
y: [1,2],
type: 'bar'
}];
var layout = {
updatemenus: [{
y: 0.8,
yanchor: 'top',
buttons: [{
method: 'update',
args: [{'x':['USA'],'y':[2],'marker.color': 'red'}, {'title': 'some new title'}],
label: 'red'
}]
}]
};
Plotly.newPlot('PlotlyTest', data, layout);
</script>
</body>
</html>