Skip to content

Commit bfc49fb

Browse files
authored
Merge pull request #1302 from plotly/updatemenus-over-sliders
Draw updatemenus over sliders
2 parents 8bd4c97 + f2db0d7 commit bfc49fb

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

src/plot_api/plot_api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ Plotly.plot = function(gd, data, layout, config) {
196196

197197
Registry.getComponentMethod('legend', 'draw')(gd);
198198
Registry.getComponentMethod('rangeselector', 'draw')(gd);
199-
Registry.getComponentMethod('updatemenus', 'draw')(gd);
200199
Registry.getComponentMethod('sliders', 'draw')(gd);
200+
Registry.getComponentMethod('updatemenus', 'draw')(gd);
201201

202202
for(i = 0; i < calcdata.length; i++) {
203203
cd = calcdata[i];
@@ -333,8 +333,8 @@ Plotly.plot = function(gd, data, layout, config) {
333333
Registry.getComponentMethod('legend', 'draw')(gd);
334334
Registry.getComponentMethod('rangeslider', 'draw')(gd);
335335
Registry.getComponentMethod('rangeselector', 'draw')(gd);
336-
Registry.getComponentMethod('updatemenus', 'draw')(gd);
337336
Registry.getComponentMethod('sliders', 'draw')(gd);
337+
Registry.getComponentMethod('updatemenus', 'draw')(gd);
338338
}
339339

340340
function cleanUp() {

test/jasmine/tests/updatemenus_test.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ describe('update menus interactions', function() {
629629
}).catch(fail).then(done);
630630
});
631631

632-
it('appliesy padding on relayout', function(done) {
632+
it('applies y padding on relayout', function(done) {
633633
var x1, x2;
634634
var firstMenu = d3.select('.' + constants.headerGroupClassName);
635635
var padShift = 40;
@@ -734,3 +734,69 @@ describe('update menus interactions', function() {
734734
return button;
735735
}
736736
});
737+
738+
739+
describe('update menus interaction with other components:', function() {
740+
'use strict';
741+
742+
afterEach(destroyGraphDiv);
743+
744+
it('buttons show be drawn above sliders', function(done) {
745+
746+
Plotly.plot(createGraphDiv(), [{
747+
x: [1, 2, 3],
748+
y: [1, 2, 1]
749+
}], {
750+
sliders: [{
751+
xanchor: 'right',
752+
x: -0.05,
753+
y: 0.9,
754+
len: 0.3,
755+
steps: [{
756+
label: 'red',
757+
method: 'restyle',
758+
args: [{'line.color': 'red'}]
759+
}, {
760+
label: 'orange',
761+
method: 'restyle',
762+
args: [{'line.color': 'orange'}]
763+
}, {
764+
label: 'yellow',
765+
method: 'restyle',
766+
args: [{'line.color': 'yellow'}]
767+
}]
768+
}],
769+
updatemenus: [{
770+
buttons: [{
771+
label: 'markers and lines',
772+
method: 'restyle',
773+
args: [{ 'mode': 'markers+lines' }]
774+
}, {
775+
label: 'markers',
776+
method: 'restyle',
777+
args: [{ 'mode': 'markers' }]
778+
}, {
779+
label: 'lines',
780+
method: 'restyle',
781+
args: [{ 'mode': 'lines' }]
782+
}]
783+
}]
784+
})
785+
.then(function() {
786+
var infoLayer = d3.select('g.infolayer');
787+
var containerClassNames = ['slider-container', 'updatemenu-container'];
788+
var list = [];
789+
790+
infoLayer.selectAll('*').each(function() {
791+
var className = d3.select(this).attr('class');
792+
793+
if(containerClassNames.indexOf(className) !== -1) {
794+
list.push(className);
795+
}
796+
});
797+
798+
expect(list).toEqual(containerClassNames);
799+
})
800+
.then(done);
801+
});
802+
});

0 commit comments

Comments
 (0)