Eli : Memcached, MySQL, Highcharts

Tag - highcharts

Friday, February 28 2014

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

Tuesday, December 18 2012

Highcharts French Translation Javascript Code

Simple Javascript code to translate the Highchart Tools in french language.
Put this code before calling for a new Highchart graphic

Highcharts French Translation Javascript Code

    Highcharts.setOptions({
        lang: {
            months: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
                          'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
            weekdays: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 
                             'Jeudi', 'Vendredi', 'Samedi'],
            shortMonths: ['Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil',
                                'Aout', 'Sept', 'Oct', 'Nov', 'Déc'],
            decimalPoint: ',',
            downloadPNG: 'Télécharger en image PNG',
            downloadJPEG: 'Télécharger en image JPEG',
            downloadPDF: 'Télécharger en document PDF',
            downloadSVG: 'Télécharger en document Vectoriel',
            exportButtonTitle: 'Export du graphique',
            loading: 'Chargement en cours...',
            printButtonTitle: 'Imprimer le graphique',
            resetZoom: 'Réinitialiser le zoom',
            resetZoomTitle: 'Réinitialiser le zoom au niveau 1:1',
            thousandsSep: ' ',
            decimalPoint: ','
        }
    });

Hope this help.