Fedor Alexandrovich
Fedor Alexandrovich

Reputation: 147

How to remove batch of points in the period based on xAxis(time) coordinates from the series in Highstock

I've got a series and I need to remove points selected by time. For example points from 4 Dec to 25 Dec in this fiddle: http://jsfiddle.net/9rLbft5q/

series: [{
    name: 'AAPL Stock Price',
    data: data,
    type: 'areaspline',
    threshold: null,
    tooltip: {
        valueDecimals: 2
    },
    fillColor: {
        linearGradient: {
            x1: 0,
            y1: 0,
            x2: 0,
            y2: 1
        },
        stops: [
            [0, Highcharts.getOptions().colors[0]],
            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
        ]
    }
}] 

Upvotes: 0

Views: 39

Answers (1)

beaver
beaver

Reputation: 17647

Filter data retrieved from getJson() with array.filter() function:

var start = new Date("4 Dec 2017").getTime();
var end = new Date("25 Dec 2017").getTime();
var filtered = data.filter(function(item, index, arr) {
  if (item[0]>end || item[0]<start) return item;
}, []);

Check fiddle updated: http://jsfiddle.net/beaver71/axxm0fh1/

Upvotes: 1

Related Questions