highcharts中用<%=%>获得一个数组,如何将该数组赋给data呀?????

 我来答
匿名用户
推荐于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'
                       
                    }
                }
}]
        });
    });
}
    }
orchield
2014-05-08 · TA获得超过140个赞
知道小有建树答主
回答量:242
采纳率:0%
帮助的人:207万
展开全部
直接 data: <%= [1,2,3] %>这不就行了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式