Highstocks, chart.series[0].data is empty in afterSetExtremes()

心不动则不痛 提交于 2019-12-24 10:31:14

问题


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:


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 ;)



来源:https://stackoverflow.com/questions/26510307/highstocks-chart-series0-data-is-empty-in-aftersetextremes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!