Skip to content

Commit 4e98b12

Browse files
committed
working around image gen sensitivity
1 parent 4ea240f commit 4e98b12

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/traces/sankey/render.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ function sizeNode(rect) {
247247
.attr('height', function(d) {return d.visibleHeight;});
248248
}
249249

250+
function linksTransform(d) {
251+
return d.horizontal ? 'matrix(1,0,0,1,0,0)' : 'matrix(0,1,1,0,0,0)';
252+
}
253+
254+
function textGuidePath(d) {
255+
return d3.svg.line()([
256+
[d.horizontal ? (d.left ? -d.sizeAcross : d.visibleWidth + c.nodeTextOffsetHorizontal) : c.nodeTextOffsetHorizontal, d.labelY],
257+
[d.horizontal ? (d.left ? - c.nodeTextOffsetHorizontal : d.sizeAcross) : d.visibleWidth - c.nodeTextOffsetHorizontal, d.labelY]
258+
]);}
259+
250260
// event handling
251261

252262
function attachPointerEvents(selection, sankey, eventSet) {
@@ -417,11 +427,12 @@ module.exports = function(svg, styledData, layout, callbacks) {
417427
sankeyLinks.enter()
418428
.append('g')
419429
.classed('sankeyLinks', true)
420-
.style('fill', 'none');
430+
.style('fill', 'none')
431+
.style('transform', linksTransform);
421432

422433
sankeyLinks.transition()
423434
.ease(c.ease).duration(c.duration)
424-
.style('transform', function(d) {return d.horizontal ? 'matrix(1,0,0,1,0,0)' : 'matrix(0,1,1,0,0,0)';});
435+
.style('transform', linksTransform);
425436

426437
var sankeyLink = sankeyLinks.selectAll('.sankeyLink')
427438
.data(function(d) {
@@ -441,16 +452,10 @@ module.exports = function(svg, styledData, layout, callbacks) {
441452
.style('stroke-width', function(d) {return d.link.dy > 1 ? 2 : 1;})
442453
.style('stroke-opacity', function(d) {return d.tinyColorAlpha;})
443454
.style('fill', function(d) {return d.tinyColorHue;})
444-
.style('fill-opacity', function(d) {return d.tinyColorAlpha;});
445-
446-
sankeyLink.transition()
447-
.ease(c.ease).duration(c.duration)
455+
.style('fill-opacity', function(d) {return d.tinyColorAlpha;})
448456
.attr('d', linkPath);
449457

450-
sankeyLink.exit().transition()
451-
.ease(c.ease).duration(c.duration)
452-
.style('opacity', 0)
453-
.remove();
458+
sankeyLink.exit().remove();
454459

455460
var sankeyNodeSet = sankey.selectAll('.sankeyNodeSet')
456461
.data(repeat, keyFun);
@@ -535,16 +540,13 @@ module.exports = function(svg, styledData, layout, callbacks) {
535540
nodeLabelGuide.enter()
536541
.append('path')
537542
.classed('nodeLabelGuide', true)
538-
.attr('id', function(d) {return d.uniqueNodeLabelPathId;});
543+
.attr('id', function(d) {return d.uniqueNodeLabelPathId;})
544+
.attr('d', textGuidePath);
539545

540546
nodeLabelGuide
541547
.transition()
542548
.ease(c.ease).duration(c.duration)
543-
.attr('d', function(d) {
544-
return d3.svg.line()([
545-
[d.horizontal ? (d.left ? -d.sizeAcross : d.visibleWidth + c.nodeTextOffsetHorizontal) : c.nodeTextOffsetHorizontal, d.labelY],
546-
[d.horizontal ? (d.left ? - c.nodeTextOffsetHorizontal : d.sizeAcross) : d.visibleWidth - c.nodeTextOffsetHorizontal, d.labelY]
547-
]);});
549+
.attr('d', textGuidePath);
548550

549551
var nodeLabel = sankeyNode.selectAll('.nodeLabel')
550552
.data(repeat);

0 commit comments

Comments
 (0)