Skip to content

Commit

Permalink
Fixed highcharts#9762, series was referencing public object for userO…
Browse files Browse the repository at this point in the history
…ptions and some updates were working in an unexpected way.
  • Loading branch information
KacperMadej authored and TorsteinHonsi committed Jan 7, 2019
1 parent cac9c2a commit 2aee510
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
3 changes: 2 additions & 1 deletion js/parts/Series.js
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,8 @@ H.Series = H.seriesType('line',
zone,
styledMode = chart.styledMode;

this.userOptions = itemOptions;
// use copy to prevent undetected changes (#9762)
this.userOptions = merge(itemOptions);

// General series options take precedence over type options because
// otherwise, default type options like column.animation would be
Expand Down
57 changes: 53 additions & 4 deletions samples/unit-tests/series/update/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,26 @@ QUnit.test('Series.update and mouse interaction', function (assert) {
events: {
mouseOver: function () {
this.update({
dataLabels: { enabled: true }, events: {
dataLabels: {
enabled: true
},
events: {
mouseOut: function () {
this.update({ dataLabels: { enabled: false } });
this.update({
dataLabels: {
enabled: false
}
});
}
}
});
},
mouseOut: function () {
this.update({ dataLabels: { enabled: false } });
this.update({
dataLabels: {
enabled: false
}
});
}
}
}
Expand Down Expand Up @@ -571,7 +582,7 @@ QUnit.test('Z index changed after update (#3094)', function (assert) {
pointPadding: -0.4
}
},
series: [ {
series: [{
data: [1300],
color: 'rgba(13,35,58,0.9)',
index: 0,
Expand Down Expand Up @@ -621,4 +632,42 @@ QUnit.test('Wrong type for series config (#9680)', function (assert) {
Highcharts.chart('container', {
series: {}
});
});

QUnit.test('series.update using altered original chart options', function (assert) {
var chartOptions = {
chart: {
renderTo: 'container'
},
plotOptions: {
series: {
lineWidth: 10
}
},
series: [{
data: [1, 20, -3],
type: 'line'
}]
},
chart = new Highcharts.Chart(chartOptions);

chartOptions.series[0].lineWidth = 10;
chart.series[0].update(chartOptions.series[0]);

assert.strictEqual(
chart.series[0].userOptions.lineWidth,
10,
'New options is added - passes through cleanRecursively (#9762)'
);

chartOptions.plotOptions.series.lineWidth = 1;
chart.update({
plotOptions: chartOptions.plotOptions
});

assert.strictEqual(
chart.series[0].options.lineWidth,
10,
'Series level option survived after plotOptions.series update (#9762)'
);
});

0 comments on commit 2aee510

Please sign in to comment.