highcharts中用<%=%>获得一个数组,如何将该数组赋给data呀?????
2个回答
推荐于2016-05-14
展开全部
何必用小脚本呢,直接通过json返回给页面,页面上取出JSON就好了。
给一点代码片段给你
var childObj =
{
getQueTotal:function()
{
$.ajax({
type:"post",
url:contextPath+"/elispay!getQueTotal.do",
dataType:"json",
success:function(result)
{
var json = $.parseJSON(result);
childObj.fillConsumerData(json.xData,json.workData,json.telData,'child-1');
},
error:function(data)
{
}
});
},
fillConsumerData : function(xData,workData,telData,child_id)
{
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: child_id,
type: 'column',
backgroundColor: '#fff',
plotBorderWidth:1,
plotBorderColor:'gray',
margin:[10,10]
},
title: {
text: ''
},
xAxis: {
categories: xData,
labels: {
rotation: -45,
align: 'right',
color:'#bbb',
style: {
fontSize: '13px',
fontFamily: 'Microsoft YaHei,Verdana, sans-serif'
}
}
},
yAxis: {
min: 0,
title: {
text: ''
}
},
legend: {
align: 'right',
x: -100,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
series: [{
name: '工作平台',
data: workData,
color:'#86c021',
dataLabels: {
enabled: true,
rotation: -0,
color: '#3c3c3c',
align: 'center',
x: 0,
y: -10,
formatter: function() {
return this.y;
},
style: {
fontSize: '13px',
fontFamily: 'Microsoft YaHei,Verdana, sans-serif'
}
}
},{
name: '手机平台',
data: telData,
color:'#4572a7',
dataLabels: {
enabled: true,
rotation: -0,
color: '#3c3c3c',
align: 'center',
x: 0,
y: -10,
formatter: function() {
return this.y;
},
style: {
fontSize: '13px',
fontFamily: 'Microsoft YaHei,Verdana, sans-serif'
}
}
}]
});
});
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询