highcharts pie问题!
为什么我让:var dp = "[['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]]";
chart.series[0].setData(dp);
而此饼状图不能正常显示,请用过highcharts的兄弟们告诉我下
为什么我让:var dp = "[['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]]";
chart.series[0].setData(dp);
而此饼状图不能正常显示,请用过highcharts的兄弟们告诉我下
var chart;
$(document).ready(function() {
var dp = [['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]];
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
margin: [50, 200, 60, 170]
},
title: {
text: 'Browser et shares at a specific website, 2010'
},
plotArea: {
shadow: null,
borderWidth: null,
backgroundColor: null
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
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: 'Browser share',
data: dp
}]
});
});
chart.series[0].setData(dp);
把字符串类型转变成[['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]]
var dp = [['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]];
var picchart;
var options = {
chart: {
renderTo: 'pieinfo',
margin: [100, 0, 0, 0],
plotBackgroundColor: 'none',
plotBorderWidth: 0,
plotShadow: false
},
title: {
text: 'Browser et shares at a specific website'
},
plotArea: {
shadow: null,
borderWidth: null,
backgroundColor: null
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.point.name +': '+ this.y +' %';
}
},
legend: {
enabled: false
},
series: [],
dataLabels: {
enabled: true,
formatter: function() {
if (this.y > 2) return this.point.name;
},
color: 'white',
style: {
font: '13px Trebuchet MS, Verdana, sans-serif'
}
}
};
result = [];
result.push({name: 'Firefox', y: 44.2});
result.push({name: 'liufang', y: 21});
result.push({name: 'jet', y: 5});
result.push({name:'Safari',y:8.5});
result.push({name:'Opera',y:6.2});
result.push({name:'Others',y:0.7});
options.series.push({
type: 'pie',
name: '2008',
size: '100%',
data: result
});
piechart = new Highcharts.Chart(options);
var dp = [['河南省',97.42],['山东',1.59],['河南省',0.53],['湖北省',0.23],['湖南省',0.23],['m',0]];
就可以了,没办法,用了最笨的方法,一个一个赋值的,哎