From aa6ba8fab5769bf56bce125c04f3c3cd3cbc5ff8 Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Wed, 26 Jun 2019 17:05:42 -0400 Subject: [PATCH] modebar: check traces instead of basePlotModules for noHover --- src/components/modebar/manage.js | 10 +++++----- test/jasmine/tests/modebar_test.js | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js index f4a43c9ce9e..6c8b1884a7b 100644 --- a/src/components/modebar/manage.js +++ b/src/components/modebar/manage.js @@ -146,7 +146,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { if(hasCartesian) { hoverGroup = ['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']; } - if(hasNoHover(fullLayout)) { + if(hasNoHover(fullData)) { hoverGroup = []; } @@ -219,10 +219,10 @@ function isSelectable(fullData) { return selectable; } -// check whether all plot modules in fullLayout are noHover -function hasNoHover(fullLayout) { - for(var i = 0; i < fullLayout._basePlotModules.length; i++) { - if(!Registry.traceIs(fullLayout._basePlotModules[i].name, 'noHover')) return false; +// check whether all trace are 'noHover' +function hasNoHover(fullData) { + for(var i = 0; i < fullData.length; i++) { + if(!Registry.traceIs(fullData[i], 'noHover')) return false; } return true; } diff --git a/test/jasmine/tests/modebar_test.js b/test/jasmine/tests/modebar_test.js index 05caf3f35f4..30dca4169f5 100644 --- a/test/jasmine/tests/modebar_test.js +++ b/test/jasmine/tests/modebar_test.js @@ -41,7 +41,6 @@ describe('ModeBar', function() { _modebardiv: d3.select(getMockModeBarTree()), _has: Plots._hasPlotType, _subplots: {xaxis: xaxes || [], yaxis: yaxes || []}, - _basePlotModules: [], modebar: { orientation: 'h', bgcolor: 'rgba(255,255,255,0.7)', @@ -349,6 +348,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(['x'], ['y']); gd._fullLayout._basePlotModules = [{ name: 'cartesian' }]; gd._fullLayout.xaxis = {fixedrange: false}; + gd._fullData = [{type: 'scatter'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -412,6 +412,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'cartesian' }]; + gd._fullData = [{type: 'scatter'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -429,6 +430,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'gl3d' }]; + gd._fullData = [{type: 'scatter3d'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -446,6 +448,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'geo' }]; + gd._fullData = [{type: 'scattergeo'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -486,6 +489,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'mapbox' }]; + gd._fullData = [{type: 'scattermapbox'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -527,6 +531,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(['x'], ['y']); gd._fullLayout._basePlotModules = [{ name: 'gl2d' }]; gd._fullLayout.xaxis = {fixedrange: false}; + gd._fullData = [{type: 'scattergl'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -542,6 +547,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'pie' }]; + gd._fullData = [{type: 'pie'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -559,6 +565,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'cartesian' }, { name: 'gl3d' }]; + gd._fullData = [{type: 'scatter'}, {type: 'scatter3d'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -577,6 +584,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(['x'], ['y']); gd._fullLayout._basePlotModules = [{ name: 'cartesian' }, { name: 'geo' }]; gd._fullLayout.xaxis = {fixedrange: false}; + gd._fullData = [{type: 'scatter'}, {type: 'scattergeo'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -642,6 +650,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'geo' }, { name: 'gl3d' }]; + gd._fullData = [{type: 'scattergeo'}, {type: 'scatter3d'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -658,6 +667,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'ternary' }]; + gd._fullData = [{type: 'scatterternary'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -696,6 +706,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'ternary' }, { name: 'cartesian' }]; + gd._fullData = [{type: 'scatterternary'}, {type: 'scatter'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -713,6 +724,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'ternary' }, { name: 'gl3d' }]; + gd._fullData = [{ type: 'scatterternary' }, { type: 'scatter3d' }]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -726,7 +738,7 @@ describe('ModeBar', function() { ]); var gd = getMockGraphInfo(); - gd._fullLayout._basePlotModules = [{ name: 'indicator' }]; + gd._fullData = [{ type: 'indicator' }]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -741,7 +753,8 @@ describe('ModeBar', function() { ]); var gd = getMockGraphInfo(); - gd._fullLayout._basePlotModules = [{ name: 'indicator' }, {name: 'pie'}]; + gd._fullLayout._basePlotModules = [{ name: 'pie' }]; + gd._fullData = [{ type: 'indicator' }, {type: 'pie'}]; manageModeBar(gd); var modeBar = gd._fullLayout._modeBar; @@ -794,6 +807,7 @@ describe('ModeBar', function() { it('displays/hides cloud link according to showSendToCloud config arg', function() { var gd = getMockGraphInfo(); gd._fullLayout._basePlotModules = [{ name: 'pie' }]; + gd._fullData = [{type: 'pie'}]; manageModeBar(gd); checkButtons(gd._fullLayout._modeBar, getButtons([ ['toImage'], @@ -823,6 +837,7 @@ describe('ModeBar', function() { var gd = getMockGraphInfo(['x'], ['y']); gd._fullLayout._basePlotModules = [{ name: 'cartesian' }]; gd._fullLayout.xaxis = {fixedrange: false}; + gd._fullData = [{type: 'scatter'}]; return gd; } @@ -833,6 +848,7 @@ describe('ModeBar', function() { expect(countButtons(gd._fullLayout._modeBar)).toEqual(11); gd._fullLayout._basePlotModules = [{ name: 'gl3d' }]; + gd._fullData = [{type: 'scatter3d'}]; manageModeBar(gd); expect(countButtons(gd._fullLayout._modeBar)).toEqual(9);