本文介绍了HighSet,chart.series [0] .data在afterSetExtremes()中为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我已经设置了一个小提琴,它允许您移动highstock导航器并查看所选时间的下方加上所选时间段的所有值。 http://jsfiddle.net/o8dLh3m5/3/ 我遇到的问题是,当选择包含太多数据时,chart.series [0] .data数组为空,所以我无法计算总数。 有人可以解释发生了什么事(例如,这个阈值是在哪里设定的?),当返回的数据大于阈值时,我有什么选择来计算总数? 预先感谢, xAxis:{类型:'datetime',事件:{ afterSetExtremes:function(event){ //转换为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')); //获得总计 var sum = 0,chartOb = this; $ .each(chartOb.series,function(series_id){ $ .each(chartOb.series [series_id] .data,function(i,point){ //返回的数组是空的! 解决方案点的数量超过了cropThreshold,那么数组可以是空的,我认为使用 series.processedYData 来计算总和会更好,这只是一个真正显示y的数组注::它不是官方API的一部分,但可以使用;) $($) b $ bI 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! 解决方案 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 ;) 这篇关于HighSet,chart.series [0] .data在afterSetExtremes()中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-01 00:17