highcharts - 可变数据导致浏览器锁定 [英] highcharts - variable data causes browser lockup

查看:138
本文介绍了highcharts - 可变数据导致浏览器锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数create_chart(成功,失败,失败,待定)
{
var chart = new Highcharts.Chart({
图表:{
renderTo:'图表',
保证金:[5,5,5, 5]
},
标题:{
文本:'消息发送状态'
},
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)返回this.point.name;
},
color:'white',
style:{
font:'13px Trebuchet MS,Verdana,sans-serif'
}
}
}
},
图例:{
layout:'vertical',
style:{
left:'auto',
bottom :'auto',
右:'50px',
top:'100px'
}
},
系列:[{
type:' '
''消息状态',
数据:[
['成功消息',成功],
['失败消息',失败],
['等待消息',等待中]
]
}]
});
}

然而,这会锁定浏览器



我已将问题缩小至

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

就好像我用数字代替变量(即用12等取代成功)
那么它工作正常



<这是令人困惑的,因为使用console.log(成功)返回12,所以这可能是什么原因造成的?

 数据:[
['Successful Messages',success - 0],
''Failed Messages' ,失败 - 0],
['Pending Messages',pending - 0]
]

让我们看看这是否做了一件事......


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

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...

这篇关于highcharts - 可变数据导致浏览器锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆