Skip to content

Commit

Permalink
Fixed #5631, zeroes in logarithmic chart made the whole graph crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Aug 30, 2016
1 parent 5203670 commit 7b4ceac
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
3 changes: 1 addition & 2 deletions js/highcharts.src.js
Expand Up @@ -14571,8 +14571,7 @@

// Discard disallowed y values for log axes (#3434)
if (yAxis.isLog && yValue !== null && yValue <= 0) {
point.y = yValue = null;
error(10);
point.isNull = true;
}

// Get the plotX translation
Expand Down
3 changes: 1 addition & 2 deletions js/highmaps.src.js
Expand Up @@ -14052,8 +14052,7 @@

// Discard disallowed y values for log axes (#3434)
if (yAxis.isLog && yValue !== null && yValue <= 0) {
point.y = yValue = null;
error(10);
point.isNull = true;
}

// Get the plotX translation
Expand Down
3 changes: 1 addition & 2 deletions js/highstock.src.js
Expand Up @@ -14571,8 +14571,7 @@

// Discard disallowed y values for log axes (#3434)
if (yAxis.isLog && yValue !== null && yValue <= 0) {
point.y = yValue = null;
error(10);
point.isNull = true;
}

// Get the plotX translation
Expand Down
3 changes: 1 addition & 2 deletions js/parts/Series.js
Expand Up @@ -721,8 +721,7 @@ Series.prototype = {

// Discard disallowed y values for log axes (#3434)
if (yAxis.isLog && yValue !== null && yValue <= 0) {
point.y = yValue = null;
error(10);
point.isNull = true;
}

// Get the plotX translation
Expand Down
5 changes: 5 additions & 0 deletions samples/unit-tests/series/data-null/demo.details
@@ -0,0 +1,5 @@
---
resources:
- https://code.jquery.com/qunit/qunit-1.19.0.js
- https://code.jquery.com/qunit/qunit-1.19.0.css
...
7 changes: 7 additions & 0 deletions samples/unit-tests/series/data-null/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; margin: 0 auto"></div>
43 changes: 43 additions & 0 deletions samples/unit-tests/series/data-null/demo.js
@@ -0,0 +1,43 @@
$(function () {

QUnit.test('NaN in graphs', function (assert) {
var chart = Highcharts.chart('container', {

series: [{
data: [NaN, 71.5, 106.4, 129.2, 144.0, NaN, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]

});

assert.ok(
chart.series[0].graph.attr('d').length > 100,
'Path is ok'
);
assert.notEqual(
chart.series[0].graph.attr('d'),
'M 0 0',
'Path is ok'
);
});

QUnit.test('Zeroes on log axis', function (assert) {

var chart = Highcharts.chart('container', {

yAxis: {
type: 'logarithmic'
},

series: [{
data: [1, 2, 0, 8, 16, 32, 64, 128, 256, 512],
pointStart: 1
}]
});

assert.strictEqual(
chart.series[0].graph.attr('d').split(' ')[6],
'M',
'Gap detected'
);
});
});

0 comments on commit 7b4ceac

Please sign in to comment.