-1

我正在尝试使用 highcharts javascript 库来使用此函数加载图表:

function create_chart(success, failed, pending)
{
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'graph',
            margin: [5, 5, 5, 5]
        },
        title: {
            text: 'Message Sending Status'
        },
        plotArea: {
            shadow: null,
            borderWidth: null,
            backgroundColor: null
        },
        tooltip: {
            formatter: function() {
                return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
            }
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                dataLabels: {
                    enabled: true,
                    formatter: function() {
                        if (this.y > 5) return this.point.name;
                    },
                    color: 'white',
                    style: {
                        font: '13px Trebuchet MS, Verdana, sans-serif'
                    }
                }
            }
        },
        legend: {
            layout: 'vertical',
            style: {
                left: 'auto',
                bottom: 'auto',
                right: '50px',
                top: '100px'
            }
        },
        series: [{
                type: 'pie',
                name: 'Message Status',
                data: [
                    ['Successful Messages',   success],
                    ['Failed Messages',       failed],
                    ['Pending Messages',       pending]
                ]
            }]
    });
}

但是这会锁定浏览器

我已将问题缩小到

data: [
   ['Successful Messages',   success],
   ['Failed Messages',       failed],
   ['Pending Messages',       pending]
]

好像我用数字代替变量(即用 12 等替换成功)然后它工作正常

这很令人困惑,因为使用 console.log(success) 返回 12,那么可能是什么原因造成的呢?

4

1 回答 1

0

尝试

data: [
   ['Successful Messages',   success - 0],
   ['Failed Messages',       failed - 0 ],
   ['Pending Messages',      pending - 0]
]

让我们看看这是否有用......

于 2010-07-06T05:01:46.757 回答