From 2a40921a0ae04c0b934d797ad19aa7e6dcf4cc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 13 Jan 2017 17:40:41 -0500 Subject: [PATCH 1/2] draw updatemenus over sliders - so that their buttons are displayed above all other layout components --- src/plot_api/plot_api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 0e26c4b8aa9..431cda21cc6 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -196,8 +196,8 @@ Plotly.plot = function(gd, data, layout, config) { Registry.getComponentMethod('legend', 'draw')(gd); Registry.getComponentMethod('rangeselector', 'draw')(gd); - Registry.getComponentMethod('updatemenus', 'draw')(gd); Registry.getComponentMethod('sliders', 'draw')(gd); + Registry.getComponentMethod('updatemenus', 'draw')(gd); for(i = 0; i < calcdata.length; i++) { cd = calcdata[i]; @@ -333,8 +333,8 @@ Plotly.plot = function(gd, data, layout, config) { Registry.getComponentMethod('legend', 'draw')(gd); Registry.getComponentMethod('rangeslider', 'draw')(gd); Registry.getComponentMethod('rangeselector', 'draw')(gd); - Registry.getComponentMethod('updatemenus', 'draw')(gd); Registry.getComponentMethod('sliders', 'draw')(gd); + Registry.getComponentMethod('updatemenus', 'draw')(gd); } function cleanUp() { From f2db0d797a0149c9f452df0f9c72104e14449adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 16 Jan 2017 14:39:43 -0500 Subject: [PATCH 2/2] add test checking that updatemenus are above sliders --- test/jasmine/tests/updatemenus_test.js | 68 +++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/test/jasmine/tests/updatemenus_test.js b/test/jasmine/tests/updatemenus_test.js index 37a3a415e2d..a85947445f4 100644 --- a/test/jasmine/tests/updatemenus_test.js +++ b/test/jasmine/tests/updatemenus_test.js @@ -629,7 +629,7 @@ describe('update menus interactions', function() { }).catch(fail).then(done); }); - it('appliesy padding on relayout', function(done) { + it('applies y padding on relayout', function(done) { var x1, x2; var firstMenu = d3.select('.' + constants.headerGroupClassName); var padShift = 40; @@ -734,3 +734,69 @@ describe('update menus interactions', function() { return button; } }); + + +describe('update menus interaction with other components:', function() { + 'use strict'; + + afterEach(destroyGraphDiv); + + it('buttons show be drawn above sliders', function(done) { + + Plotly.plot(createGraphDiv(), [{ + x: [1, 2, 3], + y: [1, 2, 1] + }], { + sliders: [{ + xanchor: 'right', + x: -0.05, + y: 0.9, + len: 0.3, + steps: [{ + label: 'red', + method: 'restyle', + args: [{'line.color': 'red'}] + }, { + label: 'orange', + method: 'restyle', + args: [{'line.color': 'orange'}] + }, { + label: 'yellow', + method: 'restyle', + args: [{'line.color': 'yellow'}] + }] + }], + updatemenus: [{ + buttons: [{ + label: 'markers and lines', + method: 'restyle', + args: [{ 'mode': 'markers+lines' }] + }, { + label: 'markers', + method: 'restyle', + args: [{ 'mode': 'markers' }] + }, { + label: 'lines', + method: 'restyle', + args: [{ 'mode': 'lines' }] + }] + }] + }) + .then(function() { + var infoLayer = d3.select('g.infolayer'); + var containerClassNames = ['slider-container', 'updatemenu-container']; + var list = []; + + infoLayer.selectAll('*').each(function() { + var className = d3.select(this).attr('class'); + + if(containerClassNames.indexOf(className) !== -1) { + list.push(className); + } + }); + + expect(list).toEqual(containerClassNames); + }) + .then(done); + }); +});