Skip to content

Commit

Permalink
modebar: check traces instead of basePlotModules for noHover
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerg committed Jun 26, 2019
1 parent c796e57 commit aa6ba8f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
if(hasCartesian) {
hoverGroup = ['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian'];
}
if(hasNoHover(fullLayout)) {
if(hasNoHover(fullData)) {
hoverGroup = [];
}

Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 19 additions & 3 deletions test/jasmine/tests/modebar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit aa6ba8f

Please sign in to comment.