Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function handleCartesian(gd, ev) {
var fullLayout = gd._fullLayout;
var aobj = {};
var axList = axisIds.list(gd, null, true);
var allSpikesEnabled = 'on';
var allSpikesEnabled = fullLayout._cartesianSpikesEnabled;

var ax, i;

Expand All @@ -224,6 +224,8 @@ function handleCartesian(gd, ev) {
aobj[axName + '.range[0]'] = rangeInitial[0];
aobj[axName + '.range[1]'] = rangeInitial[1];
}

// N.B. "reset" also resets showspikes
if(ax._showSpikeInitial !== undefined) {
aobj[axName + '.showspikes'] = ax._showSpikeInitial;
if(allSpikesEnabled === 'on' && !ax._showSpikeInitial) {
Expand All @@ -246,7 +248,6 @@ function handleCartesian(gd, ev) {
}
}
}
fullLayout._cartesianSpikesEnabled = allSpikesEnabled;
} else {
// if ALL traces have orientation 'h', 'hovermode': 'x' otherwise: 'y'
if(astr === 'hovermode' && (val === 'x' || val === 'y')) {
Expand All @@ -259,12 +260,13 @@ function handleCartesian(gd, ev) {
allSpikesEnabled = 'off';
}
}
fullLayout._cartesianSpikesEnabled = allSpikesEnabled;
}

aobj[astr] = val;
}

fullLayout._cartesianSpikesEnabled = allSpikesEnabled;

Registry.call('_guiRelayout', gd, aobj);
}

Expand Down
30 changes: 30 additions & 0 deletions test/jasmine/tests/modebar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,36 @@ describe('ModeBar', function() {
buttonClosest.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');
});

it('should work after clicking on "autoScale2d"', function() {
var buttonAutoScale = selectButton(modeBar, 'autoScale2d');
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, clicking on the "autoScale2d" modebar button on a graph that has _cartesianSpikesEnabled: 'off' on first draw, results in

gd._fullLayout._cartesianSpikesEnabled // => 'on'

which is obviously wrong.


buttonAutoScale.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');

buttonToggle.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('on');

buttonToggle.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');
});

it('should work after clicking on "resetScale2d"', function() {
var buttonResetScale = selectButton(modeBar, 'resetScale2d');
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');

buttonToggle.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('on');

buttonResetScale.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');

buttonToggle.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('on');
buttonToggle.click();
expect(gd._fullLayout._cartesianSpikesEnabled).toBe('off');
});
});
});

Expand Down