Hi,
I am quite new to plotly, and even newer to this forum. So I might say something stupid, or say it in the wrong place. Sorry in advance about that.
I am trying to do a very simple animation. So simple that I have difficulties to believe that a bug prevent it. Yet, I start to wonder if it is not so.
I want to animate a time series, showing the same curve with a sliding timeframe.
So, for example if I had a list of temperatures from 1900 to 2000, I want an animation that goes from a chart of temperatures from 1900 to 1920, then 1901 to 1921, then…, then 1980 to 2000.
It seems to be a quite classical way to animate a chart. Yet, it doesn’t work with any of the versions of plotly I have tried.
Here is the smallest code to illustrate the problem:
Plotly.newPlot("plot",
[{x:[0,1,2,3,4,5,6], y:[0,1,4,9,16,25,36]}],
{xaxis:{range:[0,3], type:"date"}, yaxis:{range:[0,36]}});
Plotly.animate("plot", {
layout:{ xaxis:{range:[3,6], type:"date"}}
});
I know, date are stupids (it goes from 1970 Jan 1, to 1970 Jan 1 + 6 milliseconds), but problem is the same with any other date (and also if dates are given with a string such as “1970-01-01”, or with a datetime)
Advantage of those dates, is that it is very easy to see what was expected from this code. Just remove type:“date”, and you have exactly what I wanted. Except that the x axis is now a numerical one, not a date.
Plotly.newPlot("plot",
[{x:[0,1,2,3,4,5,6], y:[0,1,4,9,16,25,36]}],
{xaxis:{range:[0,3]}, yaxis:{range:[0,36]}});
Plotly.animate("plot", {
layout:{ xaxis:{range:[3,6]}}
});
Note that it is only animate that fails with date xaxis. The initial plot works just fine whatever the type.
Am I doing something wrong?