Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f02f0ee

Browse files
committed
Fix axes expansion
1 parent ae6ebd3 commit f02f0ee

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/traces/scattergl/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var SYMBOL_SIZE = 20;
3434
var SYMBOL_STROKE = SYMBOL_SIZE / 20;
3535
var SYMBOL_SDF = {};
3636
var SYMBOL_SVG_CIRCLE = Drawing.symbolFuncs[0](SYMBOL_SIZE * 0.05);
37-
37+
var TOO_MANY_POINTS = 1e5;
3838

3939
var ScatterRegl = module.exports = extend({}, require('../scatter'));
4040

@@ -356,12 +356,12 @@ ScatterRegl.calc = function calc(container, trace) {
356356
}
357357
}
358358

359-
// FIXME: this slows down big number of points
360-
Axes.expand(xaxis, trace.x, { padded: true, ppad: sizes });
361-
Axes.expand(yaxis, trace.y, { padded: true, ppad: sizes });
359+
Axes.expand(xaxis, x, { padded: true, ppad: sizes });
360+
Axes.expand(yaxis, y, { padded: true, ppad: sizes });
362361
}
363362
else {
364-
scatterOptions.size = markerSizeFunc(markerOpts && markerOpts.size || 10);
363+
// console.log(x, xOptions, xa._min)
364+
var size = scatterOptions.size = markerSizeFunc(markerOpts && markerOpts.size || 10);
365365
scatterOptions.borderSizes = markerOpts.line.width * 0.5;
366366

367367
// axes bounds
@@ -373,17 +373,21 @@ ScatterRegl.calc = function calc(container, trace) {
373373
if(ybounds[1] < yy) ybounds[1] = yy;
374374
}
375375

376-
if (!xaxis.autorange) {
377-
// update axes fast
376+
// FIXME: is there a better way to separate expansion?
377+
if (count < TOO_MANY_POINTS) {
378+
Axes.expand(xaxis, x, { padded: true, ppad: size });
379+
Axes.expand(yaxis, y, { padded: true, ppad: size });
380+
}
381+
// update axes fast for big number of points
382+
else {
378383
var pad = scatterOptions.size;
379384
if(xaxis._min) {
380385
xaxis._min.push({ val: xbounds[0], pad: pad });
381386
}
382387
if(xaxis._max) {
383388
xaxis._max.push({ val: xbounds[1], pad: pad });
384389
}
385-
}
386-
if (!yaxis.autorange) {
390+
387391
if(yaxis._min) {
388392
yaxis._min.push({ val: ybounds[0], pad: pad });
389393
}

0 commit comments

Comments
 (0)