Skip to content

Commit 2ca2443

Browse files
committed
*Make* multiline tspans work correctly
1 parent 4f3f0a6 commit 2ca2443

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/components/drawing/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ drawing.textPointStyle = function(s, trace) {
343343
s.each(function(d) {
344344
var p = d3.select(this),
345345
text = d.tx || trace.text;
346+
346347
if(!text || Array.isArray(text)) {
347348
// isArray test handles the case of (intentionally) missing
348349
// or empty text within a text array

src/traces/scatter/plot.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,20 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
456456
});
457457

458458
join.selectAll('text')
459-
.call(Drawing.textPointStyle, trace);
459+
.call(Drawing.textPointStyle, trace)
460+
.each(function(d) {
461+
462+
// This just *has* to be totally custom becuase of SVG text positioning :(
463+
// It's obviously copied from translatePoint; we just can't use that
464+
//
465+
// put xp and yp into d if pixel scaling is already done
466+
var x = d.xp || xa.c2p(d.x),
467+
y = d.yp || ya.c2p(d.y);
468+
469+
d3.select(this).selectAll('tspan').each(function() {
470+
transition(d3.select(this)).attr({x: x, y: y});
471+
});
472+
});
460473

461474
join.exit().remove();
462475
}

0 commit comments

Comments
 (0)