Search code examples
javascriptarraysjsonhighcharts

Highcharts series value is different from a Data Source


I have a problem with Highcharts where the value of this.y does'nt represent the value of my data source. It looks like the picture below. I don't if this is a bug or not.

Screenshot of Error

This is my Demo : https://jsfiddle.net/xzjrkf1d/

And this is my Highcharts code

Highcharts.chart('ChartNational', {
chart: {
    type: 'waterfall'
},
title: {
    text: 'Company'
},
xAxis: {
    type: 'category'
},
yAxis: {
    labels: {
        formatter: function () {
            if (FilterValueType == "Full Amount") {
                var val = nFormatter(this.value);
                return val;
            } else {
                return Highcharts.numberFormat(this.value, 0, '.', ',');
                //return this.value;
            }
        }
    },
    title: {
        text: 'Value'
    },
    min: YAxisCel
},
legend: {
    enabled: false
},
tooltip: {
    pointFormat: '<b>{point.y}</b>',
    enabled: false
},
series: [{
    upColor: Highcharts.getOptions().colors[2],
    color: Highcharts.getOptions().colors[3],
    data: resultData,
    dataLabels: {
        enabled: true,
        formatter: function () {
            debugger
            if (FilterValueType == "Full Amount") {
                var val = nFormatter(this.y);
                return val;
            } else {
                return Highcharts.numberFormat(this.y, 0, '.', ',');
            }

            //return this.y;;
            //return Highcharts.numberFormat(this.y, 0, ',');
        },
        style: {
            fontWeight: 'bold'
        }
    },
    pointPadding: 0
}]

});

I expecting the same value of this.y as my Data Source


Solution

  • Guys i found the issue.

    that is because i set the value of my last array isSum = true so i simpy change the value to false and this.y value now the same with my data

    OLD

    {
        "name": "Total Compare",
        "type": "FFI",
        "orderBy": 9,
        "total_main": 0,
        "total_compare": 0,
        "y": 1664.691438,
        "color": "Blue",
        "isSum": true
    }
    

    FIXED

    {
        "name": "Total Compare",
        "type": "FFI",
        "orderBy": 9,
        "total_main": 0,
        "total_compare": 0,
        "y": 1664.691438,
        "color": "Blue",
        "isSum": false
    }