Should Plotly.restyle throw error(s) when the update object isn't valid?
See original GitHub issueConsider this setup,
var data = [
{
y: ['22.3', '23'],
x: ['2001-06-11 11:00', '2001-06-11 11:10'],
line: {
'width': 2
},
uid: '40abaa'
}
]
var layout = {
yaxis: {
title: 'Rate'
},
margin: {
l: 40, b: 40, r: 40, t: 40
}
}
Plotly.plot('mydiv', data, layout)
This dosen’t work, and clears the plot
var update = {
x: ['2001-06-15 11:10', '2001-06-15 11:20'],
y: ['23', '100.3']
}
Plotly.restyle('mydiv', update)
But this is working
var update = {
y: ['23', '100.3']
}
Plotly.restyle('mydiv', update)
Plotly.restyle
is handling two axis data update incorrectly and clears the existing data on the plot.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Function reference in JavaScript - Plotly
When restyling, you may choose to have the specified changes affect as many traces as desired. The update is given as a single...
Read more >Plotly update data - javascript - Stack Overflow
The right way is update the data object, instead of new a data object. ... Plotly.restyle is faster than Plotly.redraw and Plotly.newPlot ....
Read more >plotly - Bountysource
The problem is that the horizontal legend overlaps the x-axis title. ... Should Plotly.restyle throw error(s) when the update object isn't valid? $...
Read more >17 Server-side linking with shiny
More specifically, because plotly is inherently web-based, it allows for more control over how the graphics update in response to user input (e.g.,...
Read more >NEWS
When TRUE (the default), the widget's container element is allowed to grow/shrink ... Fixed an issue where map_color() would throw an error on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@harshjv Your update object should be:
to update the
x
andy
of your single-trace graph.The restyle syntax works as fellow, the outer array maps to different traces i.e. your above update object mapped
'2001-06-15 11:10'
to thex
in the first (and only) trace of your graph. Asx
andy
need to be linked to an array, the graph is left blank after the update.So, to update the the
x
data, you need to nest the update data array.More info about the restyle syntax here. Unfortunately our docs on
restyle
are limited at the moment. Our apologies.That said, one could argue that trying to update
x
(ory
) with a scalar should throw an error. @mdtusz @cldougl thoughts?No initial opposition to throwing an error from me. Regarding docs: we mention wrapping with the outer array in the function reference doc, but I think it could be a bit more clear if we add a codepen example updating data and possibly use x/y data instead of z (it might be a little easier to see/understand the outer array looking at an x array opposed to a z matrix).