DragonWar% 2014-07-28 13:57 采纳率: 0%
浏览 7

高图未执行

I have used highchart to draw pie chart.I got the ajax response but my chat is not executed.I had put the alert also but alert("highchart called"); is not executed till that line my all alert is executed.I think options.series[0].data = responsePIE; is wrong but not sure. My main12.js code is as below.

$(document).ready(function()
{

    $(function () 
       {

           $('#container').highcharts(
                {
                   chart:
                   {
                        plotBackgroundColor: null,
                        plotBorderWidth: 1,//null,
                        plotShadow: false
                   },
                   title: 
                   {
                        text: 'Browser market shares at a specific website, 2014'
                   },
                   tooltip:
                   {
                        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                   },
                   plotOptions: 
                   {
                        pie: 
                           {
                             allowPointSelect: true,
                             cursor: 'pointer',
                              dataLabels:
                              {
                                enabled: true,
                                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                                style: 
                                 {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                 }
                              }
                           }
                     },

        series: [{
            type: 'pie',
            name: 'Browser share',
            data: []
        }]
    });
});

$.getJSON("GetReportdata", function(json) {

    var call11 = JSON.stringify(json);
    alert(call11);
    var responsePIE = jQuery.parseJSON(call11);
    alert(responsePIE[1].title);

    options.series[0].data = responsePIE;
    alert("highchart called");

    var chart = new Highcharts.Chart(options);
});


        });

My jsp code is as below.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="../css/demo.css" rel="stylesheet">
<script src="../js/jquery.js"></script>
<script src="../external js/jquery-1.9.1.js"></script> 
<script src="../external js/jquery-ui.js"></script>


</head>
<body>



<script src="../js/highcharts.js"></script>
<script src="../js/exporting.js"></script>
<script src="../js/main12.js"></script>



<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
<div id="container2" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>



</body>
</html>

Thanks

  • 写回答

2条回答 默认 最新

  • weixin_33735077 2014-07-28 15:01
    关注

    It looks like this line is wrong:

    options.series[0].data = responsePIE;
    

    in that you haven't defined options.

    Either set an options variable to the full chart definition and create the chart in the getJson callback, or create the chart first, and then set the series data on the exinsting chart in the getJson callback using the series setData() method (http://api.highcharts.com/highcharts#Series.setData).

    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口