-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Selection re-ordering for scatter traces with ids
#1709
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
Changes from 3 commits
cbcec26
83234b5
c8c3197
5fa1e97
9c35675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,9 +419,6 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition | |
var enter = join.enter().append('path') | ||
.classed('point', true); | ||
|
||
enter.call(Drawing.pointStyle, trace) | ||
.call(Drawing.translatePoints, xa, ya, trace); | ||
|
||
if(hasTransition) { | ||
enter.style('opacity', 0).transition() | ||
.style('opacity', 1); | ||
|
@@ -430,6 +427,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition | |
var markerScale = showMarkers && Drawing.tryColorscale(trace.marker, ''); | ||
var lineScale = showMarkers && Drawing.tryColorscale(trace.marker, 'line'); | ||
|
||
join.order(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one for marker nodes, one for text nodes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right - didn't notice |
||
|
||
join.each(function(d) { | ||
var el = d3.select(this); | ||
var sel = transition(el); | ||
|
@@ -460,6 +459,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition | |
// it gets converted to mathjax | ||
join.enter().append('g').classed('textpoint', true).append('text'); | ||
|
||
join.order(); | ||
|
||
join.each(function(d) { | ||
var g = d3.select(this); | ||
var sel = transition(g.select('text')); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
@n-riesco thanks very much 🎉
Your solution appears to work:

My only concern now is how this interacts with animations. I think the reason why
translatePoints
andpointStyle
are called on enter selection and merge selection has to do with this block below where entering nodes have their opacity transitioned from 0 to 1. I suspect this commit will break this behavior (although the tests are passing) has the entering aren't positioned and styled properly before opacity transition cc @rreusser . It would be nice to write a test case here 😏I'm thinking instead, we could keep those
enter.call()
, makeDrawing.translatePoints
not (and maybe never) remove nodes and make the merge selection.each
block below (which comes after the.order()
) handle the cases where nodes need to be removed.Thoughts?
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.
I think the point you make about animations is important.
And the solution you propose (i.e. remove nodes only after we're done with the enter selection) is more robust.
👍 from me.
Uh oh!
There was an error while loading. Please reload this page.
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.
@etpinard
after thinking a little bit about it. I'm still think thattranslatePoints
andpointStyle
should be applied to the merge selection to keep in sync DOM and trace.I haven't tested it, but.order
should take care of my concern.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.
That's always been the case here and here.