Skip to content

Commit aa67a7f

Browse files
committed
Take config.plotGlPixelRatio into account for parcoords trace
1 parent 004c401 commit aa67a7f

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/traces/parcoords/base_plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ exports.toSVG = function(gd) {
3939
preserveAspectRatio: 'none',
4040
x: 0,
4141
y: 0,
42-
width: canvas.width,
43-
height: canvas.height
42+
width: canvas.style.width,
43+
height: canvas.style.height
4444
});
4545
}
4646

src/traces/parcoords/lines.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,27 @@ function emptyAttributes(regl) {
160160
return attributes;
161161
}
162162

163-
function makeItem(model, leftmost, rightmost, itemNumber, i0, i1, x, y, panelSizeX, panelSizeY, crossfilterDimensionIndex, drwLayer, constraints) {
163+
function makeItem(
164+
model, leftmost, rightmost, itemNumber, i0, i1, x, y, panelSizeX, panelSizeY,
165+
crossfilterDimensionIndex, drwLayer, constraints, plotGlPixelRatio
166+
) {
164167
var dims = [[], []];
165168
for(var k = 0; k < 64; k++) {
166169
dims[0][k] = (k === i0) ? 1 : 0;
167170
dims[1][k] = (k === i1) ? 1 : 0;
168171
}
169-
170-
var overdrag = model.lines.canvasOverdrag;
172+
x *= plotGlPixelRatio;
173+
y *= plotGlPixelRatio;
174+
panelSizeX *= plotGlPixelRatio;
175+
panelSizeY *= plotGlPixelRatio;
176+
var overdrag = model.lines.canvasOverdrag * plotGlPixelRatio;
171177
var domain = model.domain;
172-
var canvasWidth = model.canvasWidth;
173-
var canvasHeight = model.canvasHeight;
178+
var canvasWidth = model.canvasWidth * plotGlPixelRatio;
179+
var canvasHeight = model.canvasHeight * plotGlPixelRatio;
180+
var padL = model.pad.l * plotGlPixelRatio;
181+
var padB = model.pad.b * plotGlPixelRatio;
182+
var layoutHeight = model.layoutHeight * plotGlPixelRatio;
183+
var layoutWidth = model.layoutWidth * plotGlPixelRatio;
174184

175185
var deselectedLinesColor = model.deselectedLines.color;
176186

@@ -201,13 +211,13 @@ function makeItem(model, leftmost, rightmost, itemNumber, i0, i1, x, y, panelSiz
201211
Math.max(1 / 255, Math.pow(1 / model.lines.color.length, 1 / 3))
202212
],
203213

204-
scissorX: (itemNumber === leftmost ? 0 : x + overdrag) + (model.pad.l - overdrag) + model.layoutWidth * domain.x[0],
214+
scissorX: (itemNumber === leftmost ? 0 : x + overdrag) + (padL - overdrag) + layoutWidth * domain.x[0],
205215
scissorWidth: (itemNumber === rightmost ? canvasWidth - x + overdrag : panelSizeX + 0.5) + (itemNumber === leftmost ? x + overdrag : 0),
206-
scissorY: y + model.pad.b + model.layoutHeight * domain.y[0],
216+
scissorY: y + padB + layoutHeight * domain.y[0],
207217
scissorHeight: panelSizeY,
208218

209-
viewportX: model.pad.l - overdrag + model.layoutWidth * domain.x[0],
210-
viewportY: model.pad.b + model.layoutHeight * domain.y[0],
219+
viewportX: padL - overdrag + layoutWidth * domain.x[0],
220+
viewportY: padB + layoutHeight * domain.y[0],
211221
viewportWidth: canvasWidth,
212222
viewportHeight: canvasHeight
213223
}, constraints);
@@ -454,6 +464,7 @@ module.exports = function(canvasGL, d) {
454464
var x = p.canvasX;
455465
var y = p.canvasY;
456466
var nextX = x + p.panelSizeX;
467+
var plotGlPixelRatio = p.plotGlPixelRatio;
457468
if(setChanged ||
458469
!prevAxisOrder[i0] ||
459470
prevAxisOrder[i0][0] !== x ||
@@ -467,7 +478,8 @@ module.exports = function(canvasGL, d) {
467478
p.panelSizeX, p.panelSizeY,
468479
p.dim0.crossfilterDimensionIndex,
469480
isContext ? 0 : isPick ? 2 : 1,
470-
constraints
481+
constraints,
482+
plotGlPixelRatio
471483
);
472484

473485
renderState.clearOnly = clearOnly;

src/traces/parcoords/parcoords.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function calcTilt(angle, position) {
369369
};
370370
}
371371

372-
function updatePanelLayout(yAxis, vm) {
372+
function updatePanelLayout(yAxis, vm, plotGlPixelRatio) {
373373
var panels = vm.panels || (vm.panels = []);
374374
var data = yAxis.data();
375375
for(var i = 0; i < data.length - 1; i++) {
@@ -383,6 +383,7 @@ function updatePanelLayout(yAxis, vm) {
383383
p.panelSizeY = vm.model.canvasHeight;
384384
p.y = 0;
385385
p.canvasY = 0;
386+
p.plotGlPixelRatio = plotGlPixelRatio;
386387
}
387388
}
388389

@@ -433,6 +434,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
433434
var fullLayout = gd._fullLayout;
434435
var svg = fullLayout._toppaper;
435436
var glContainer = fullLayout._glcontainer;
437+
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
436438

437439
calcAllTicks(cdModule);
438440

@@ -534,7 +536,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
534536
.classed(c.cn.yAxis, true);
535537

536538
parcoordsControlView.each(function(p) {
537-
updatePanelLayout(yAxis, p);
539+
updatePanelLayout(yAxis, p, plotGlPixelRatio);
538540
});
539541

540542
glLayers
@@ -573,7 +575,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
573575
e.canvasX = e.x * e.model.canvasPixelRatio;
574576
});
575577

576-
updatePanelLayout(yAxis, p);
578+
updatePanelLayout(yAxis, p, plotGlPixelRatio);
577579

578580
yAxis.filter(function(e) { return Math.abs(d.xIndex - e.xIndex) !== 0; })
579581
.attr('transform', function(d) { return strTranslate(d.xScale(d.xIndex), 0); });
@@ -586,7 +588,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
586588
var p = d.parent;
587589
d.x = d.xScale(d.xIndex);
588590
d.canvasX = d.x * d.model.canvasPixelRatio;
589-
updatePanelLayout(yAxis, p);
591+
updatePanelLayout(yAxis, p, plotGlPixelRatio);
590592
d3.select(this)
591593
.attr('transform', function(d) { return strTranslate(d.x, 0); });
592594
p.contextLayer && p.contextLayer.render(p.panels, false, !someFiltersActive(p));

0 commit comments

Comments
 (0)