Skip to content

Commit

Permalink
Fixed #6897, prevented axis extremes change in case of a single point…
Browse files Browse the repository at this point in the history
… if multiple ticks are set.
  • Loading branch information
Kacper Madej authored and TorsteinHonsi committed Jul 13, 2017
1 parent 887f756 commit da2557a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/parts/Axis.js
Expand Up @@ -2248,8 +2248,9 @@ H.extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */{
this.trimTicks(tickPositions, startOnTick, endOnTick);
if (!this.isLinked) {

// Substract half a unit (#2619, #2846, #2515, #3390)
if (this.single) {
// Substract half a unit (#2619, #2846, #2515, #3390),
// but not in case of multiple ticks (#6897)
if (this.single && tickPositions.length < 2) {
this.min -= 0.5;
this.max += 0.5;
}
Expand Down
6 changes: 6 additions & 0 deletions samples/unit-tests/axis/ticks/demo.details
@@ -0,0 +1,6 @@
---
resources:
- https://code.jquery.com/qunit/qunit-2.0.1.js
- https://code.jquery.com/qunit/qunit-2.0.1.css
js_wrap: b
...
7 changes: 7 additions & 0 deletions samples/unit-tests/axis/ticks/demo.html
@@ -0,0 +1,7 @@
<script src="https://code.highcharts.com/stock/highstock.js"></script>


<div id="qunit"></div>
<div id="qunit-fixture"></div>

<div id="container" style="width: 600px; height: 250px; margin: 0 auto"></div>
30 changes: 30 additions & 0 deletions samples/unit-tests/axis/ticks/demo.js
@@ -0,0 +1,30 @@
QUnit.test('Ticks for a single point.', function (assert) {
var chart = Highcharts.chart('container', {
yAxis: {
tickPositioner: function () {
return [0, 0.2, 0.4, 0.6, 0.8];
}
},
series: [{
data: [0.2]
}]
});

assert.strictEqual(
chart.yAxis[0].min,
0,
'multiple ticks from tickPositioner for a single point (#6897)'
);

chart.yAxis[0].update({
tickPositioner: function () {
return;
}
});

assert.strictEqual(
chart.yAxis[0].min,
-0.3,
'single tick and increased extremes for a single point'
);
});

0 comments on commit da2557a

Please sign in to comment.