@@ -52,6 +52,11 @@ proto.update = function(graphInfo, buttons) {
5252 }
5353 else this . element . className = 'modebar' ;
5454
55+ if ( context . modeBarStyle . orientation === 'v' ) {
56+ this . element . className += ' vertical' ;
57+ }
58+ this . element . style . backgroundColor = context . modeBarStyle . bgcolor ;
59+
5560 // if buttons or logo have changed, redraw modebar interior
5661 var needsNewButtons = ! this . hasButtons ( buttons ) ;
5762 var needsNewLogo = ( this . hasLogo !== context . displaylogo ) ;
@@ -62,7 +67,7 @@ proto.update = function(graphInfo, buttons) {
6267 if ( needsNewButtons || needsNewLogo || needsNewLocale ) {
6368 this . removeAllButtons ( ) ;
6469
65- this . updateButtons ( buttons ) ;
70+ this . updateButtons ( buttons , context . modeBarStyle . iconColor ) ;
6671
6772 if ( context . displaylogo ) {
6873 this . element . appendChild ( this . getLogo ( ) ) ;
@@ -73,7 +78,7 @@ proto.update = function(graphInfo, buttons) {
7378 this . updateActiveButton ( ) ;
7479} ;
7580
76- proto . updateButtons = function ( buttons ) {
81+ proto . updateButtons = function ( buttons , iconColor ) {
7782 var _this = this ;
7883
7984 this . buttons = buttons ;
@@ -93,6 +98,7 @@ proto.updateButtons = function(buttons) {
9398 }
9499 _this . buttonsNames . push ( buttonName ) ;
95100
101+ buttonConfig . color = iconColor ;
96102 var button = _this . createButton ( buttonConfig ) ;
97103 _this . buttonElements . push ( button ) ;
98104 group . appendChild ( button ) ;
@@ -157,6 +163,7 @@ proto.createButton = function(config) {
157163 if ( config . toggle ) d3 . select ( button ) . classed ( 'active' , true ) ;
158164
159165 var icon = config . icon ;
166+ if ( config . color ) icon . color = config . color ;
160167 if ( typeof icon === 'function' ) {
161168 button . appendChild ( icon ( ) ) ;
162169 }
@@ -173,31 +180,42 @@ proto.createButton = function(config) {
173180 * @Param {object} thisIcon
174181 * @Param {number} thisIcon.width
175182 * @Param {string} thisIcon.path
183+ * @Param {string} thisIcon.color
176184 * @Return {HTMLelement}
177185 */
178186proto . createIcon = function ( thisIcon ) {
179187 var iconHeight = isNumeric ( thisIcon . height ) ?
180188 Number ( thisIcon . height ) :
181189 thisIcon . ascent - thisIcon . descent ,
182190 svgNS = 'http://www.w3.org/2000/svg' ,
183- icon = document . createElementNS ( svgNS , 'svg' ) ,
184- path = document . createElementNS ( svgNS , 'path' ) ;
191+ icon = document . createElementNS ( svgNS , 'svg' ) ;
185192
186193 icon . setAttribute ( 'height' , '1em' ) ;
187194 icon . setAttribute ( 'width' , ( thisIcon . width / iconHeight ) + 'em' ) ;
188195 icon . setAttribute ( 'viewBox' , [ 0 , 0 , thisIcon . width , iconHeight ] . join ( ' ' ) ) ;
189196
190- path . setAttribute ( 'd' , thisIcon . path ) ;
197+ if ( thisIcon . path ) {
198+ var path = document . createElementNS ( svgNS , 'path' ) ;
199+ path . setAttribute ( 'd' , thisIcon . path ) ;
191200
192- if ( thisIcon . transform ) {
193- path . setAttribute ( 'transform' , thisIcon . transform ) ;
194- }
195- else if ( thisIcon . ascent !== undefined ) {
196- // Legacy icon transform calculation
197- path . setAttribute ( 'transform' , 'matrix(1 0 0 -1 0 ' + thisIcon . ascent + ')' ) ;
201+ if ( thisIcon . transform ) {
202+ path . setAttribute ( 'transform' , thisIcon . transform ) ;
203+ }
204+ else if ( thisIcon . ascent !== undefined ) {
205+ // Legacy icon transform calculation
206+ path . setAttribute ( 'transform' , 'matrix(1 0 0 -1 0 ' + thisIcon . ascent + ')' ) ;
207+ }
208+
209+ if ( thisIcon . color ) {
210+ path . setAttribute ( 'fill' , thisIcon . color ) ;
211+ }
212+
213+ icon . appendChild ( path ) ;
198214 }
199215
200- icon . appendChild ( path ) ;
216+ if ( thisIcon . svg ) {
217+ icon . innerHTML = thisIcon . svg ;
218+ }
201219
202220 return icon ;
203221} ;
@@ -272,7 +290,7 @@ proto.getLogo = function() {
272290 a . setAttribute ( 'data-title' , Lib . _ ( this . graphInfo , 'Produced with Plotly' ) ) ;
273291 a . className = 'modebar-btn plotlyjsicon modebar-btn--logo' ;
274292
275- a . appendChild ( this . createIcon ( Icons . plotlylogo ) ) ;
293+ a . appendChild ( this . createIcon ( Icons . newplotlylogo ) ) ;
276294
277295 group . appendChild ( a ) ;
278296 return group ;
0 commit comments