Skip to content

Commit f03bce0

Browse files
committed
scattergl size fixes.
1 parent 55ee4b3 commit f03bce0

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/traces/scatter/make_bubble_size_func.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ var isNumeric = require('fast-isnumeric');
55

66
// used in the drawing step for 'scatter' and 'scattegeo' and
77
// in the convert step for 'scatter3d'
8-
module.exports = function makeBubbleSizeFn(trace) {
8+
module.exports = function makeBubbleSizeFn(trace, factor) {
9+
if(!factor) {
10+
factor = 2;
11+
}
912
var marker = trace.marker;
1013
var sizeRef = marker.sizeref || 1;
1114
var sizeMin = marker.sizemin || 0;
@@ -21,7 +24,7 @@ module.exports = function makeBubbleSizeFn(trace) {
2124
// TODO add support for position/negative bubbles?
2225
// TODO add 'sizeoffset' attribute?
2326
return function(v) {
24-
var baseSize = baseFn(v / 2);
27+
var baseSize = baseFn(v / factor);
2528

2629
// don't show non-numeric and negative sizes
2730
return (isNumeric(baseSize) && (baseSize > 0)) ?

src/traces/scattergl/convert.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function convertStyle(gd, trace) {
3939
textUnsel: undefined
4040
};
4141

42+
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
43+
4244
if(trace.visible !== true) return opts;
4345

4446
if(subTypes.hasText(trace)) {
@@ -64,7 +66,7 @@ function convertStyle(gd, trace) {
6466
if(subTypes.hasLines(trace)) {
6567
opts.line = {
6668
overlay: true,
67-
thickness: trace.line.width,
69+
thickness: trace.line.width * plotGlPixelRatio,
6870
color: trace.line.color,
6971
opacity: trace.opacity
7072
};
@@ -77,11 +79,11 @@ function convertStyle(gd, trace) {
7779
}
7880

7981
if(trace.error_x && trace.error_x.visible) {
80-
opts.errorX = convertErrorBarStyle(trace, trace.error_x);
82+
opts.errorX = convertErrorBarStyle(trace, trace.error_x, plotGlPixelRatio);
8183
}
8284

8385
if(trace.error_y && trace.error_y.visible) {
84-
opts.errorY = convertErrorBarStyle(trace, trace.error_y);
86+
opts.errorY = convertErrorBarStyle(trace, trace.error_y, plotGlPixelRatio);
8587
}
8688

8789
if(!!trace.fill && trace.fill !== 'none') {
@@ -106,6 +108,7 @@ function convertTextStyle(gd, trace) {
106108
var tff = textfontIn.family;
107109
var optsOut = {};
108110
var i;
111+
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
109112

110113
var texttemplate = trace.texttemplate;
111114
if(texttemplate) {
@@ -191,13 +194,13 @@ function convertTextStyle(gd, trace) {
191194
Array.isArray(tfs) ? (
192195
isNumeric(tfs[i]) ? tfs[i] : 0
193196
) : tfs
194-
);
197+
) * plotGlPixelRatio;
195198

196199
fonti.family = Array.isArray(tff) ? tff[i] : tff;
197200
}
198201
} else {
199202
// if both are single values, make render fast single-value
200-
optsOut.font = {size: tfs, family: tff};
203+
optsOut.font = {size: tfs * plotGlPixelRatio, family: tff};
201204
}
202205

203206
return optsOut;
@@ -283,7 +286,8 @@ function convertMarkerStyle(trace) {
283286
}
284287

285288
// prepare sizes
286-
var markerSizeFunc = makeBubbleSizeFn(trace);
289+
var sizeFactor = 1;
290+
var markerSizeFunc = makeBubbleSizeFn(trace, sizeFactor);
287291
var s;
288292

289293
if(multiSize || multiLineWidth) {
@@ -308,10 +312,10 @@ function convertMarkerStyle(trace) {
308312
// See https://github.com/plotly/plotly.js/pull/1781#discussion_r121820798
309313
if(multiLineWidth) {
310314
for(i = 0; i < count; i++) {
311-
borderSizes[i] = optsIn.line.width[i] / 2;
315+
borderSizes[i] = optsIn.line.width[i];
312316
}
313317
} else {
314-
s = optsIn.line.width / 2;
318+
s = optsIn.line.width;
315319
for(i = 0; i < count; i++) {
316320
borderSizes[i] = s;
317321
}
@@ -335,7 +339,7 @@ function convertMarkerSelection(trace, target) {
335339
if(target.marker && target.marker.symbol) {
336340
optsOut = convertMarkerStyle(Lib.extendFlat({}, optsIn, target.marker));
337341
} else if(target.marker) {
338-
if(target.marker.size) optsOut.size = target.marker.size / 2;
342+
if(target.marker.size) optsOut.size = target.marker.size;
339343
if(target.marker.color) optsOut.colors = target.marker.color;
340344
if(target.marker.opacity !== undefined) optsOut.opacity = target.marker.opacity;
341345
}
@@ -365,10 +369,10 @@ function convertTextSelection(gd, trace, target) {
365369
return optsOut;
366370
}
367371

368-
function convertErrorBarStyle(trace, target) {
372+
function convertErrorBarStyle(trace, target, plotGlPixelRatio) {
369373
var optsOut = {
370-
capSize: target.width * 2,
371-
lineWidth: target.thickness,
374+
capSize: target.width * 2 * plotGlPixelRatio,
375+
lineWidth: target.thickness * plotGlPixelRatio,
372376
color: target.color
373377
};
374378

0 commit comments

Comments
 (0)