开发者

highcharts - variable data causes browser lockup

开发者 https://www.devze.com 2023-01-06 14:28 出处:网络
I am attempting to use the highcharts javascript library to load charts using this function: function create_chart(success, failed, pending)

I am attempting to use the highcharts javascript library to load charts using this function:

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>: '+ 开发者_如何学JAVAthis.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]
                ]
            }]
    });
}

however this locks the browser up

i have narrowed down the problem to

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

as if i use numbers in place of the variables (i.e replace success with 12 ect) then it works fine

this is confusing as using console.log(success) returns 12, so what could be causing this?


try

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

lets see if this does a thing...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号