Eli : Memcached, MySQL, Highcharts

Summing Graph Data by Series in Highcharts/Highstocks

How to Sum series in Highcharts & Highstocks

This quick code will do the trick and add a nice sum of all series values in the legend label for each series

legend: {
enabled: true,
labelFormatter: function() {
var count = 0;
for (var i = 0 ; i < this.yData.length; i++) {
count += this.yData[i];
}
return this.name + ' [' + count + ']';
}
}

Quick explanation of Highcharts legend parameters

labelFormatter : function() { } : called by Highcharts to make legend label, for each item, return the text for the legend builder.
this.yData : contains series data, in a Javascript array.
this.name : series label, defined in the series array on your chart definition.

Hope this help

Related Posts





comments powered by Disqus

You may also be interested in