当前位置: 代码迷 >> Java Web开发 >> highcharts解决办法
  详细解决方案

highcharts解决办法

热度:7063   发布时间:2016-04-10 22:33:53.0
highcharts
我在action中拼接series数据public String getInfo(){
List<AttentionReport> list=homePageService.getInfo(year, month);

StringBuffer sb=new StringBuffer();
sb.append("[{name: '关注数',data:[");
for(AttentionReport c:list){
sb.append(c.getAttentionNumber());
sb.append(",");
}
sb.append("'']},{name:'取消关注数',data:[");
for(AttentionReport c:list){
sb.append(c.getUnfollowNumber());
sb.append(",");
}
sb.append("'']},{name:'净增长数',data:[");
for(AttentionReport c:list){
sb.append(c.getAttentionNumber()-c.getUnfollowNumber());
sb.append(",");
}
sb.append("'']}]");
System.out.println(sb.toString());
/*for(AttentionReport c:list){
System.out.println(c.getAttentionNumber()+","+c.getUnfollowNumber()+","+c.getTime());
}*/
HttpServletRequest request=ServletActionContext.getRequest();
request.setAttribute("sb", sb);
return SUCCESS;
}
返回给jsp页面通过request获取<input type="hidden" value="<%=request.getAttribute("sb")%>" id="sb"/>
最后将数据给series
$(function () {
   $('#basic_line_test').highcharts({
        title: {
            text:'用户关注报告',
            x: -20 //center
        },
        subtitle: {
        },
        xAxis: {
            categories: []
        },
        yAxis: {
            title: {
                text: '关注次数'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: '次'
        },
        credits: { 
         enabled: false 
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: document.getElementById("sb").value
    }); 问什么没有显示
------解决方案--------------------
1、json格式拼写错误

2、页面js错误

先看看报什么错吧~~ 

页面:打开浏览器的开发者选项 看一下!
后台:打个断电看看json有没有问题
  相关解决方案