Hi,

To help us debug, please try this example without the server, i.e., with the
string embedded into the javascript code:
var mockResponse = '{cols: ...
and let me know if the bug persists. If it does please try to provide a
minimalist code example as possible to avoid other bugs in the rest of the
code.
Then I can try to help you debug.

Regards,
    VizBoy.

On Tue, Jun 2, 2009 at 1:47 AM, Bob <[email protected]> wrote:

>
> Hello,
>
> I am using the google-visualization-java api, I am having issues
> rendering a line chart in java and could use some assistance.  Here is
> the page that is sending data to the server.  (I am using prototype to
> send the request.)  At the bottom of the message is the data returned
> from the server.  Any help would be appreciated.
>
> I have tried using the google sandbox to generate the graph and am
> able to do so without issue.  Thanks in advance.
>
> Bob
>
> <HTML>
> <HEAD>
> <TITLE>Charts</TITLE>
> <SCRIPT SRC="/MyServlet/js/prototype.js"></SCRIPT>
> <SCRIPT SRC="/MyServlet/js/scriptaculous.js"></SCRIPT>
> <script type="text/javascript" src="http://www.google.com/jsapi";></
> script>
>
> <script type="text/javascript">
>        var firstTime = true;
>        //Load the Visualization API and the ready-made Google table
> visualization
>        google.load("visualization", "1", {
>                packages : [ "linechart" ]
>        });
>        // Set a callback to run when the API is loaded.
>        google.setOnLoadCallback(init);
>
>        // Send the query to the data source.
>        function init() {
>        }
>
>        function invoke(form, event) {
>                if (!form.onsubmit) {
>                        form.onsubmit = function() {
>                                return false
>                        }
>                }
>                var params = Form.serialize(form, {
>                        submit : event
>                });
>                console.log("params: " + params);
>                new Ajax.Request(form.action, {
>                        method : 'post',
>                        parameters : params,
>                        onSuccess : processSuccess
>                });
>        }
>
>        function processSuccess(xhr) {
>                var data = xhr.responseText;
>                var length = data.length;
>                var index = data.lastIndexOf("{cols:");
>                data = data.substring(index, length - 3);
>                console.log("data: " + data);
>                var dataTable = new google.visualization.DataTable(data,
> 0.6);
>                new
> google.visualization.LineChart($('chart_div')).draw(data, {
>                        width : 400,
>                        height : 240,
>                        legend : 'bottom',
>                        title : 'Company Performance'
>                });
>        }
> </script>
> </HEAD>
> <BODY class="yui-skin-sam">
> <form id="revenue" action="/MyServlet" method="post">
>
>
>        <div>Property: <input name="property" type="text" /><br />
>
>        Product: <input name="Product" type="text" /></div>
>        <div>Start time: <input name="startDate" value="1234" type="text" />
> <br />
>        </div>
>        <div>End time: <input name="endDate" value="1234" type="text" /> <br
> /
> >
>        </div>
>        <div id="values"><select name="selectedProducts"
> multiple="multiple">
>
>                <option value="49">name2</option><option value="47">name2</
> option><option value="34">name0</option><option value="42">name1</
> option><option value="43">name1</option><option value="37">name0</
> option><option value="32">name0</option><option value="46">name2</
> option><option value="44">name2</option><option value="40">name1</
> option><option value="38">name1</option><option value="45">name2</
> option><option value="35">name0</option><option value="36">name0</
> option><option value="41">name1</option><option value="48">name2</
> option><option value="33">name0</option><option value="39">name1</
> option>
>
>        </select></div>
>        <input name="generateChart" value="generateChart" onclick="invoke
> (this.form, this.name);" type="submit" />
> </form>
> <div id='Charts'>
> <div id='chart_div'></div>
> </div>
> </BODY>
> </HTML>
>
> Data returned from server.
> {cols:[{id:'date',label:'Date',type:'string',pattern:''},
> {id:'a',label:'A',type:'number',pattern:''},
> {id:'b',label:'B',type:'number',pattern:''},
> {id:'c',label:'C',type:'number',pattern:''},
> {id:'d',label:'D',type:'number',pattern:''},
> {id:'e',label:'E',type:'number',pattern:''},
> {id:'f',label:'F',type:'number',pattern:''}],rows:[{c:[{v:'0'},{v:
> 15016.3126220703},{v:16399.1228027344},{v:13416.8115234375},{v:
> 22230.9321289062},{v:21288.5932617188},{v:18679.0187988281}]},{c:
> [{v:'1'},{v:14032.5787353516},{v:7370.62826538086},{v:
> 25648.6225585938},{v:14541.0964355469},{v:12641.0971679688},{v:
> 17808.7253417969}]},{c:[{v:'2'},{v:15599.0372810364},{v:
> 14065.6091308594},{v:13446.4102172852},{v:14674.8068847656},{v:
> 5343.62072753906},{v:17071.8499755859}]},{c:[{v:'3'},{v:
> 15737.1694335938},{v:14526.9857788086},{v:16414.8510742188},{v:
> 13371.9372558594},{v:28145.298828125},{v:21964.7421875}]}]}
>
> >
>

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