@@ -195,7 +195,7 @@ fx.init = function(gd) {
195
195
196
196
// hover labels for multiple horizontal bars get tilted by some angle,
197
197
// then need to be offset differently if they overlap
198
- var YANGLE = 60 ,
198
+ var YANGLE = constants . YANGLE ,
199
199
YA_RADIANS = Math . PI * YANGLE / 180 ,
200
200
201
201
// expansion of projected height
@@ -228,13 +228,10 @@ function quadrature(dx, dy) {
228
228
}
229
229
230
230
// size and display constants for hover text
231
- var HOVERARROWSIZE = 6 , // pixel size of hover arrows
232
- HOVERTEXTPAD = 3 , // pixels padding around text
233
- HOVERFONTSIZE = 13 ,
234
- HOVERFONT = 'Arial, sans-serif' ;
235
-
236
- // max pixels away from mouse to allow a point to highlight
237
- fx . MAXDIST = 20 ;
231
+ var HOVERARROWSIZE = constants . HOVERARROWSIZE ,
232
+ HOVERTEXTPAD = constants . HOVERTEXTPAD ,
233
+ HOVERFONTSIZE = constants . HOVERFONTSIZE ,
234
+ HOVERFONT = constants . HOVERFONT ;
238
235
239
236
// fx.hover: highlight data on hover
240
237
// evt can be a mousemove event, or an object with data about what points
@@ -262,8 +259,6 @@ fx.MAXDIST = 20;
262
259
// The actual rendering is done by private functions
263
260
// hover() and unhover().
264
261
265
- var HOVERMINTIME = 100 ; // minimum time between hover calls
266
-
267
262
fx . hover = function ( gd , evt , subplot ) {
268
263
if ( typeof gd === 'string' ) gd = document . getElementById ( gd ) ;
269
264
if ( gd . _lastHoverTime === undefined ) gd . _lastHoverTime = 0 ;
@@ -275,7 +270,7 @@ fx.hover = function (gd, evt, subplot) {
275
270
}
276
271
// Is it more than 100ms since the last update? If so, force
277
272
// an update now (synchronously) and exit
278
- if ( Date . now ( ) > gd . _lastHoverTime + HOVERMINTIME ) {
273
+ if ( Date . now ( ) > gd . _lastHoverTime + constants . HOVERMINTIME ) {
279
274
hover ( gd , evt , subplot ) ;
280
275
gd . _lastHoverTime = Date . now ( ) ;
281
276
return ;
@@ -285,7 +280,7 @@ fx.hover = function (gd, evt, subplot) {
285
280
hover ( gd , evt , subplot ) ;
286
281
gd . _lastHoverTime = Date . now ( ) ;
287
282
gd . _hoverTimer = undefined ;
288
- } , HOVERMINTIME ) ;
283
+ } , constants . HOVERMINTIME ) ;
289
284
} ;
290
285
291
286
fx . unhover = function ( gd , evt , subplot ) {
@@ -442,7 +437,7 @@ function hover(gd, evt, subplot){
442
437
name : ( gd . data . length > 1 || trace . hoverinfo . indexOf ( 'name' ) !== - 1 ) ? trace . name : undefined ,
443
438
// point properties - override all of these
444
439
index : false , // point index in trace - only used by plotly.js hoverdata consumers
445
- distance : Math . min ( distance , fx . MAXDIST ) , // pixel distance or pseudo-distance
440
+ distance : Math . min ( distance , constants . MAXDIST ) , // pixel distance or pseudo-distance
446
441
color : Plotly . Color . defaultLine , // trace color
447
442
x0 : undefined ,
448
443
x1 : undefined ,
@@ -762,7 +757,7 @@ function createHoverText(hoverData, opts) {
762
757
// show the common label, if any, on the axis
763
758
// never show a common label in array mode,
764
759
// even if sometimes there could be one
765
- var showCommonLabel = c0 . distance <= fx . MAXDIST &&
760
+ var showCommonLabel = c0 . distance <= constants . MAXDIST &&
766
761
( hovermode === 'x' || hovermode === 'y' ) ;
767
762
768
763
// all hover traces hoverinfo must contain the hovermode
@@ -1312,6 +1307,8 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1312
1307
ya = [ plotinfo . y ( ) ] ,
1313
1308
pw = xa [ 0 ] . _length ,
1314
1309
ph = ya [ 0 ] . _length ,
1310
+ MINDRAG = constants . MINDRAG ,
1311
+ MINZOOM = constants . MINZOOM ,
1315
1312
i ,
1316
1313
subplotXa ,
1317
1314
subplotYa ;
@@ -1449,7 +1446,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1449
1446
y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ,
1450
1447
dx = Math . abs ( x1 - x0 ) ,
1451
1448
dy = Math . abs ( y1 - y0 ) ,
1452
- clen = Math . floor ( Math . min ( dy , dx , constants . MINZOOM ) / 2 ) ;
1449
+ clen = Math . floor ( Math . min ( dy , dx , MINZOOM ) / 2 ) ;
1453
1450
1454
1451
box . l = Math . min ( x0 , x1 ) ;
1455
1452
box . r = Math . max ( x0 , x1 ) ;
@@ -1458,8 +1455,8 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1458
1455
1459
1456
// look for small drags in one direction or the other,
1460
1457
// and only drag the other axis
1461
- if ( ! yActive || dy < Math . min ( Math . max ( dx * 0.6 , constants . MINDRAG ) , constants . MINZOOM ) ) {
1462
- if ( dx < constants . MINDRAG ) {
1458
+ if ( ! yActive || dy < Math . min ( Math . max ( dx * 0.6 , MINDRAG ) , MINZOOM ) ) {
1459
+ if ( dx < MINDRAG ) {
1463
1460
zoomMode = '' ;
1464
1461
box . r = box . l ;
1465
1462
box . t = box . b ;
@@ -1470,21 +1467,21 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1470
1467
box . b = ph ;
1471
1468
zoomMode = 'x' ;
1472
1469
corners . attr ( 'd' ,
1473
- 'M' + ( box . l - 0.5 ) + ',' + ( y0 - constants . MINZOOM - 0.5 ) +
1474
- 'h-3v' + ( 2 * constants . MINZOOM + 1 ) + 'h3ZM' +
1475
- ( box . r + 0.5 ) + ',' + ( y0 - constants . MINZOOM - 0.5 ) +
1476
- 'h3v' + ( 2 * constants . MINZOOM + 1 ) + 'h-3Z' ) ;
1470
+ 'M' + ( box . l - 0.5 ) + ',' + ( y0 - MINZOOM - 0.5 ) +
1471
+ 'h-3v' + ( 2 * MINZOOM + 1 ) + 'h3ZM' +
1472
+ ( box . r + 0.5 ) + ',' + ( y0 - MINZOOM - 0.5 ) +
1473
+ 'h3v' + ( 2 * MINZOOM + 1 ) + 'h-3Z' ) ;
1477
1474
}
1478
1475
}
1479
- else if ( ! xActive || dx < Math . min ( dy * 0.6 , constants . MINZOOM ) ) {
1476
+ else if ( ! xActive || dx < Math . min ( dy * 0.6 , MINZOOM ) ) {
1480
1477
box . l = 0 ;
1481
1478
box . r = pw ;
1482
1479
zoomMode = 'y' ;
1483
1480
corners . attr ( 'd' ,
1484
- 'M' + ( x0 - constants . MINZOOM - 0.5 ) + ',' + ( box . t - 0.5 ) +
1485
- 'v-3h' + ( 2 * constants . MINZOOM + 1 ) + 'v3ZM' +
1486
- ( x0 - constants . MINZOOM - 0.5 ) + ',' + ( box . b + 0.5 ) +
1487
- 'v3h' + ( 2 * constants . MINZOOM + 1 ) + 'v-3Z' ) ;
1481
+ 'M' + ( x0 - MINZOOM - 0.5 ) + ',' + ( box . t - 0.5 ) +
1482
+ 'v-3h' + ( 2 * MINZOOM + 1 ) + 'v3ZM' +
1483
+ ( x0 - MINZOOM - 0.5 ) + ',' + ( box . b + 0.5 ) +
1484
+ 'v3h' + ( 2 * MINZOOM + 1 ) + 'v-3Z' ) ;
1488
1485
}
1489
1486
else {
1490
1487
zoomMode = 'xy' ;
@@ -1536,7 +1533,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1536
1533
}
1537
1534
1538
1535
function zoomDone ( dragged , numClicks ) {
1539
- if ( Math . min ( box . h , box . w ) < constants . MINDRAG * 2 ) {
1536
+ if ( Math . min ( box . h , box . w ) < MINDRAG * 2 ) {
1540
1537
if ( numClicks === 2 ) doubleClick ( ) ;
1541
1538
else pauseForDrag ( gd ) ;
1542
1539
@@ -1973,6 +1970,7 @@ fx.dragCursors = function(x,y,xanchor,yanchor){
1973
1970
fx . dragElement = function ( options ) {
1974
1971
var gd = Plotly . Lib . getPlotDiv ( options . element ) || { } ,
1975
1972
numClicks = 1 ,
1973
+ DBLCLICKDELAY = constants . DBLCLICKDELAY ,
1976
1974
startX ,
1977
1975
startY ,
1978
1976
newMouseDownTime ,
@@ -1996,7 +1994,7 @@ fx.dragElement = function(options) {
1996
1994
initialTarget = e . target ;
1997
1995
1998
1996
newMouseDownTime = ( new Date ( ) ) . getTime ( ) ;
1999
- if ( newMouseDownTime - gd . _mouseDownTime < constants . DBLCLICKDELAY ) {
1997
+ if ( newMouseDownTime - gd . _mouseDownTime < DBLCLICKDELAY ) {
2000
1998
// in a click train
2001
1999
numClicks += 1 ;
2002
2000
}
@@ -2047,7 +2045,7 @@ fx.dragElement = function(options) {
2047
2045
2048
2046
// don't count as a dblClick unless the mouseUp is also within
2049
2047
// the dblclick delay
2050
- if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > constants . DBLCLICKDELAY ) {
2048
+ if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > DBLCLICKDELAY ) {
2051
2049
numClicks = Math . max ( numClicks - 1 , 1 ) ;
2052
2050
}
2053
2051
@@ -2105,7 +2103,7 @@ fx.setCursor = function(el3,csr) {
2105
2103
// count one edge as in, so that over continuous ranges you never get a gap
2106
2104
fx . inbox = function ( v0 , v1 ) {
2107
2105
if ( v0 * v1 < 0 || v0 === 0 ) {
2108
- return fx . MAXDIST * ( 0.6 - 0.3 / Math . max ( 3 , Math . abs ( v0 - v1 ) ) ) ;
2106
+ return constants . MAXDIST * ( 0.6 - 0.3 / Math . max ( 3 , Math . abs ( v0 - v1 ) ) ) ;
2109
2107
}
2110
2108
return Infinity ;
2111
2109
} ;
0 commit comments