0

I am having issue on loading json Data from a table to highchart.js column type. I tried to load the JSON to JavaScript object and access them like : y: chartvals.projects but I got this error message:

Uncaught Highcharts error #14: www.highcharts.com/errors/14

what I have is this ajax call and highchart snippet:

var req2 = $.ajax({
    type: "POST",
    data: data,
    dataType: 'json',
    url: "assets/tempchart.php"
});
req2.done(function(data) {
    var chartvals = data;
    $('#chart1').highcharts({
        chart: {
            type: 'column'
        },
        credits: {
            enabled: false
        },
        title: {
            text: 'Economy Model',
            style: {
                color: '#5882FA',
                fontWeight: 'normal',
                fontSize: '11',
                marginBottom: '30'
            }
        },
        xAxis: {
            categories: ['Total Projects']
        },
        yAxis: {
            tickInterval: 50,
            max: 800
        },
        legend: {
            enabled: false
        },
        tooltip: {
            formatter: function() {
                return this.x +
                        ' is <b>' + this.y + '</b>';
            }
        },
        series: [{
                data: [{
                        name: 'Point 1',
                        color: '#00FF00',
                        y: chartvals.projects
                    }]
            }]
    });
});

Can you please let me know how to fix this? Thanks

Update

Here is the Response JSON

{"project":"8","powerline":"188.396496","road":"7.876766","cost":"69885005.45"}
user3668817
  • 63
  • 2
  • 8

1 Answers1

0

This error comes when string value is sent to series.data, but it expects number. This happens if you pass in a string as a data point.

HightCharts Error # 14

Highcharts expects the data values to be numbers. The most common reason for this is that data is parsed from CSV or from a XML source, and the implementer forgot to run parseFloat on the parsed value.

For performance reasons internal type casting is not performed, and only the first value is checked (since 2.3).

Community
  • 1
  • 1
Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160