Hello,

I have been having some trouble with ChartWrapper and a custom data
source url.  I poked around on this list and elsewhere and didn't see
anything that quite matched my experience so I am hoping someone could
offer me some pointers.  I have used the gviz_api.py python module

http://code.google.com/apis/chart/interactive/docs/dev/gviz_api_lib.html

to create a JSON response:

google.visualization.Query.setResponse({'version':'0.6', 'reqId':'0',
'status':'OK', 'table': {cols:
[{id:'latency',label:'latency',type:'string'},
{id:'count',label:'count',type:'number'}],rows:[{c:[{v:'-inf'},{v:
385.0}]},{c:[{v:'15.0'},{v:2319258.0}]},{c:[{v:'25.0'},{v:4781117.0}]},
{c:[{v:'35.0'},{v:223345.0}]},{c:[{v:'45.0'},{v:135157.0}]},{c:
[{v:'55.0'},{v:108485.0}]},{c:[{v:'65.0'},{v:118934.0}]},{c:
[{v:'75.0'},{v:85136.0}]},{c:[{v:'85.0'},{v:19281.0}]},{c:[{v:'95.0'},
{v:17479.0}]},{c:[{v:'105.0'},{v:10407.0}]},{c:[{v:'115.0'},{v:
16392.0}]},{c:[{v:'125.0'},{v:11487.0}]},{c:[{v:'135.0'},{v:13664.0}]},
{c:[{v:'145.0'},{v:575.0}]},{c:[{v:'155.0'},{v:0.0}]},{c:[{v:'165.0'},
{v:0.0}]},{c:[{v:'175.0'},{v:0.0}]},{c:[{v:'185.0'},{v:0.0}]},{c:
[{v:'195.0'},{v:0.0}]},{c:[{v:'inf'},{v:0.0}]}]}});

and I have saved this to a file on my web server named latency.txt.  I
am having difficulty interacting with this as a data source url.  I
observe the following behavior.

1) If I include a single ChartWrapper that sets the dataSourceUrl to
'latency.txt' it mostly works. The chart is displayed.  It does *not*
refresh and it sometimes does not even reload properly when the entire
page is reloaded.
2) If I try to make two ChartWrappers from the same source (or any
similar source on my web sever) then only one is displayed.
3) If I have a single chart and try to use the Chart Editor then one
of two things happens
 a) If I have the page load by first bringing up the chart editor it
works, but any attempt to draw the chart on the page after clicking
'ok' fails.
 b) If I have the page load by first drawing the chart then the chart
is drawn, but if I click on a button to open a chart editor the chart
editor displays but then just spins as if it cannot access the chart
data.

My main question is, should this work at all (providing a static JSON
response in a file on the server)?  If so, what could be going
wrong?

I have tried this on both firefox and chrome.  I have pasted my html
below for example 3b).  Any suggestions would be highly appreciated.

best wishes

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
        <meta http-equiv="PRAGMA" content="NO-CACHE">
        <title>
        gstlal viz
        </title>
        <script type="text/javascript" src="http://www.google.com/
jsapi"></script>
        <script type="text/javascript" src='https://www.google.com/
jsapi?autoload={"modules":[{"name":"visualization","version":"1"}]}'></
script>
        <script type="text/javascript">google.load('visualization',
'1.0', {packages: ['charteditor']});</script>
        <script type="text/javascript">

var wrapper = new google.visualization.ChartWrapper({
           'chartType':'LineChart'
           });

var chartEditor = new google.visualization.ChartEditor();

google.visualization.events.addListener(chartEditor, 'ok',
update_chart);

function draw() {
        wrapper.setDataSourceUrl('latency.txt');
        wrapper.draw(document.getElementById('vis_div'));
        }

function update_chart() {
        wrapper = chartEditor.getChartWrapper();
        draw();
        }

function loadEditor() {
        chartEditor.openDialog(wrapper, {});
        }

google.setOnLoadCallback(draw);

        </script>

</head>
<body face="Arial">
        <table border="10" cellpadding="1">
                <tr><td><div id="vis_div" style="height: 250px; width:
400px;"></div></td><tr>
                <tr><td onClick="loadEditor()"><i>This is a table
caption</i></td></tr>
        </table>
</body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to