-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Scatter <g textpoint> join fixup #1672
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
310e67a
68959b3
49e5da5
3f7601c
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 |
---|---|---|
|
@@ -458,8 +458,10 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition | |
join.enter().append('g').classed('textpoint', true).append('text'); | ||
|
||
join.each(function(d) { | ||
var sel = transition(d3.select(this).select('text')); | ||
Drawing.translatePoint(d, sel, xa, ya); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Each 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. Good catch! 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.
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. Good eyes 👁️ thanks! 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. done in 3f7601c |
||
}); | ||
|
||
join.selectAll('text') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,60 @@ describe('end-to-end scatter tests', function() { | |
expect(Plotly.d3.selectAll('.textpoint').size()).toBe(3); | ||
}).catch(fail).then(done); | ||
}); | ||
|
||
it('should remove all point and text nodes on blank data', function(done) { | ||
function assertNodeCnt(ptCnt, txCnt) { | ||
expect(d3.selectAll('.point').size()).toEqual(ptCnt); | ||
expect(d3.selectAll('.textpoint').size()).toEqual(txCnt); | ||
} | ||
|
||
function assertText(content) { | ||
d3.selectAll('.textpoint').each(function(_, i) { | ||
var tx = d3.select(this).select('text'); | ||
expect(tx.text()).toEqual(content[i]); | ||
}); | ||
} | ||
|
||
Plotly.plot(gd, [{ | ||
x: [150, 350, 650], | ||
y: [100, 300, 600], | ||
text: ['A', 'B', 'C'], | ||
mode: 'markers+text', | ||
marker: { | ||
size: [100, 200, 300], | ||
line: { width: [10, 20, 30] }, | ||
color: 'yellow', | ||
sizeref: 3, | ||
gradient: { | ||
type: 'radial', | ||
color: 'white' | ||
} | ||
} | ||
}]) | ||
.then(function() { | ||
assertNodeCnt(3, 3); | ||
assertText(['A', 'B', 'C']); | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. On d3.selectAll('.point').size() // => 0 (as desired)
d3.selectAll('.textpoint').size() // => 3 (which messes up subsequent updates) |
||
}) | ||
.then(function() { | ||
assertNodeCnt(0, 0); | ||
|
||
return Plotly.restyle(gd, { | ||
x: [[150, 350, 650]], | ||
y: [[100, 300, 600]] | ||
}); | ||
}) | ||
.then(function() { | ||
assertNodeCnt(3, 3); | ||
assertText(['A', 'B', 'C']); | ||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
}); | ||
|
||
describe('scatter hoverPoints', function() { | ||
|
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 🎎 !