Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从MySQL JSON输出呈现Highchart时出现问题_Javascript_Php_Jquery_Json_Highcharts - Fatal编程技术网

Javascript 从MySQL JSON输出呈现Highchart时出现问题

Javascript 从MySQL JSON输出呈现Highchart时出现问题,javascript,php,jquery,json,highcharts,Javascript,Php,Jquery,Json,Highcharts,我在将json数据从表加载到highchart.js列类型时遇到问题。我尝试将JSON加载到JavaScript对象并像:y:chartvals.projects那样访问它们,但收到以下错误消息: 未捕获的Highcharts错误14:www.Highcharts.com/errors/14 我得到的是这个ajax调用和highchart片段: var req2 = $.ajax({ type: "POST", data: data, dataType: 'json',

我在将json数据从表加载到highchart.js列类型时遇到问题。我尝试将JSON加载到JavaScript对象并像:y:chartvals.projects那样访问它们,但收到以下错误消息:

未捕获的Highcharts错误14:www.Highcharts.com/errors/14

我得到的是这个ajax调用和highchart片段:

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
                    }]
            }]
    });
});

当字符串值被发送到series.data时会出现此错误,但它需要数字。 如果将字符串作为数据点传入,则会发生这种情况

Highcharts期望数据值是数字。最常见的原因是数据是从CSV或XML源解析的,而实现者忘记对解析的值运行parseFloat

出于性能原因,不执行内部类型转换,仅检查自2.3以来的第一个值


谢谢Ehsan,但是解决方案呢?你知道如何解决这个问题吗?你必须传递整数值而不是字符串。你能在帖子中发布回复json吗?在y:chartvals.projects-Data for series中发布json回复。是
{"project":"8","powerline":"188.396496","road":"7.876766","cost":"69885005.45"}