Hello,
My code updating the scatter3d
using setInterval
and Plotly.extendTraces
. I am also using uirevision
, so that I can change the camera position even during the updating (see building up of the graph from different angle).
But this is not working. I use the following code:
HTML:
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="graph"></div>
</body>
<script src="3d_graph.js"></script>
3d_graph.js
var fig = {}
fig.data = [{
type: 'scatter3d',
x: [0],
y: [0],
z: [0]
}]
fig.layout = {
scene: {
xaxis: { range: [-1, 1], rangemode: 'tozero', tickmode: "linear", dtick: 1 },
yaxis: { range: [-1, 1], rangemode: 'tozero', tickmode: "linear", dtick: 1 },
zaxis: { range: [-1, 1], rangemode: 'tozero', tickmode: "linear", dtick: 1 },
aspectratio: { x: 1, y: 1, z: 1 },
uirevision: true
//camera: { eye: { x: 1.5, y: 1.5, z: 1.5 } },
//aspectmode: 'cube'
},
xaxis: { range: [-2, 2], fixedrange: false, automargin: true },
yaxis: { range: [-2, 2], fixedrange: false, automargin: true },
zaxis: { range: [-2, 2], fixedrange: false, automargin: true },
width: 1000,
height: 1000,
margin: { autoexpand: false },
autosize: false
}
Plotly.react('graph', fig)
var cnt = 0;
var interval = setInterval(function() {
Plotly.extendTraces('graph', {
x: [
[Math.random()]
],
y: [
[Math.random()]
],
z: [
[Math.random()]
]
}, [0])
cnt = cnt + 1;
if (cnt === 10) clearInterval(interval);
}, 500);
Any idea why it is not working?