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

Skip to content

Commit ae6ebd3

Browse files
committed
Do not redefine autorange
1 parent 8b81ba1 commit ae6ebd3

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

src/traces/scattergl/index.js

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ ScatterRegl.calc = function calc(container, trace) {
322322
}
323323

324324
// prepare sizes and expand axes
325-
var multiSize = scatterOptions.multiSize = markerOpts && (Array.isArray(markerOpts.size) || Array.isArray(markerOpts.line.width));
325+
var multiSize = markerOpts && (Array.isArray(markerOpts.size) || Array.isArray(markerOpts.line.width));
326326
var msx, msy, xbounds = [Infinity, -Infinity], ybounds = [Infinity, -Infinity];
327327
var markerSizeFunc = makeBubbleSizeFn(trace);
328328

@@ -355,6 +355,10 @@ ScatterRegl.calc = function calc(container, trace) {
355355
borderSizes[i] = size;
356356
}
357357
}
358+
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 });
358362
}
359363
else {
360364
scatterOptions.size = markerSizeFunc(markerOpts && markerOpts.size || 10);
@@ -368,8 +372,25 @@ ScatterRegl.calc = function calc(container, trace) {
368372
if(ybounds[0] > yy) ybounds[0] = yy;
369373
if(ybounds[1] < yy) ybounds[1] = yy;
370374
}
371-
scatterOptions.xbounds = xbounds;
372-
scatterOptions.ybounds = ybounds;
375+
376+
if (!xaxis.autorange) {
377+
// update axes fast
378+
var pad = scatterOptions.size;
379+
if(xaxis._min) {
380+
xaxis._min.push({ val: xbounds[0], pad: pad });
381+
}
382+
if(xaxis._max) {
383+
xaxis._max.push({ val: xbounds[1], pad: pad });
384+
}
385+
}
386+
if (!yaxis.autorange) {
387+
if(yaxis._min) {
388+
yaxis._min.push({ val: ybounds[0], pad: pad });
389+
}
390+
if(yaxis._max) {
391+
yaxis._max.push({ val: ybounds[1], pad: pad });
392+
}
393+
}
373394
}
374395
}
375396

@@ -621,7 +642,7 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
621642
}
622643

623644
// provide viewport and range
624-
var vpRange = cdata.map(function(cdscatter, i) {
645+
var vpRange = cdata.map(function(cdscatter) {
625646
if(!cdscatter || !cdscatter[0] || !cdscatter[0].trace) return;
626647
var cd = cdscatter[0];
627648
var trace = cd.trace;
@@ -640,7 +661,6 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
640661
(height - vpSize.t) - (1 - yaxis.domain[1]) * vpSize.h
641662
];
642663

643-
// handle selection here
644664
if (dragmode === 'lasso' || dragmode === 'select') {
645665
//precalculate px coords since we are not going to pan during select
646666
var xpx = Array(stash.count), ypx = Array(stash.count);
@@ -662,33 +682,6 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
662682
}
663683
}
664684

665-
// axes expand does not trigger right at the calc stage, so we do it here
666-
if (scene.scatter2d) {
667-
var scatterOptions = scene.scatterOptions[i];
668-
if (scatterOptions.multiSize) {
669-
// FIXME: this slows down big number of points
670-
Axes.expand(xaxis, trace.x, { padded: true, ppad: scatterOptions.sizes });
671-
Axes.expand(yaxis, trace.y, { padded: true, ppad: scatterOptions.sizes });
672-
}
673-
// update axes fast
674-
else {
675-
var pad = scatterOptions.sizes;
676-
console.log(scatterOptions.xbounds)
677-
if(xaxis._min) {
678-
xaxis._min.push({ val: scatterOptions.xbounds[0], pad: pad });
679-
}
680-
if(xaxis._max) {
681-
xaxis._max.push({ val: scatterOptions.xbounds[1], pad: pad });
682-
}
683-
if(yaxis._min) {
684-
yaxis._min.push({ val: scatterOptions.ybounds[0], pad: pad });
685-
}
686-
if(yaxis._max) {
687-
yaxis._max.push({ val: scatterOptions.ybounds[1], pad: pad });
688-
}
689-
}
690-
}
691-
692685
return {
693686
viewport: viewport,
694687
range: range
@@ -751,8 +744,8 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval) {
751744
var min = MAXDIST, id, ptx, pty;
752745

753746
for(var i = 0; i < ids.length; i++) {
754-
ptx = trace.x[ids[i]];
755-
pty = trace.y[ids[i]];
747+
ptx = x[ids[i]];
748+
pty = y[ids[i]];
756749
var dx = xa.c2p(ptx) - xpx, dy = ya.c2p(pty) - ypx;
757750

758751
var dist = Math.sqrt(dx * dx + dy * dy);
@@ -768,8 +761,8 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval) {
768761

769762
// the closest data point
770763
var di = {
771-
x: trace.x[id],
772-
y: trace.y[id]
764+
x: x[id],
765+
y: y[id]
773766
};
774767

775768
// that is single-item arrays_to_calcdata excerpt, since we are doing it for a single point and we don't have to do it beforehead for 1e6 points

0 commit comments

Comments
 (0)