Skip to content

Commit

Permalink
fix #4027 - show zeroline even when no grid lines are present
Browse files Browse the repository at this point in the history
- see #4027
  for complete rationale
- add assertZeroLines assertion
  • Loading branch information
etpinard committed Sep 13, 2019
1 parent 9f30e0a commit ed81f17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,6 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) {
(rng[0] * rng[1] <= 0) &&
ax.zeroline &&
(ax.type === 'linear' || ax.type === '-') &&
ax._gridVals.length &&
(
clipEnds(ax, 0) ||
!anyCounterAxLineAtZero(gd, ax, counterAxis, rng) ||
Expand Down
11 changes: 11 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,17 @@ describe('Test axes', function() {
})
.then(function() {
assertZeroLines(['x', 'y']);
return Plotly.relayout(gd, {
'xaxis.showline': false, 'xaxis.nticks': 1, 'xaxis.range': [0, 0.1],
'yaxis.showline': false, 'yaxis.nticks': 2, 'yaxis.range': [0, 0.1]
});
})
.then(function() {
// no grid lines, but still should show zeroline in this case
// see https://github.com/plotly/plotly.js/issues/4027
expect(gd._fullLayout.xaxis._gridVals.length).toBe(0, '# of grid lines');
expect(gd._fullLayout.xaxis._gridVals.length).toBe(0, '# of grid lines');
assertZeroLines(['x', 'y']);
})
.catch(failTest)
.then(done);
Expand Down

0 comments on commit ed81f17

Please sign in to comment.