You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The graphDiv.data looks like it 'should be', the trouble is with the passed in data array. At the first addTraces call the data array gets mutated and the trace gets added at the end of the array, not at the specified index, and further addTraces calls don't even further mutate the array.
This is very confusing and I'd say it's a bug one way or another (mutating the passed in data array or not continuing to do so after the first addTraces call, even if the addTraces index gets ignored). Should be clear that there's only one 'source of truth' so either the graphDiv.data should be accessed or the developer should keep tabs on the traces himself.
Currently the functionality for my use (Angular2 and input binding) is broken and I'll have to resort to to Plotly.redraw.
The text was updated successfully, but these errors were encountered:
graphDiv.data - and graphDiv.layout - are intended to be the 'source of truth', and all changes to a plot first modify these objects and then propagate the changes to the plot. We've never made a commitment either way about what would happen to the specific data and layout objects you pass in, whether they would mutate or be replaced. But I can see that the behavior of addTraces, doing half the mutation and then replacing the array, is particularly non-intuitive, and potentially harmful if you aren't expecting it.
When things change, we've generally mutated rather than replaced, owing largely to performance for cases like streaming new data into existing x/y arrays. We would consider making this a guarantee, that we will only ever mutate these objects, so your original reference remains a valid view into the plot state, but I would consider that a new feature rather than a bug.
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
http://codepen.io/anon/pen/vxWRry
The
graphDiv.data
looks like it 'should be', the trouble is with the passed indata
array. At the firstaddTraces
call thedata
array gets mutated and the trace gets added at the end of the array, not at the specified index, and furtheraddTraces
calls don't even further mutate the array.This is very confusing and I'd say it's a bug one way or another (mutating the passed in
data
array or not continuing to do so after the firstaddTraces
call, even if theaddTraces
index gets ignored). Should be clear that there's only one 'source of truth' so either thegraphDiv.data
should be accessed or the developer should keep tabs on the traces himself.Currently the functionality for my use (Angular2 and input binding) is broken and I'll have to resort to to
Plotly.redraw
.The text was updated successfully, but these errors were encountered: