-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Restyling a date axis with timestamp data changes axis type to numeric #2144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Side-effect of #1999, thanks for the report. |
I'd like to take a shot at fixing this behaviour, but I'm not sure where the best place to tackle this would be.
|
I think the cleanest way to fix this would be to wait for But since this ticket signals a regression, perhaps we should try to make a quick (albeit temporary) fix. In this case, your first bullet point seems like the best solution. |
I want to update timeseries data and observe the same problem in v1.54.5. Is there a workaround? |
I found a workaround: deleteTraces() + addTraces() instead of restyle(). Downside: The trace must be completely defined. |
When clearing the data of the first trace, the display breaks. codepen.io#Plotly.js axis.type discard error js source codevar trace1 = {
name: "trace1",
x: [new Date('2020-10-04'), new Date('2021-11-04'), new Date('2023-12-04')],
y: [90, 40, 60],
type: 'scatter'
};
var trace2 = {
name: "trace2",
x: [new Date('2020-10-04'), new Date('2021-11-04'), new Date('2023-12-04')],
y: [80, 50, 40],
type: 'scatter'
};
var layout = {
showlegend: true,
xaxis: {
type: "date" // Explicitly
}
};
Plotly.newPlot('myDiv', [trace1, trace2], layout);
setTimeout(function () {
// Then I want to leave the legend1. But hide the trace1
Plotly.restyle('myDiv', { x: [[null]], y: [[null]] }, [0]); // this doesn't work
//Plotly.restyle('myDiv', { x: [[null]], y: [[null]] }, [1]); // it works
}, 2000); |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Unfortunately, I am still getting this exact issue. plotly.js v2.35.2. |
Starting with Plotly.js 1.31.0, restyling a plot using timestamps instead of date strings turns the axis from a date axis to a numeric axis, even if the original data was in the same format, as can be seen in this codepen. In 1.30.0, this didn't happen.
The text was updated successfully, but these errors were encountered: