首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery的highcharts插件解决办法

2012-04-14 
jquery的highcharts插件jquery的highcharts插件生成饼状图的源码为:var chartchart new Highcharts.Cha

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;            })(), 

热点排行