diff --git a/js/parts/Axis.js b/js/parts/Axis.js index 274bd443702..e29f0a8fb42 100644 --- a/js/parts/Axis.js +++ b/js/parts/Axis.js @@ -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; } diff --git a/samples/unit-tests/axis/ticks/demo.details b/samples/unit-tests/axis/ticks/demo.details new file mode 100644 index 00000000000..a86ee3a2f30 --- /dev/null +++ b/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 +... \ No newline at end of file diff --git a/samples/unit-tests/axis/ticks/demo.html b/samples/unit-tests/axis/ticks/demo.html new file mode 100644 index 00000000000..20fd9fd355f --- /dev/null +++ b/samples/unit-tests/axis/ticks/demo.html @@ -0,0 +1,7 @@ + + + +
+
+ +
\ No newline at end of file diff --git a/samples/unit-tests/axis/ticks/demo.js b/samples/unit-tests/axis/ticks/demo.js new file mode 100644 index 00000000000..79cca9c0c8c --- /dev/null +++ b/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' + ); +}); \ No newline at end of file