Stig Eide
Stig Eide

Reputation: 1062

Only first N datapoints should be used

I have several 100 data points (type: 'scatter3d'). I do not like how the zoom works, so I would like to change the number of data points that are being used, for example only the first 10. The axis should adjust accordingly. Is this possible?

Upvotes: 0

Views: 18

Answers (1)

ppotaczek
ppotaczek

Reputation: 39099

You just need to provide the proper data to the chart. For example:

    var data = [
        ...
    ];

    var chart = new Highcharts.Chart({
        ...,
        series: [{
            colorByPoint: true,
            data: data.slice(0, 10)
        }]
    });

    document.getElementById('first').addEventListener('click', function() {
        chart.series[0].setData(data.slice(0, 10));
    });

    document.getElementById('next').addEventListener('click', function() {
        chart.series[0].setData(data.slice(10, 20));
    });

Live demo: https://jsfiddle.net/BlackLabel/9aruwzpd/

API Reference: https://api.highcharts.com/class-reference/Highcharts.Series#setData

Upvotes: 1

Related Questions