Skip to content

Commit d99ae9c

Browse files
committed
rework pixel-scale adjustments
1 parent 74dbac7 commit d99ae9c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/traces/sankey/render.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function nodeModel(uniqueKeys, d, n) {
181181
var tc = tinycolor(n.color),
182182
zoneThicknessPad = c.nodePadAcross,
183183
zoneLengthPad = d.nodePad / 2,
184-
visibleThickness = n.dx + 0.5,
185-
visibleLength = Math.max(1, n.dy - 0.5);
184+
visibleThickness = n.dx,
185+
visibleLength = Math.max(1, n.dy);
186186

187187
var basicKey = n.label;
188188
var foundKey = uniqueKeys[basicKey];
@@ -203,7 +203,7 @@ function nodeModel(uniqueKeys, d, n) {
203203
textFont: d.textFont,
204204
size: d.horizontal ? d.height : d.width,
205205
visibleWidth: Math.ceil(visibleThickness),
206-
visibleHeight: Math.ceil(visibleLength),
206+
visibleHeight: visibleLength,
207207
zoneX: -zoneThicknessPad,
208208
zoneY: -zoneLengthPad,
209209
zoneWidth: visibleThickness + 2 * zoneThicknessPad,
@@ -227,14 +227,10 @@ function nodeModel(uniqueKeys, d, n) {
227227

228228
// rendering snippets
229229

230-
function crispLinesOnEnd(sankeyNode) {
231-
d3.select(sankeyNode.node().parentNode).style('shape-rendering', 'crispEdges');
232-
}
233-
234230
function updateNodePositions(sankeyNode) {
235231
sankeyNode
236232
.attr('transform', function(d) {
237-
return 'translate(' + (d.node.x - 0.5) + ', ' + (d.node.y - d.node.dy / 2 + 0.5) + ')';
233+
return 'translate(' + d.node.x.toFixed(3) + ', ' + (d.node.y - d.node.dy / 2).toFixed(3) + ')';
238234
});
239235
}
240236

@@ -247,7 +243,6 @@ function linkPath(d) {
247243
}
248244

249245
function updateNodeShapes(sankeyNode) {
250-
d3.select(sankeyNode.node().parentNode).style('shape-rendering', 'optimizeSpeed');
251246
sankeyNode.call(updateNodePositions);
252247
}
253248

@@ -360,7 +355,6 @@ function attachDragHandler(sankeyNode, sankeyLink, callbacks) {
360355
if(d.arrangement !== 'snap') {
361356
d.sankey.relayout();
362357
updateShapes(sankeyNode.filter(sameLayer(d)), sankeyLink);
363-
sankeyNode.call(crispLinesOnEnd);
364358
}
365359
})
366360

@@ -414,9 +408,6 @@ function snappingForce(sankeyNode, forceKey, nodes, d) {
414408
}
415409
if(!d.interactionState.dragInProgress && maxVelocity < 0.1 && d.forceLayouts[forceKey].alpha() > 0) {
416410
d.forceLayouts[forceKey].alpha(0);
417-
window.setTimeout(function() {
418-
sankeyNode.call(crispLinesOnEnd);
419-
}, 30); // geome on move, crisp when static
420411
}
421412
};
422413
}
@@ -495,7 +486,7 @@ module.exports = function(svg, styledData, layout, callbacks) {
495486

496487
sankeyNodeSet.enter()
497488
.append('g')
498-
.style('shape-rendering', 'geometricPrecision')
489+
.style('shape-rendering', 'crispEdges')
499490
.classed('sankeyNodeSet', true);
500491

501492
sankeyNodeSet

0 commit comments

Comments
 (0)