问题
How Can I sum the points in a line within a selected range in order to be shown to users?
回答1:
Yes it is possible, by means of using afterSetExtremes function (http://api.highcharts.com/highstock#xAxis.events.afterSetExtremes) which allows to catch "change" range event and run custom function. So then you can interate for all points in serie and limit which of them should be added to sum, by check min/max range value.
http://jsfiddle.net/2WdQw/
afterSetExtremes: function(e) {
var sum = 0,
chartOb = this;
$.each(chartOb.series[0].data,function(i,point){
if(point.x >= chartOb.min && point.x <= chartOb.max)
sum += point.y;
});
$('#report').html('Sum: '+sum);
}
来源:https://stackoverflow.com/questions/14176459/highstock-how-programmatically-sum-selected-values-and-show-the-sum-to-user