当前位置: 动力学知识库 > 问答 > 编程问答 >

Google gauge chart is not displaying

问题描述:

Hi I am trying Display the Gauge chart By using JSON data but I am getting the following error' this IS my error:

Please help how to solve this

Uncaught TypeError: undefined is not a function

Can any one help me

This my JSON output

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

Here my code

<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>

分享给朋友:
您可能感兴趣的文章:
随机阅读: