@@ -322,7 +322,7 @@ ScatterRegl.calc = function calc(container, trace) {
322
322
}
323
323
324
324
// 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 ) ) ;
326
326
var msx , msy , xbounds = [ Infinity , - Infinity ] , ybounds = [ Infinity , - Infinity ] ;
327
327
var markerSizeFunc = makeBubbleSizeFn ( trace ) ;
328
328
@@ -355,6 +355,10 @@ ScatterRegl.calc = function calc(container, trace) {
355
355
borderSizes [ i ] = size ;
356
356
}
357
357
}
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 } ) ;
358
362
}
359
363
else {
360
364
scatterOptions . size = markerSizeFunc ( markerOpts && markerOpts . size || 10 ) ;
@@ -368,8 +372,25 @@ ScatterRegl.calc = function calc(container, trace) {
368
372
if ( ybounds [ 0 ] > yy ) ybounds [ 0 ] = yy ;
369
373
if ( ybounds [ 1 ] < yy ) ybounds [ 1 ] = yy ;
370
374
}
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
+ }
373
394
}
374
395
}
375
396
@@ -621,7 +642,7 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
621
642
}
622
643
623
644
// provide viewport and range
624
- var vpRange = cdata . map ( function ( cdscatter , i ) {
645
+ var vpRange = cdata . map ( function ( cdscatter ) {
625
646
if ( ! cdscatter || ! cdscatter [ 0 ] || ! cdscatter [ 0 ] . trace ) return ;
626
647
var cd = cdscatter [ 0 ] ;
627
648
var trace = cd . trace ;
@@ -640,7 +661,6 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
640
661
( height - vpSize . t ) - ( 1 - yaxis . domain [ 1 ] ) * vpSize . h
641
662
] ;
642
663
643
- // handle selection here
644
664
if ( dragmode === 'lasso' || dragmode === 'select' ) {
645
665
//precalculate px coords since we are not going to pan during select
646
666
var xpx = Array ( stash . count ) , ypx = Array ( stash . count ) ;
@@ -662,33 +682,6 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
662
682
}
663
683
}
664
684
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
-
692
685
return {
693
686
viewport : viewport ,
694
687
range : range
@@ -751,8 +744,8 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval) {
751
744
var min = MAXDIST , id , ptx , pty ;
752
745
753
746
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 ] ] ;
756
749
var dx = xa . c2p ( ptx ) - xpx , dy = ya . c2p ( pty ) - ypx ;
757
750
758
751
var dist = Math . sqrt ( dx * dx + dy * dy ) ;
@@ -768,8 +761,8 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval) {
768
761
769
762
// the closest data point
770
763
var di = {
771
- x : trace . x [ id ] ,
772
- y : trace . y [ id ]
764
+ x : x [ id ] ,
765
+ y : y [ id ]
773
766
} ;
774
767
775
768
// 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