@@ -1573,7 +1573,7 @@ describe('ModeBar', function() {
15731573 . then ( done , done . fail ) ;
15741574 } ) ;
15751575
1576- it ( 'add predefined shape drawing and hover buttons via layout.modebar.add and template ' , function ( done ) {
1576+ it ( 'add predefined shape drawing and hover buttons via layout.modebar.add' , function ( done ) {
15771577 function countButtons ( ) {
15781578 var modeBarEl = gd . _fullLayout . _modeBar . element ;
15791579 return d3Select ( modeBarEl ) . selectAll ( 'a.modebar-btn' ) . size ( ) ;
@@ -1591,7 +1591,7 @@ describe('ModeBar', function() {
15911591 'drawcircle' ,
15921592 'drawrect' ,
15931593 'eraseshape'
1594- ] . join ( '+' ) ) ;
1594+ ] ) ;
15951595 } )
15961596 . then ( function ( ) {
15971597 expect ( countButtons ( ) ) . toBe ( initial + 6 ) ;
@@ -1605,7 +1605,7 @@ describe('ModeBar', function() {
16051605 'hovercompare' ,
16061606 'hoverclosest' ,
16071607 'togglespikelines'
1608- ] . join ( '+' ) ) ;
1608+ ] ) ;
16091609 } )
16101610 . then ( function ( ) {
16111611 expect ( countButtons ( ) ) . toBe ( initial + 3 ) ;
@@ -1618,7 +1618,7 @@ describe('ModeBar', function() {
16181618 return Plotly . relayout ( gd , 'modebar.add' , [
16191619 'v1hovermode' ,
16201620 'togglespikelines'
1621- ] . join ( '+' ) ) ;
1621+ ] ) ;
16221622 } )
16231623 . then ( function ( ) {
16241624 expect ( countButtons ( ) ) . toBe ( initial + 3 ) ;
@@ -1629,18 +1629,16 @@ describe('ModeBar', function() {
16291629 'togglehover' ,
16301630 'hovercompare' ,
16311631 'hoverclosest' ,
1632- 'eraseshape' ,
1633- 'eraseshape' ,
16341632 'eraseshape'
1635- ] . join ( '+' ) ) ;
1633+ ] ) ;
16361634 } )
16371635 . then ( function ( ) {
16381636 expect ( countButtons ( ) ) . toBe ( initial + 4 , 'skip duplicates' ) ;
16391637
16401638 return Plotly . relayout ( gd , 'modebar.add' , [
16411639 'drawline' ,
16421640 'invalid'
1643- ] . join ( '+' ) ) ;
1641+ ] ) ;
16441642 } )
16451643 . then ( function ( ) {
16461644 expect ( countButtons ( ) ) . toBe ( initial + 1 , 'skip invalid' ) ;
@@ -1649,11 +1647,6 @@ describe('ModeBar', function() {
16491647 } )
16501648 . then ( function ( ) {
16511649 expect ( countButtons ( ) ) . toBe ( initial ) ;
1652-
1653- return Plotly . relayout ( gd , 'template.layout.modebar.add' , 'v1hovermode' ) ;
1654- } )
1655- . then ( function ( ) {
1656- expect ( countButtons ( ) ) . toBe ( initial + 2 , 'via template' ) ;
16571650 } )
16581651 . then ( done , done . fail ) ;
16591652 } ) ;
@@ -1679,7 +1672,7 @@ describe('ModeBar', function() {
16791672 'autoscale' ,
16801673 'resetscale' ,
16811674 'toimage' ,
1682- ] . join ( '+' ) ) ;
1675+ ] ) ;
16831676 } )
16841677 . then ( function ( ) {
16851678 expect ( countButtons ( ) ) . toBe ( initial - 9 ) ;
@@ -1699,30 +1692,64 @@ describe('ModeBar', function() {
16991692 'autoScale2d' ,
17001693 'resetScale2d' ,
17011694 'toImage' ,
1702- ] . join ( '+' ) ) ;
1695+ ] ) ;
17031696 } )
17041697 . then ( function ( ) {
17051698 expect ( countButtons ( ) ) . toBe ( initial - 9 ) ;
1699+ } )
1700+ . then ( done , done . fail ) ;
1701+ } ) ;
17061702
1707- return Plotly . relayout ( gd , 'modebar.remove' , '' ) ;
1703+ it ( 'remove buttons using template' , function ( done ) {
1704+ function countButtons ( ) {
1705+ var modeBarEl = gd . _fullLayout . _modeBar . element ;
1706+ return d3Select ( modeBarEl ) . selectAll ( 'a.modebar-btn' ) . size ( ) ;
1707+ }
1708+
1709+ var initial = 10 ;
1710+ Plotly . newPlot ( gd , [ { y : [ 1 , 2 ] } ] , {
1711+ template : {
1712+ layout : {
1713+ modebar : {
1714+ remove : [
1715+ 'zoom' ,
1716+ 'zoomin' ,
1717+ 'zoomout' ,
1718+ 'pan' ,
1719+ 'select' ,
1720+ 'lasso' ,
1721+ 'autoscale' ,
1722+ 'resetscale' ,
1723+ 'toimage' ,
1724+ ]
1725+ }
1726+ }
1727+ }
17081728 } )
17091729 . then ( function ( ) {
1710- expect ( countButtons ( ) ) . toBe ( initial ) ;
1730+ expect ( countButtons ( ) ) . toBe ( initial - 9 ) ;
1731+ } )
1732+ . then ( done , done . fail ) ;
1733+ } ) ;
17111734
1712- return Plotly . relayout ( gd , 'template.layout.modebar.remove' , [
1713- 'zoom' ,
1714- 'zoomin' ,
1715- 'zoomout' ,
1716- 'pan' ,
1717- 'select' ,
1718- 'lasso' ,
1719- 'autoscale' ,
1720- 'resetscale' ,
1721- 'toimage' ,
1722- ] . join ( '+' ) ) ;
1735+ it ( 'add buttons using template' , function ( done ) {
1736+ function countButtons ( ) {
1737+ var modeBarEl = gd . _fullLayout . _modeBar . element ;
1738+ return d3Select ( modeBarEl ) . selectAll ( 'a.modebar-btn' ) . size ( ) ;
1739+ }
1740+
1741+ var initial = 10 ;
1742+ Plotly . newPlot ( gd , [ { y : [ 1 , 2 ] } ] , {
1743+ template : {
1744+ layout : {
1745+ modebar : {
1746+ add : 'drawcircle'
1747+ }
1748+ }
1749+ }
17231750 } )
17241751 . then ( function ( ) {
1725- expect ( countButtons ( ) ) . toBe ( initial - 9 ) ;
1752+ expect ( countButtons ( ) ) . toBe ( initial + 1 ) ;
17261753 } )
17271754 . then ( done , done . fail ) ;
17281755 } ) ;
0 commit comments