Hi there! I’m building some animated graphs with Plotly.js and custom buttons. Really I’m not having any problem but I’m getting the next error when I pause the animation:
plotly-2.32.0.min.js:8 Uncaught (in promise) undefined
And the steps:
Source | @ | Script file |
---|---|---|
(anonymous) | @ | plotly-2.32.0.min.js:8 |
(anonymous) | @ | plotly-2.32.0.min.js:8 |
e.animate | @ | plotly-2.32.0.min.js:8 |
pause | @ | animate.js:42 |
onclick | @ | index.html:25 |
I had a similar error with a slider and I solve it by adding then → catch ; but here it didn’t work
I don’t know if it’s a bug or what.
Thanks!!
I supply part of the code:
Buttons (simple html buttons with onclick() attribute):
function play() {
if (!isAnimating) {
Plotly.animate(graph, null, frameConfig(true));
isAnimating = true;
}
}
function pause() {
if (isAnimating) {
Plotly.animate(graph, [], {mode: 'immediate'});
isAnimating = false;
}
}
Slider (same as buttons, html input):
slider.addEventListener('input', function() {
// Pause the animation if it is running
if (isAnimating) {
btnPause.click();
// Set a timeout to resume the animation after a pause in slider input
setTimeout(() => {
btnPlay.click();
}, 500);
}
// Update the time output
timeOutput.textContent = processedData2.T[this.value].toFixed(2);
// Update the position of the cars
cars = 'frame' + this.value;
Plotly.animate(graph, [cars, cars], frameConfig(false))
.then(() => {
// Animation update logic here (if needed)
})
.catch(() => {
// Error handling here (if needed)
});
// Update the table
updateTableContent();
});