日期:2014-05-16  浏览次数:20357 次

jquery的highcharts插件
jquery的highcharts插件
生成饼状图的源码为:
var chart;

chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'pie',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: '浏览器使用统计分析'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',  
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
我想把页面传过来的两个数组加到到data中,传过来的是两个数组 exprot{'Firefox','IE','Safari','Opera','Others'} values{45.0, 26.8, 12.8, 8.5, 6.2, 0.7},应该怎么写啊

------解决方案--------------------
JScript code
         data: (function () {
                var data = [], i;
                for (i = 0; i < dt.length; i++) {
                    data.push({
                        name: dt[i]["name"],
                        y: dt[i]["y"]
                    });
                    data.push({
                        name: '',
                        y: dt[i]["x"],
                        color: '#FFFFFF'
                    });
                }
                return data;
            })(),