I am drawing a chart from a url like this:
var defaultUrl = 'http://ammiller-lnx:8080/sonarChartData/data1;
var query = new google.visualization.Query(defaultUrl);
query.send(handleQueryResponse);
etc...
Now, I added a button and I want the chart data to be refreshed from a
different url.
I tried (onclick of the button)
query.setQuery('http://ammiller-lnx:8080/sonarChartData/data2');
query.send(handleQueryResponse);:
But when I get the data response (var data = response.getDataTable();)
it still has the data from the first url.
What am I doing wrong here?
Amir.
<!--
You are free to copy and use this sample in accordance with the terms
of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['table']});
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
var visualization;
var defaultUrl = 'http://ammiller-lnx:8080/sonarChartData/data1?
tqx=reqId:1';
var query = new google.visualization.Query(defaultUrl);
function drawVisualization() {
// Send the query with a callback function.
query.send(handleQueryResponse);
}
function setQuery(queryUrl) {
query.setQuery(queryUrl);
query.send(handleQueryResponse);
//drawVisualization();
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' +
response.getDetailedMessage());
return;
}
var data = response.getDataTable();
//alert('S1:' + data.G[data.G.length-1].c[1].v + ' S2:' +
data.G[data.G.length-1].c[2].v + ' S3:' +
data.G[data.G.length-1].c[3].v + ' S4:' +
data.G[data.G.length-1].c[4].v + ' S5:' +
data.G[data.G.length-1].c[5].v +' Total' +
data.G[data.G.length-1].c[6].v);
visualization = new
google.visualization.ComboChart(document.getElementById('visualization'));
var options = {
width: 470,
height: 250,
seriesType: "bars",
isStacked: true,
colors:
['#3266CC','#DC3910','#DB8E1C','#109619','#990099','#0099C5','#DD4578','#66AA00'],
series: {5: {type: "line"},6: {type: "line"},7: {type:
"line"}}
};
visualization.draw(data, options);
}
function drawChart() {
}
google.setOnLoadCallback(drawVisualization(defaultUrl));
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<input type="button" value="Go" onclick="setQuery('http://ammiller-
lnx:8080/sonarChartData/data2?tqx=reqId:2')"/>
<div id="visualization" style="height: 400px; width: 400px;"></
div>
</body>
</html>
On Dec 5, 4:56 pm, asgallant <drew_gall...@abtassoc.com> wrote:
> Can you post your javascript?