Skip to content

Commit

Permalink
Highstock: fixed #2914, dataGrouping approximation wasn't checked pro…
Browse files Browse the repository at this point in the history
…perly.
  • Loading branch information
Kacper Madej committed Apr 21, 2017
1 parent 941ec25 commit 5814242
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
8 changes: 7 additions & 1 deletion js/parts/DataGrouping.js
Expand Up @@ -221,7 +221,13 @@ seriesProto.groupData = function (xData, yData, groupPositions, approximation) {
values = [],
approximationFn = typeof approximation === 'function' ?
approximation :
approximations[approximation],
approximations[approximation] ||
// if the approximation is not found use default series type
// approximation (#2914)
(
specificOptions[series.type] &&
approximations[specificOptions[series.type].approximation]
) || approximations[commonOptions.approximation],
pointArrayMap = series.pointArrayMap,
pointArrayMapLength = pointArrayMap && pointArrayMap.length,
pos = 0,
Expand Down
42 changes: 40 additions & 2 deletions samples/unit-tests/series/datagrouping/demo.js
Expand Up @@ -22,16 +22,54 @@ QUnit.test('dataGrouping and keys', function (assert) {
});

assert.strictEqual(
chart.series[0].points[0].low === 91 && chart.series[0].points[0].high === 109,
chart.series[0].points[0].low === 91 &&
chart.series[0].points[0].high === 109,
true,
'data grouped correctly when using keys on data (#6590)'
);

chart.xAxis[0].setExtremes(0, 30);

assert.strictEqual(
chart.series[0].points[0].low === 100 && chart.series[0].points[0].high === 100,
chart.series[0].points[0].low === 100 &&
chart.series[0].points[0].high === 100,
true,
'not grouped data is correct'
);
});

QUnit.test('dataGrouping approximations', function (assert) {
var chart = Highcharts.stockChart('container', {
chart: {
width: 400
},
plotOptions: {
series: {
dataGrouping: {
forced: true,
units: [
['millisecond', [10]]
],
approximation: 'wrong'
}
}
},
series: [{
data: [0, 5, 40]
}, {
type: 'column',
data: [2, 2, 2]
}, {
type: 'ohlc',
data: [[1, 3, 0, 2], [1, 5, 1, 2], [2, 2, 2, 2]]
}]
});

assert.strictEqual(
chart.series[0].points[0].y === 15 &&
chart.series[1].points[0].y === 6 &&
chart.series[2].points[0].high === 5,
true,
'wrong approximation - fallback to series default (#2914)'
);
});

0 comments on commit 5814242

Please sign in to comment.