Highstocks, chart.series[0].data is empty in after

2019-08-06 08:30发布

I have set up a fiddle which allows you to move the highstock navigator and see underneath the times selected plus a sum of the values for the selected period.

http://jsfiddle.net/o8dLh3m5/3/

The problem I am having is that when the selection contains too much data, the chart.series[0].data array is empty so I can't calculate the total.

Could someone please explain what is happening (ie where is this threshold set?), and what are my options for calculating totals when the data returned is larger than the threshold.

Thanks in advance,

xAxis:{
    type: 'datetime',
        events: {
            afterSetExtremes:function(event){

                // convert to dd/mm/yyyy hh:mm
                var start_date = new Date(event.min);
                var end_date = new Date(event.max);
                $('#id_start_date').text( moment(start_date).format('DD/MM/YYYY HH:mm') ); 
                $('#id_end_date').text( moment(end_date).format('DD/MM/YYYY HH:mm') ); 

                // get totals
                var sum = 0, chartOb = this;

                $.each(chartOb.series, function(series_id){

                    $.each(chartOb.series[series_id].data, function(i,point){
                    // array returned is empty!

1条回答
在下西门庆
2楼-- · 2019-08-06 09:20

When number of points exceeds cropThreshold, then array can be empty. I think it would be better to use series.processedYData to calculate that sum. That is just an array with actually displayed y-values on a chart in one series.

Note: It's not part of official API but can be used ;)

查看更多
登录 后发表回答