@@ -126,7 +126,6 @@ exports.finalizeSubplots = function(layoutIn, layoutOut) {
126
126
*/
127
127
exports . plot = function ( gd , traces , transitionOpts , makeOnCompleteCallback ) {
128
128
var fullLayout = gd . _fullLayout ;
129
- var subplots = fullLayout . _subplots . cartesian ;
130
129
var calcdata = gd . calcdata ;
131
130
var i ;
132
131
@@ -141,55 +140,75 @@ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
141
140
for ( i = 0 ; i < calcdata . length ; i ++ ) traces . push ( i ) ;
142
141
}
143
142
144
- // For each subplot
145
- for ( i = 0 ; i < subplots . length ; i ++ ) {
146
- var subplot = subplots [ i ] ;
147
- var subplotInfo = fullLayout . _plots [ subplot ] ;
148
-
149
- // Get all calcdata (traces) for this subplot:
150
- var cdSubplot = [ ] ;
151
- var pcd ;
152
-
153
- // For each trace
154
- for ( var j = 0 ; j < calcdata . length ; j ++ ) {
155
- var cd = calcdata [ j ] ;
156
- var trace = cd [ 0 ] . trace ;
157
-
158
- // Skip trace if whitelist provided and it's not whitelisted:
159
- // if (Array.isArray(traces) && traces.indexOf(i) === -1) continue;
160
- if ( trace . xaxis + trace . yaxis === subplot ) {
161
- // XXX: Should trace carpet dependencies. Only replot all carpet plots if the carpet
162
- // axis has actually changed:
163
- //
164
- // If this trace is specifically requested, add it to the list:
165
- if ( traces . indexOf ( trace . index ) !== - 1 || trace . carpet ) {
166
- // Okay, so example: traces 0, 1, and 2 have fill = tonext. You animate
167
- // traces 0 and 2. Trace 1 also needs to be updated, otherwise its fill
168
- // is outdated. So this retroactively adds the previous trace if the
169
- // traces are interdependent.
170
- if (
171
- pcd &&
172
- pcd [ 0 ] . trace . xaxis + pcd [ 0 ] . trace . yaxis === subplot &&
173
- [ 'tonextx' , 'tonexty' , 'tonext' ] . indexOf ( trace . fill ) !== - 1 &&
174
- cdSubplot . indexOf ( pcd ) === - 1
175
- ) {
176
- cdSubplot . push ( pcd ) ;
143
+ var trace ;
144
+ var subplot ;
145
+ var subplotZindexGroups = { } ;
146
+ for ( var t = 0 ; t < calcdata . length ; t ++ ) {
147
+ trace = calcdata [ t ] [ 0 ] . trace ;
148
+ var zi = trace . zindex || 0 ;
149
+ subplot = trace . xaxis + trace . yaxis ;
150
+ if ( ! subplotZindexGroups [ zi ] ) subplotZindexGroups [ zi ] = { } ;
151
+ if ( ! subplotZindexGroups [ zi ] [ subplot ] ) subplotZindexGroups [ zi ] [ subplot ] = [ ] ;
152
+ subplotZindexGroups [ zi ] [ subplot ] . push ( calcdata [ t ] ) ;
153
+ }
154
+ var zindices = Object . keys ( subplotZindexGroups )
155
+ . map ( Number )
156
+ . sort ( Lib . sorterAsc ) ;
157
+
158
+ var subplots ;
159
+ var zindex ;
160
+ var subplotLayerData = { } ;
161
+ for ( i = 0 ; i < zindices . length ; i ++ ) {
162
+ zindex = zindices [ i ] ;
163
+ subplots = Object . keys ( subplotZindexGroups [ zindex ] ) ;
164
+
165
+ // For each subplot
166
+ for ( var j = 0 ; j < subplots . length ; j ++ ) {
167
+ subplot = subplots [ j ] ;
168
+ var subplotInfo = fullLayout . _plots [ subplot ] ;
169
+
170
+ // Get all calcdata (traces) for this subplot:
171
+ var cdSubplot = [ ] ;
172
+ var pcd ;
173
+ // For each trace
174
+ for ( var k = 0 ; k < subplotZindexGroups [ zindex ] [ subplot ] . length ; k ++ ) {
175
+ var cd = subplotZindexGroups [ zindex ] [ subplot ] [ k ] ;
176
+ trace = cd [ 0 ] . trace ;
177
+ // Skip trace if whitelist provided and it's not whitelisted:
178
+ // if (Array.isArray(traces) && traces.indexOf(i) === -1) continue;
179
+ if ( trace . xaxis + trace . yaxis === subplot ) {
180
+ // XXX: Should trace carpet dependencies. Only replot all carpet plots if the carpet
181
+ // axis has actually changed:
182
+ //
183
+ // If this trace is specifically requested, add it to the list:
184
+ if ( traces . indexOf ( trace . index ) !== - 1 || trace . carpet ) {
185
+ // Okay, so example: traces 0, 1, and 2 have fill = tonext. You animate
186
+ // traces 0 and 2. Trace 1 also needs to be updated, otherwise its fill
187
+ // is outdated. So this retroactively adds the previous trace if the
188
+ // traces are interdependent.
189
+ if (
190
+ pcd &&
191
+ pcd [ 0 ] . trace . xaxis + pcd [ 0 ] . trace . yaxis === subplot &&
192
+ [ 'tonextx' , 'tonexty' , 'tonext' ] . indexOf ( trace . fill ) !== - 1 &&
193
+ cdSubplot . indexOf ( pcd ) === - 1
194
+ ) {
195
+ cdSubplot . push ( pcd ) ;
196
+ }
197
+ cdSubplot . push ( cd ) ;
177
198
}
178
199
179
- cdSubplot . push ( cd ) ;
200
+ // Track the previous trace on this subplot for the retroactive-add step
201
+ // above:
202
+ pcd = cd ;
180
203
}
181
-
182
- // Track the previous trace on this subplot for the retroactive-add step
183
- // above:
184
- pcd = cd ;
185
204
}
205
+ if ( ! subplotLayerData [ subplot ] ) subplotLayerData [ subplot ] = [ ] ;
206
+ subplotLayerData [ subplot ] = plotOne ( gd , subplotInfo , cdSubplot , transitionOpts , makeOnCompleteCallback , subplotLayerData [ subplot ] ) ;
186
207
}
187
- // Plot the traces for this subplot
188
- plotOne ( gd , subplotInfo , cdSubplot , transitionOpts , makeOnCompleteCallback ) ;
189
208
}
190
209
} ;
191
210
192
- function plotOne ( gd , plotinfo , cdSubplot , transitionOpts , makeOnCompleteCallback ) {
211
+ function plotOne ( gd , plotinfo , cdSubplot , transitionOpts , makeOnCompleteCallback , layerData ) {
193
212
var traceLayerClasses = constants . traceLayerClasses ;
194
213
var fullLayout = gd . _fullLayout ;
195
214
var modules = fullLayout . _modules ;
@@ -205,7 +224,6 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
205
224
traceZindexGroups [ zi ] . push ( cdSubplot [ t ] ) ;
206
225
}
207
226
208
- var layerData = [ ] ;
209
227
var zoomScaleQueryParts = [ ] ;
210
228
211
229
// Plot each zindex group in ascending order
@@ -221,7 +239,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
221
239
var categories = Registry . modules [ name ] . categories ;
222
240
223
241
if ( categories . svg ) {
224
- var className = ( _module . layerName || name + 'layer' ) + ( zindex ? '- ' + z : '' ) ;
242
+ var className = ( _module . layerName || name + 'layer' ) + '_ ' + zindex ;
225
243
var plotMethod = _module . plot ;
226
244
227
245
// plot all visible traces of this type on this subplot at once
@@ -234,7 +252,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
234
252
if ( cdModule . length ) {
235
253
layerData . push ( {
236
254
i : traceLayerClasses . indexOf ( className ) ,
237
- zindex : z ,
255
+ zindex : zindex ,
238
256
className : className ,
239
257
plotMethod : plotMethod ,
240
258
cdModule : cdModule
@@ -301,6 +319,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
301
319
plotinfo . zoomScaleTxt = traces . selectAll ( '.textpoint' ) ;
302
320
}
303
321
}
322
+ return layerData ;
304
323
}
305
324
306
325
exports . clean = function ( newFullData , newFullLayout , oldFullData , oldFullLayout ) {
@@ -372,15 +391,16 @@ exports.drawFramework = function(gd) {
372
391
373
392
var subplotLayers = fullLayout . _cartesianlayer . selectAll ( '.subplot' )
374
393
. data ( subplotData , String ) ;
375
-
394
+
376
395
subplotLayers . enter ( ) . append ( 'g' )
377
396
. attr ( 'class' , function ( d ) { return 'subplot ' + d [ 0 ] ; } ) ;
378
397
379
- subplotLayers . order ( ) ;
380
-
381
- subplotLayers . exit ( )
382
- . call ( purgeSubplotLayers , fullLayout ) ;
398
+ //subplotLayers.order();
383
399
400
+ //subplotLayers.exit()
401
+ // .call(purgeSubplotLayers, fullLayout);
402
+ console . log ( "Subplotlayers" )
403
+ console . log ( subplotLayers )
384
404
subplotLayers . each ( function ( d ) {
385
405
var id = d [ 0 ] ;
386
406
var plotinfo = fullLayout . _plots [ id ] ;
@@ -411,29 +431,67 @@ function makeSubplotData(gd) {
411
431
var regulars = [ ] ;
412
432
var overlays = [ ] ;
413
433
414
- for ( i = 0 ; i < len ; i ++ ) {
415
- id = ids [ i ] ;
416
- plotinfo = fullLayout . _plots [ id ] ;
417
- xa = plotinfo . xaxis ;
418
- ya = plotinfo . yaxis ;
419
-
420
- var xa2 = xa . _mainAxis ;
421
- var ya2 = ya . _mainAxis ;
422
- var mainplot = xa2 . _id + ya2 . _id ;
423
- var mainplotinfo = fullLayout . _plots [ mainplot ] ;
424
- plotinfo . overlays = [ ] ;
434
+ var calcdata = gd . calcdata ;
425
435
426
- if ( mainplot !== id && mainplotinfo ) {
427
- plotinfo . mainplot = mainplot ;
428
- plotinfo . mainplotinfo = mainplotinfo ;
429
- overlays . push ( id ) ;
430
- } else {
431
- plotinfo . mainplot = undefined ;
432
- plotinfo . mainplotinfo = undefined ;
433
- regulars . push ( id ) ;
436
+ var trace ;
437
+ var subplot ;
438
+ var subplotZindexGroups = { } ;
439
+ for ( var t = 0 ; t < calcdata . length ; t ++ ) {
440
+ trace = calcdata [ t ] [ 0 ] . trace ;
441
+ var zi = trace . zindex || 0 ;
442
+ subplot = trace . xaxis + trace . yaxis ;
443
+ if ( ! subplotZindexGroups [ zi ] ) subplotZindexGroups [ zi ] = { } ;
444
+ if ( ! subplotZindexGroups [ zi ] [ subplot ] ) subplotZindexGroups [ zi ] [ subplot ] = [ ] ;
445
+ subplotZindexGroups [ zi ] [ subplot ] . push ( calcdata [ t ] ) ;
446
+ }
447
+ var zindices = Object . keys ( subplotZindexGroups )
448
+ . map ( Number )
449
+ . sort ( Lib . sorterAsc ) ;
450
+
451
+ console . log ( subplotZindexGroups )
452
+
453
+ for ( i = 0 ; i < zindices . length ; i ++ ) {
454
+ console . log ( i )
455
+ var zindex = subplotZindexGroups [ zindices [ i ] ] ;
456
+ console . log ( zindex )
457
+ console . log ( )
458
+ var ids = Object . keys ( zindex ) ;
459
+ for ( var j = 0 ; j < ids . length ; j ++ ) {
460
+ var id = ids [ j ] ;
461
+ plotinfo = fullLayout . _plots [ id ] ;
462
+ //xa = plotinfo.xaxis;
463
+ //ya = plotinfo.yaxis;
464
+
465
+ //var xa2 = xa._mainAxis;
466
+ //var ya2 = ya._mainAxis;
467
+ var mainplot = mainplot ? mainplot : id ; //xa2._id + ya2._id;
468
+ var mainplotinfo = fullLayout . _plots [ mainplot ] ;
469
+ plotinfo . overlays = [ ] ;
470
+
471
+ if ( i !== 0 ) { //if(mainplot !== id && mainplotinfo) {
472
+ console . log ( "hererere" )
473
+ plotinfo . mainplot = mainplot ;
474
+ plotinfo . mainplotinfo = mainplotinfo ;
475
+ overlays . push ( id ) ;
476
+ } else {
477
+ plotinfo . mainplot = undefined ;
478
+ plotinfo . mainplotinfo = undefined ;
479
+ regulars . push ( id ) ;
480
+ }
481
+ console . log ( "....." )
434
482
}
483
+
484
+ }
485
+ console . log ( plotinfo . mainplotinfo )
486
+ console . log ( "----" )
487
+ console . log ( regulars , overlays )
488
+ function onlyUnique ( value , index , array ) {
489
+ return array . indexOf ( value ) === index ;
435
490
}
436
491
492
+ regulars = regulars . filter ( onlyUnique ) ;
493
+ overlays = overlays . filter ( onlyUnique ) ;
494
+ console . log ( regulars , overlays )
437
495
// fill in list of overlaying subplots in 'main plot'
438
496
for ( i = 0 ; i < overlays . length ; i ++ ) {
439
497
id = overlays [ i ] ;
@@ -448,6 +506,7 @@ function makeSubplotData(gd) {
448
506
for ( i = 0 ; i < len ; i ++ ) {
449
507
id = subplotIds [ i ] ;
450
508
plotinfo = fullLayout . _plots [ id ] ;
509
+ console . log ( id , plotinfo )
451
510
xa = plotinfo . xaxis ;
452
511
ya = plotinfo . yaxis ;
453
512
@@ -528,8 +587,12 @@ function makeSubplotLayer(gd, plotinfo) {
528
587
plotinfo . minorGridlayer = mainplotinfo . minorGridlayer ;
529
588
plotinfo . gridlayer = mainplotinfo . gridlayer ;
530
589
plotinfo . zerolinelayer = mainplotinfo . zerolinelayer ;
531
-
590
+ console . log ( xId )
591
+ console . log ( mainplotinfo )
592
+ console . log ( mainplotinfo . overlinesBelow )
532
593
ensureSingle ( mainplotinfo . overlinesBelow , 'path' , xId ) ;
594
+ console . log ( yId )
595
+
533
596
ensureSingle ( mainplotinfo . overlinesBelow , 'path' , yId ) ;
534
597
ensureSingle ( mainplotinfo . overaxesBelow , 'g' , xId ) ;
535
598
ensureSingle ( mainplotinfo . overaxesBelow , 'g' , yId ) ;
@@ -571,6 +634,7 @@ function makeSubplotLayer(gd, plotinfo) {
571
634
plotinfo . ylines
572
635
. style ( 'fill' , 'none' )
573
636
. classed ( 'crisp' , true ) ;
637
+ console . log ( "ñññññ" )
574
638
}
575
639
576
640
function purgeSubplotLayers ( layers , fullLayout ) {
0 commit comments