-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
lib function to interleave trace updates into a restyle #847
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
Conversation
5d6bbf3
to
127a4fd
Compare
var output = {}; | ||
|
||
for(i = 0; i < traces.length; i++) { | ||
for(prop in traces[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non- 🚫 , but we usually loop over object keys by first var keys = Object.keys(traces)
and then looping of keys
.
Here's what
That's fine. |
💃 once you're happy with it. |
127a4fd
to
40344ff
Compare
40344ff
to
e77a276
Compare
Regarding ambiguities, I was referring to conflicts within a single statement, which seems to be order-dependent. See example. Plotly.restyle('graph', {
marker: {color: 'red', size: 10},
'marker.color': 'blue'
}) |
Oh I see. The last key-value item ( @rreusser did you find any cases where |
I didn't find cases where it didn't obey it, but key order in iterated javascript objects, though likely nailed down pretty well in the specs, doesn't seem like the most friendly thing to confront people with on a regular basis. But it's user input anyway and it's well-defined, if weird, so I'm fine with it. |
For reference: ES5: 12.6.4 The for-in statement:
And from ES5: 15.2.3.14 Object.keys:
That means there's no guarantee |
@etpinard whoops. Didn't realize this wasn't already closed. It's not part, but instead managed to avoid the need for it by using the full supply defaults to apply the changes. So I think this is simply not needed, but there's a chance the code could come in handy if it does turn out to be necessary. |
cc: @etpinard. This PR implements an unused library function that translates a frame-style update into a restyle-…um, style update. Goal: ease the burden on reviewing #802, so perhaps review here and I'll cherry-pick into that PR if it passes. It translates this:
into this:
Caveat: There's some room for ambiguity if you specify
marker.color
and then overwrite withmarker: {}
. I'm a fan of strict sanity checking and good error reporting, but it's some extra work to either detect and throw an error or detect and resolve, so I'll hold off on this unless it seems necessary. At the very least, it's consistent. additional comment: How does restyle currently handle ambiguities? Unless we rigorously detect this case already, seems like this would all be the user's burden anyway.Together with #844, this means frame updates can simply be interleaved and passed to
Plotly.restyle
. They are interleaved in order received, so that managing trace indices is not a concern of this function.