Skip to content

Commit 397a6de

Browse files
committed
move modeBarStyle from config to layout options
1 parent ff9d801 commit 397a6de

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

src/components/modebar/modebar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ proto.update = function(graphInfo, buttons) {
4646
this.graphInfo = graphInfo;
4747

4848
var context = this.graphInfo._context;
49+
var fullLayout = this.graphInfo._fullLayout;
4950

5051
if(context.displayModeBar === 'hover') {
5152
this.element.className = 'modebar modebar--hover';
5253
}
5354
else this.element.className = 'modebar';
5455

55-
if(context.modeBarStyle.orientation === 'v') {
56+
if(fullLayout.modeBarStyle.orientation === 'v') {
5657
this.element.className += ' vertical';
58+
buttons = buttons.reverse();
5759
}
58-
this.element.style.backgroundColor = context.modeBarStyle.bgcolor;
60+
this.element.style.backgroundColor = fullLayout.modeBarStyle.bgcolor;
5961

6062
// if buttons or logo have changed, redraw modebar interior
6163
var needsNewButtons = !this.hasButtons(buttons);
@@ -67,10 +69,10 @@ proto.update = function(graphInfo, buttons) {
6769
if(needsNewButtons || needsNewLogo || needsNewLocale) {
6870
this.removeAllButtons();
6971

70-
this.updateButtons(buttons, context.modeBarStyle.iconColor);
72+
this.updateButtons(buttons, fullLayout.modeBarStyle.iconColor);
7173

7274
if(context.displaylogo) {
73-
if(context.modeBarStyle.orientation === 'v') {
75+
if(fullLayout.modeBarStyle.orientation === 'v') {
7476
this.element.prepend(this.getLogo());
7577
} else {
7678
this.element.appendChild(this.getLogo());

src/plot_api/plot_api.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ function setPlotContext(gd, config) {
428428
keys = Object.keys(config);
429429
for(i = 0; i < keys.length; i++) {
430430
key = keys[i];
431-
if(key === 'editable' || key === 'edits' || key === 'modeBarStyle') continue;
431+
if(key === 'editable' || key === 'edits') continue;
432432
if(key in context) {
433433
if(key === 'setBackground' && config[key] === 'opaque') {
434434
context[key] = opaqueSetBackground;
@@ -465,15 +465,6 @@ function setPlotContext(gd, config) {
465465
}
466466
}
467467
}
468-
if(config.modeBarStyle) {
469-
keys = Object.keys(config.modeBarStyle);
470-
for(i = 0; i < keys.length; i++) {
471-
key = keys[i];
472-
if(key in context.modeBarStyle) {
473-
context.modeBarStyle[key] = config.modeBarStyle[key];
474-
}
475-
}
476-
}
477468
}
478469

479470
// staticPlot forces a bunch of others:

src/plot_api/plot_config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ module.exports = {
102102
// display the mode bar (true, false, or 'hover')
103103
displayModeBar: 'hover',
104104

105-
// mode bar style
106-
modeBarStyle: {
107-
orientation: 'h',
108-
bgcolor: 'rgba(255,255,255,0.7)',
109-
iconColor: 'rgba(0, 31, 95, 0.3)'
110-
},
111-
112105
/*
113106
* remove mode bar button by name
114107
* (see ../components/modebar/buttons.js for the list of names)

src/plots/layout_attributes.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,29 @@ module.exports = {
224224
'or a logo image, for example. To omit one of these items on the plot,',
225225
'make an item with matching `templateitemname` and `visible: false`.'
226226
].join(' ')
227+
},
228+
modeBarStyle: {
229+
orientation: {
230+
valType: 'enumerated',
231+
values: ['v', 'h'],
232+
dflt: 'h',
233+
role: 'info',
234+
editType: 'modebar',
235+
description: 'Sets the orientation of the modebar.'
236+
},
237+
bgcolor: {
238+
valType: 'color',
239+
role: 'style',
240+
dflt: 'rgba(255,255,255,0.7)',
241+
editType: 'modebar',
242+
description: 'Sets the background color of the modebar.'
243+
},
244+
iconColor: {
245+
valType: 'color',
246+
role: 'style',
247+
dflt: 'rgba(0, 31, 95, 0.3)',
248+
editType: 'modebar',
249+
description: 'Sets the color of the icons in the modebar.'
250+
}
227251
}
228252
};

src/plots/plots.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,10 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
13341334

13351335
coerce('datarevision');
13361336

1337+
coerce('modeBarStyle.orientation');
1338+
coerce('modeBarStyle.bgcolor');
1339+
coerce('modeBarStyle.iconColor');
1340+
13371341
Registry.getComponentMethod(
13381342
'calendars',
13391343
'handleDefaults'

0 commit comments

Comments
 (0)