Skip to content

Commit 004c401

Browse files
committed
Take config.plotGlPixelRatio into account for scattergl trace
1 parent 7347bed commit 004c401

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

src/plot_api/plot_api.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ function _doPlot(gd, data, layout, config) {
223223

224224
if(fullLayout._glcanvas) {
225225
fullLayout._glcanvas
226-
.attr('width', fullLayout.width)
227-
.attr('height', fullLayout.height);
226+
.attr('width', fullLayout.width * gd._context.plotGlPixelRatio)
227+
.attr('height', fullLayout.height * gd._context.plotGlPixelRatio)
228+
.style('width', fullLayout.width + 'px')
229+
.style('height', fullLayout.height + 'px');
228230

229231
var regl = fullLayout._glcanvas.data()[0].regl;
230232
if(regl) {

src/plots/cartesian/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ exports.toSVG = function(gd) {
596596
preserveAspectRatio: 'none',
597597
x: 0,
598598
y: 0,
599-
width: canvas.width,
600-
height: canvas.height
599+
width: canvas.style.width,
600+
height: canvas.style.height
601601
});
602602
}
603603

src/traces/scattergl/plot.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ var linkTraces = require('../scatter/link_traces');
1414

1515
var styleTextSelection = require('./edit_style').styleTextSelection;
1616

17-
function getViewport(fullLayout, xaxis, yaxis) {
17+
18+
function getViewport(fullLayout, xaxis, yaxis, plotGlPixelRatio) {
1819
var gs = fullLayout._size;
19-
var width = fullLayout.width;
20-
var height = fullLayout.height;
20+
var width = fullLayout.width * plotGlPixelRatio;
21+
var height = fullLayout.height * plotGlPixelRatio;
22+
23+
var l = gs.l * plotGlPixelRatio;
24+
var b = gs.b * plotGlPixelRatio;
25+
var r = gs.r * plotGlPixelRatio;
26+
var t = gs.t * plotGlPixelRatio;
27+
var w = gs.w * plotGlPixelRatio;
28+
var h = gs.h * plotGlPixelRatio;
2129
return [
22-
gs.l + xaxis.domain[0] * gs.w,
23-
gs.b + yaxis.domain[0] * gs.h,
24-
(width - gs.r) - (1 - xaxis.domain[1]) * gs.w,
25-
(height - gs.t) - (1 - yaxis.domain[1]) * gs.h
30+
l + xaxis.domain[0] * w,
31+
b + yaxis.domain[0] * h,
32+
(width - r) - (1 - xaxis.domain[1]) * w,
33+
(height - t) - (1 - yaxis.domain[1]) * h
2634
];
2735
}
2836

@@ -59,7 +67,7 @@ module.exports = function plot(gd, subplot, cdata) {
5967
scene.line2d = createLine(regl);
6068
}
6169
if(scene.scatter2d === true) {
62-
scene.scatter2d = createScatter(regl, { constPointSize: true });
70+
scene.scatter2d = createScatter(regl);
6371
}
6472
if(scene.fill2d === true) {
6573
scene.fill2d = createLine(regl);
@@ -330,7 +338,7 @@ module.exports = function plot(gd, subplot, cdata) {
330338

331339
// provide viewport and range
332340
var vpRange0 = {
333-
viewport: getViewport(fullLayout, xaxis, yaxis),
341+
viewport: getViewport(fullLayout, xaxis, yaxis, gd._context.plotGlPixelRatio),
334342
// TODO do we need those fallbacks?
335343
range: [
336344
(xaxis._rl || xaxis.range)[0],

0 commit comments

Comments
 (0)