谷歌计量表未显示

时间:2013-09-23 13:10:20

标签: google-visualization

您好我正在尝试显示Gauge图表通过使用JSON数据,但我收到以下错误'这是我的错误: 请帮忙解决这个问题

Uncaught TypeError: undefined is not a function 

任何人都可以帮助我

这是我的JSON输出

{"cols":[{"label":"Q7","type":"number"},{"label":"Q8","type":"number"}],"rows":[{"c":[{"v":43},{"v":21}]}]}

这是我的代码

<html>
    <!--Load the AJAX API -->
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
          google.load('visualization', '1', {packages:['gauge']});
        </script>
        <script type="text/javascript">
          function drawGauge()  {


            var response = '<?php echo json_encode($response); ?>';     alert(' hi ' + response);            
            var obj = eval ("(" + response + ")");  


                // create a grid for the chart
                //options.chg = '25.0,25.0,4.0,4.0';


                var dataTable = new google.visualization.DataTable(response);



                var chart = new google.visualization.ImageChart(document.getElementById('visualization'));
               var gaugeOptions = {
                            min: 0,
                            max: 280,
                            yellowFrom: 200,
                            yellowTo: 250,
                            redFrom: 250,
                            redTo: 280,
                            minorTicks: 5
                        };
                chart.draw(dataTable, gaugeOptions);

               }

          google.setOnLoadCallback(drawGauge);
        </script>
      </body>

     <body style="font-family: Arial;border: 0 none;">
        <div id="visualization" style="width: 600px; height: 300px;"></div>
      </body>
    </html>

0 个答案:

没有答案