@@ -26,6 +26,7 @@ var Polar = require('../plots/polar/legacy');
26
26
var Axes = require ( '../plots/cartesian/axes' ) ;
27
27
var Drawing = require ( '../components/drawing' ) ;
28
28
var Color = require ( '../components/color' ) ;
29
+ var connectColorbar = require ( '../components/colorbar/connect' ) ;
29
30
var initInteractions = require ( '../plots/cartesian/graph_interact' ) . initInteractions ;
30
31
var xmlnsNamespaces = require ( '../constants/xmlns_namespaces' ) ;
31
32
var svgTextUtils = require ( '../lib/svg_text_utils' ) ;
@@ -265,10 +266,11 @@ exports.plot = function(gd, data, layout, config) {
265
266
for ( i = 0 ; i < calcdata . length ; i ++ ) {
266
267
cd = calcdata [ i ] ;
267
268
trace = cd [ 0 ] . trace ;
268
- if ( trace . visible !== true || ! trace . _module . colorbar ) {
269
+ var colorbarOpts = trace . _module . colorbar ;
270
+ if ( trace . visible !== true || ! colorbarOpts ) {
269
271
Plots . autoMargin ( gd , 'cb' + trace . uid ) ;
270
272
}
271
- else trace . _module . colorbar ( gd , cd ) ;
273
+ else connectColorbar ( gd , cd , colorbarOpts ) ;
272
274
}
273
275
274
276
Plots . doAutoMargin ( gd ) ;
@@ -1448,6 +1450,11 @@ function _restyle(gd, aobj, traces) {
1448
1450
1449
1451
if ( newVal === undefined ) continue ;
1450
1452
1453
+ var finalPart = param . parts [ param . parts . length - 1 ] ;
1454
+ var prefix = ai . substr ( 0 , ai . length - finalPart . length - 1 ) ;
1455
+ var prefixDot = prefix ? prefix + '.' : '' ;
1456
+ var innerContFull = prefix ? Lib . nestedProperty ( contFull , prefix ) : contFull ;
1457
+
1451
1458
valObject = PlotSchema . getTraceValObject ( contFull , param . parts ) ;
1452
1459
1453
1460
if ( valObject && valObject . impliedEdits && newVal !== null ) {
@@ -1461,31 +1468,30 @@ function _restyle(gd, aobj, traces) {
1461
1468
// note that colorbar fractional sizing is based on the
1462
1469
// original plot size, before anything (like a colorbar)
1463
1470
// increases the margins
1464
- else if ( ai === 'colorbar.thicknessmode' && param . get ( ) !== newVal &&
1465
- [ 'fraction' , 'pixels' ] . indexOf ( newVal ) !== - 1 &&
1466
- contFull . colorbar ) {
1467
- var thicknorm =
1468
- [ 'top' , 'bottom' ] . indexOf ( contFull . colorbar . orient ) !== - 1 ?
1469
- ( fullLayout . height - fullLayout . margin . t - fullLayout . margin . b ) :
1470
- ( fullLayout . width - fullLayout . margin . l - fullLayout . margin . r ) ;
1471
- doextra ( 'colorbar.thickness' , contFull . colorbar . thickness *
1472
- ( newVal === 'fraction' ? 1 / thicknorm : thicknorm ) , i ) ;
1473
- }
1474
- else if ( ai === 'colorbar.lenmode' && param . get ( ) !== newVal &&
1475
- [ 'fraction' , 'pixels' ] . indexOf ( newVal ) !== - 1 &&
1476
- contFull . colorbar ) {
1477
- var lennorm =
1478
- [ 'top' , 'bottom' ] . indexOf ( contFull . colorbar . orient ) !== - 1 ?
1479
- ( fullLayout . width - fullLayout . margin . l - fullLayout . margin . r ) :
1480
- ( fullLayout . height - fullLayout . margin . t - fullLayout . margin . b ) ;
1481
- doextra ( 'colorbar.len' , contFull . colorbar . len *
1482
- ( newVal === 'fraction' ? 1 / lennorm : lennorm ) , i ) ;
1483
- }
1484
- else if ( ai === 'colorbar.tick0' || ai === 'colorbar.dtick' ) {
1485
- doextra ( 'colorbar.tickmode' , 'linear' , i ) ;
1471
+ else if ( ( finalPart === 'thicknessmode' || finalPart === 'lenmode' ) &&
1472
+ oldVal !== newVal &&
1473
+ ( newVal === 'fraction' || newVal === 'pixels' ) &&
1474
+ innerContFull
1475
+ ) {
1476
+ if ( finalPart === 'thicknessmode' ) {
1477
+ var thicknorm =
1478
+ [ 'top' , 'bottom' ] . indexOf ( innerContFull . orient ) !== - 1 ?
1479
+ ( fullLayout . height - fullLayout . margin . t - fullLayout . margin . b ) :
1480
+ ( fullLayout . width - fullLayout . margin . l - fullLayout . margin . r ) ;
1481
+ doextra ( prefixDot + 'thickness' , innerContFull . thickness *
1482
+ ( newVal === 'fraction' ? 1 / thicknorm : thicknorm ) , i ) ;
1483
+ }
1484
+ else {
1485
+ var lennorm =
1486
+ [ 'top' , 'bottom' ] . indexOf ( innerContFull . orient ) !== - 1 ?
1487
+ ( fullLayout . width - fullLayout . margin . l - fullLayout . margin . r ) :
1488
+ ( fullLayout . height - fullLayout . margin . t - fullLayout . margin . b ) ;
1489
+ doextra ( prefixDot + 'len' , innerContFull . len *
1490
+ ( newVal === 'fraction' ? 1 / lennorm : lennorm ) , i ) ;
1491
+ }
1486
1492
}
1487
1493
1488
- if ( ai === 'type' && ( newVal === 'pie' ) !== ( oldVal === 'pie' ) ) {
1494
+ else if ( ai === 'type' && ( newVal === 'pie' ) !== ( oldVal === 'pie' ) ) {
1489
1495
var labelsTo = 'x' ,
1490
1496
valuesTo = 'y' ;
1491
1497
if ( ( newVal === 'bar' || oldVal === 'bar' ) && cont . orientation === 'h' ) {
0 commit comments