Skip to content

Commit

Permalink
Fixed #10413, requested corrections and change some functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Wedzel authored and TorsteinHonsi committed Apr 23, 2019
1 parent 860c744 commit fff8260
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions js/parts/Dynamics.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ extend(Series.prototype, /** @lends Series.prototype */ {
* @param {boolean} [withEvent=true]
* Used internally, whether to fire the series `addPoint` event.
*
* @return {Highcharts.Point}
* The newly generated point object.
*
* @fires Highcharts.Series#event:addPoint
*/
addPoint: function (options, redraw, shift, animation, withEvent) {
Expand All @@ -856,8 +859,8 @@ extend(Series.prototype, /** @lends Series.prototype */ {
names = xAxis && xAxis.hasNames && xAxis.names,
dataOptions = seriesOptions.data,
point,
isInTheMiddle,
xData = series.xData,
PointClass = series.pointClass,
i,
x;

Expand All @@ -870,11 +873,11 @@ extend(Series.prototype, /** @lends Series.prototype */ {
point = { series: series };
series.pointClass.prototype.applyOptions.apply(point, [options]);
x = point.x;
point = (new PointClass()).init(series, options, x);

// Get the insertion point
i = xData.length;
if (series.requireSorting && x < xData[i - 1]) {
isInTheMiddle = true;
while (i && xData[i - 1] > x) {
i--;
}
Expand All @@ -889,11 +892,7 @@ extend(Series.prototype, /** @lends Series.prototype */ {
names[x] = point.name;
}
dataOptions.splice(i, 0, options);

if (isInTheMiddle) {
series.data.splice(i, 0, null);
series.processData();
}
series.data.splice(i, 0, point);

// Generate points to be added to the legend (#1329)
if (seriesOptions.legendType === 'point') {
Expand Down
6 changes: 3 additions & 3 deletions samples/unit-tests/series/addpoint/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ QUnit.test('Testing addPoint() function - return point #10413', function (assert
var point = chart.series[0].addPoint(8);

assert.strictEqual(
typeof (point),
'object',
'Point should be added to array as an object.'
point instanceof Highcharts.Point,
true,
'Added point has a Highcharts.Point properties.'
);
});

0 comments on commit fff8260

Please sign in to comment.