@@ -19,16 +19,21 @@ var Color = require('../color');
19
19
var Titles = require ( '../titles' ) ;
20
20
21
21
var Cartesian = require ( '../../plots/cartesian' ) ;
22
- var Axes = require ( '../../plots/cartesian/axes ' ) ;
22
+ var axisIDs = require ( '../../plots/cartesian/axis_ids ' ) ;
23
23
24
24
var dragElement = require ( '../dragelement' ) ;
25
25
var setCursor = require ( '../../lib/setcursor' ) ;
26
26
27
27
var constants = require ( './constants' ) ;
28
28
29
29
module . exports = function ( gd ) {
30
- var fullLayout = gd . _fullLayout ,
31
- rangeSliderData = makeRangeSliderData ( fullLayout ) ;
30
+ var fullLayout = gd . _fullLayout ;
31
+ var rangeSliderData = fullLayout . _rangeSliderData ;
32
+ for ( var i = 0 ; i < rangeSliderData . length ; i ++ ) {
33
+ var opts = rangeSliderData [ i ] [ constants . name ] ;
34
+ // fullLayout._uid may not exist when we call makeData
35
+ opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
36
+ }
32
37
33
38
/*
34
39
* <g container />
@@ -55,10 +60,6 @@ module.exports = function(gd) {
55
60
. selectAll ( 'g.' + constants . containerClassName )
56
61
. data ( rangeSliderData , keyFunction ) ;
57
62
58
- rangeSliders . enter ( ) . append ( 'g' )
59
- . classed ( constants . containerClassName , true )
60
- . attr ( 'pointer-events' , 'all' ) ;
61
-
62
63
// remove exiting sliders and their corresponding clip paths
63
64
rangeSliders . exit ( ) . each ( function ( axisOpts ) {
64
65
var opts = axisOpts [ constants . name ] ;
@@ -68,12 +69,16 @@ module.exports = function(gd) {
68
69
// return early if no range slider is visible
69
70
if ( rangeSliderData . length === 0 ) return ;
70
71
72
+ rangeSliders . enter ( ) . append ( 'g' )
73
+ . classed ( constants . containerClassName , true )
74
+ . attr ( 'pointer-events' , 'all' ) ;
75
+
71
76
// for all present range sliders
72
77
rangeSliders . each ( function ( axisOpts ) {
73
- var rangeSlider = d3 . select ( this ) ,
74
- opts = axisOpts [ constants . name ] ,
75
- oppAxisOpts = fullLayout [ Axes . id2name ( axisOpts . anchor ) ] ,
76
- oppAxisRangeOpts = opts [ Axes . id2name ( axisOpts . anchor ) ] ;
78
+ var rangeSlider = d3 . select ( this ) ;
79
+ var opts = axisOpts [ constants . name ] ;
80
+ var oppAxisOpts = fullLayout [ axisIDs . id2name ( axisOpts . anchor ) ] ;
81
+ var oppAxisRangeOpts = opts [ axisIDs . id2name ( axisOpts . anchor ) ] ;
77
82
78
83
// update range
79
84
// Expand slider range to the axis range
@@ -97,19 +102,9 @@ module.exports = function(gd) {
97
102
var domain = axisOpts . domain ;
98
103
var tickHeight = ( axisOpts . _boundingBox || { } ) . height || 0 ;
99
104
100
- var oppBottom = Infinity ;
101
- var subplotData = Axes . getSubplots ( gd , axisOpts ) ;
102
- for ( var i = 0 ; i < subplotData . length ; i ++ ) {
103
- var oppAxis = Axes . getFromId ( gd , subplotData [ i ] . substr ( subplotData [ i ] . indexOf ( 'y' ) ) ) ;
104
- oppBottom = Math . min ( oppBottom , oppAxis . domain [ 0 ] ) ;
105
- }
106
-
107
- opts . _id = constants . name + axisOpts . _id ;
108
- opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
105
+ var oppBottom = opts . _oppBottom ;
109
106
110
107
opts . _width = graphSize . w * ( domain [ 1 ] - domain [ 0 ] ) ;
111
- opts . _height = ( fullLayout . height - margin . b - margin . t ) * opts . thickness ;
112
- opts . _offsetShift = Math . floor ( opts . borderwidth / 2 ) ;
113
108
114
109
var x = Math . round ( margin . l + ( graphSize . w * domain [ 0 ] ) ) ;
115
110
@@ -177,36 +172,9 @@ module.exports = function(gd) {
177
172
}
178
173
} ) ;
179
174
}
180
-
181
- // update margins
182
- Plots . autoMargin ( gd , opts . _id , {
183
- x : domain [ 0 ] ,
184
- y : oppBottom ,
185
- l : 0 ,
186
- r : 0 ,
187
- t : 0 ,
188
- b : opts . _height + margin . b + tickHeight ,
189
- pad : constants . extraPad + opts . _offsetShift * 2
190
- } ) ;
191
175
} ) ;
192
176
} ;
193
177
194
- function makeRangeSliderData ( fullLayout ) {
195
- var axes = Axes . list ( { _fullLayout : fullLayout } , 'x' , true ) ,
196
- name = constants . name ,
197
- out = [ ] ;
198
-
199
- if ( fullLayout . _has ( 'gl2d' ) ) return out ;
200
-
201
- for ( var i = 0 ; i < axes . length ; i ++ ) {
202
- var ax = axes [ i ] ;
203
-
204
- if ( ax [ name ] && ax [ name ] . visible ) out . push ( ax ) ;
205
- }
206
-
207
- return out ;
208
- }
209
-
210
178
function setupDragElement ( rangeSlider , gd , axisOpts , opts ) {
211
179
var slideBox = rangeSlider . select ( 'rect.' + constants . slideBoxClassName ) . node ( ) ,
212
180
grabAreaMin = rangeSlider . select ( 'rect.' + constants . grabAreaMinClassName ) . node ( ) ,
@@ -393,11 +361,10 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) {
393
361
}
394
362
395
363
function drawRangePlot ( rangeSlider , gd , axisOpts , opts ) {
396
- var subplotData = Axes . getSubplots ( gd , axisOpts ) ,
397
- calcData = gd . calcdata ;
364
+ var calcData = gd . calcdata ;
398
365
399
366
var rangePlots = rangeSlider . selectAll ( 'g.' + constants . rangePlotClassName )
400
- . data ( subplotData , Lib . identity ) ;
367
+ . data ( axisOpts . _subplotsWith , Lib . identity ) ;
401
368
402
369
rangePlots . enter ( ) . append ( 'g' )
403
370
. attr ( 'class' , function ( id ) { return constants . rangePlotClassName + ' ' + id ; } )
@@ -413,7 +380,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
413
380
var plotgroup = d3 . select ( this ) ,
414
381
isMainPlot = ( i === 0 ) ;
415
382
416
- var oppAxisOpts = Axes . getFromId ( gd , id , 'y' ) ,
383
+ var oppAxisOpts = axisIDs . getFromId ( gd , id , 'y' ) ,
417
384
oppAxisName = oppAxisOpts . _name ,
418
385
oppAxisRangeOpts = opts [ oppAxisName ] ;
419
386
@@ -445,6 +412,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
445
412
var xa = mockFigure . _fullLayout . xaxis ;
446
413
var ya = mockFigure . _fullLayout [ oppAxisName ] ;
447
414
415
+ xa . clearCalc ( ) ;
416
+ xa . setScale ( ) ;
417
+ ya . clearCalc ( ) ;
418
+ ya . setScale ( ) ;
419
+
448
420
var plotinfo = {
449
421
id : id ,
450
422
plotgroup : plotgroup ,
0 commit comments