Skip to content

Commit

Permalink
Fixed #6469, series got lost when mixing category data in a dual axis…
Browse files Browse the repository at this point in the history
… chart.
  • Loading branch information
TorsteinHonsi committed Mar 16, 2017
1 parent 06ea018 commit bf19164
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
6 changes: 4 additions & 2 deletions js/parts/Axis.js
Expand Up @@ -930,7 +930,9 @@ H.Axis.prototype = {
}

// Write the last point's name to the names array
this.names[x] = point.name;
if (x !== undefined) {
this.names[x] = point.name;
}

return x;
},
Expand Down Expand Up @@ -959,7 +961,7 @@ H.Axis.prototype = {
var x;
if (point.options) {
x = axis.nameToX(point);
if (x !== point.x) {
if (x !== undefined && x !== point.x) {
point.x = x;
series.xData[i] = x;
}
Expand Down
76 changes: 74 additions & 2 deletions samples/unit-tests/axis/category/demo.js
Expand Up @@ -476,8 +476,7 @@ QUnit.test(
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column',

type: 'column'
},
xAxis: {
type: 'category'
Expand Down Expand Up @@ -516,3 +515,76 @@ QUnit.test(

}
);

QUnit.test(
'Lost series with multiple axes and mixed configuration (#6469)',
function (assert) {
var chart = Highcharts.chart('container', {
chart: {
type: "column",
animation: false
},
xAxis: {
type: "category",
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: [{
lineWidth: 1,
title: {
text: 'Primary Axis'
},
}, {
lineWidth: 1,
opposite: true,
title: {
text: 'Secondary Axis'
}
}],

plotOptions: {
animation: false
},

series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
yAxis: 0
}, {
data: [
["Jan", 14400.0],
["Feb", 17600.0],
["Mar", 13500.6],
["Apr", 14800.5],
["May", 21600.4],
["Jun", 19400.1],
["Jul", 9500.6],
["Aug", 5400.4],
["Sep", 2900.9],
["Oct", 7100.5],
["Nov", 10600.4],
["Dec", 12900.2]
],
yAxis: 1,
type: "spline"
}]
});

chart.series[0].hide();
chart.series[0].show();

assert.strictEqual(
chart.xAxis[0].tickPositions.length,
12,
'All ticks intact'
);
assert.strictEqual(
chart.xAxis[0].min,
0,
'Correct min'
);
assert.strictEqual(
chart.xAxis[0].max,
11,
'Correct max'
);
}
);

0 comments on commit bf19164

Please sign in to comment.