Highcharts系列不显示数据也不显示图表

时间:2018-08-12 13:36:58

标签: javascript highcharts

我有以下数组,可用于绘制带有高脚椅的饼图

enter image description here

这是我的代码

var dataChart = [];
    function getData() 
    {
        return $.get('/report/charts-top-10-claimant')
        .done(function(data) {
            for (var i=0; i<data.length; i++) {
                dataChart.push(data[i]);
            }
        });
    }

    getData();

    $(function() {

            console.log(dataChart);

        $('#test').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                type: 'pie'
            },
            title: {
                text: ''
            },
            tooltip: {
                pointFormat: '{point.y} <b>({point.percentage:.1f}%)</strong>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</strong>: {point.y} ({point.percentage:.1f}%)',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                colorByPoint: true,
                data: []
            }]
        });



        $('#claimant-by-amount').on('click', function(e) {

            var chart = $('#test').highcharts();
            chart.series[0].setData(dataChart);
        });
});

加载页面并检查错误控制台后,提示“未捕获的Highcharts错误#14:www.highcharts.com/errors/14”。怎么了,请帮帮我

1 个答案:

答案 0 :(得分:1)

如果您在控制台中单击错误,则应将您重定向到:

https://www.highcharts.com/errors/14

清楚地说明了问题所在。

当需要数字时,您的y值是字符串。

相关问题