score:1

Accepted answer

the issue is the use of this.x here:

for (i = 0; i < 4; i++) {
    sum += series[i].ydata[this.x];
}

for "normal" x-axis types this works well since you can open the ydata by index. in your case it will end up trying to find something like series[0].ydata[1262304000000], which won't work.

i'm not aware of any easy way to find the relationship between the timestamp this.x and which index that has on the x-axis. my solution uses another for loop to compare the timestamp from this.x with the xdata array, and if it matches we use the data in the sum, as shown in this updated formatter:

formatter: function () {
    // if doing negative, ignore
    if(this.total <= 0)
        return;

    var sum = 0;
    var series = this.axis.series;

    for (var i = 0; i < series.length; i++){
        for(var j = 0; j < series[i].xdata.length; j++) {
            if(series[i].options.type == 'column' && series[i].xdata[j] == this.x) {
                sum += series[i].ydata[j];
                break;
            }
        }
    }

    return sum;
}

this updated jsfiddle shows it in action.

score:1

if i understand what you're asking for correctly, the following formatter function should work:

        formatter: function () {
            return this.total >= 0 ?this.total : null ;
        },

http://jsfiddle.net/ath7f/1/

as to the available options in the formatter function, http://api.highcharts.com/highcharts#plotoptions.column.datalabels.formatter should help. but, i tend to just put a breakpoint in the function and inspect what this is. :)


Related Query

More Query from same tag