-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Scatter <g textpoint> join fixup #1672
Conversation
- return false when sel is removed i.e. when its x/y coords are non-numeric - this is helpful for clearing associated <g textpoint> - return true otherwise
src/traces/scatter/plot.js
Outdated
var g = d3.select(this); | ||
var sel = transition(g.select('text')); | ||
var hasTextPt = Drawing.translatePoint(d, sel, xa, ya); | ||
if(!hasTextPt) g.remove(); |
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.
Each <text>
node is wrapped in a <g class="textpoint">
group. It is on this group that the data-join happens so we must make sure that group is removed whenever <text>
node are removed to obtain the correct enter and merge selections on updates.
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.
Good catch!
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.
Drawing.translatePoint
gets used in line 436 above too, and could short-circuit the lines after it if it removed the node.
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.
Good eyes 👁️ thanks!
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.
done in 3f7601c
return Plotly.restyle(gd, { | ||
x: [[null, undefined, NaN]], | ||
y: [[NaN, null, undefined]] | ||
}); |
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.
On master
, this restyle
call results in
d3.selectAll('.point').size() // => 0 (as desired)
d3.selectAll('.textpoint').size() // => 3 (which messes up subsequent updates)
* @return {boolean} : | ||
* true if selection got translated | ||
* false if selection got removed | ||
*/ |
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.
Thanks 🎎 !
Great! 💃 |
fixes #1666
cc @rreusser and @n-riesco
Continuing on #1666 (comment), I found a case (see 310e67a ) where
restyle
was failing on blankx
,y
arrays without using filter transforms, so the patch had to be made inscatter/plot.js
(see 49e5da5)After this patch: