Skip to content

Commit

Permalink
Fixed #6563, a regression causing flat integer data to draw on the X …
Browse files Browse the repository at this point in the history
…axis when `allowDecimals` was false.
  • Loading branch information
TorsteinHonsi committed Apr 5, 2017
1 parent 324763d commit 862628f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 11 additions & 2 deletions js/parts/Axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1299,8 +1299,17 @@ H.Axis.prototype = {
// this axis, then min and max are equal and tickPositions.length is 0
// or 1. In this case, add some padding in order to center the point,
// but leave it with one tick. #1337.
this.single = this.min === this.max && defined(this.min) &&
!this.tickAmount && options.allowDecimals !== false;
this.single =
this.min === this.max &&
defined(this.min) &&
!this.tickAmount &&
(
// Data is on integer (#6563)
parseInt(this.min, 10) === this.min ||

// Between integers and decimals are not allowed (#6274)
options.allowDecimals !== false
);

// Find the tick positions
this.tickPositions = tickPositions = tickPositionsOption && tickPositionsOption.slice(); // Work on a copy (#1565)
Expand Down
9 changes: 8 additions & 1 deletion samples/unit-tests/axis/flat-data/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ QUnit.test('Line series', function (assert) {
assert.strictEqual(
chart.yAxis[0].tickPositions.toString(),
'1,2',
'Now two ticks'
'Now two ticks (#6274)'
);

chart.series[0].setData([1, 1]);
assert.strictEqual(
chart.yAxis[0].tickPositions.toString(),
'1',
'Now one tick (#6563)'
);

});
Expand Down

0 comments on commit 862628f

Please sign in to comment.