From bf191648790425345be8531115d88a51db1cb21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torstein=20H=C3=B8nsi?= Date: Thu, 16 Mar 2017 14:01:11 +0100 Subject: [PATCH] Fixed #6469, series got lost when mixing category data in a dual axis chart. --- js/parts/Axis.js | 6 +- samples/unit-tests/axis/category/demo.js | 76 +++++++++++++++++++++++- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/js/parts/Axis.js b/js/parts/Axis.js index ab73764c9ed..97298345de5 100644 --- a/js/parts/Axis.js +++ b/js/parts/Axis.js @@ -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; }, @@ -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; } diff --git a/samples/unit-tests/axis/category/demo.js b/samples/unit-tests/axis/category/demo.js index dc7bac370aa..d8c4213d9ca 100644 --- a/samples/unit-tests/axis/category/demo.js +++ b/samples/unit-tests/axis/category/demo.js @@ -476,8 +476,7 @@ QUnit.test( var chart = new Highcharts.Chart({ chart: { renderTo: 'container', - type: 'column', - + type: 'column' }, xAxis: { type: 'category' @@ -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' + ); + } +);