Hi,

I'm afraid, i'm not a expecialist in json programmer, but i need to
construct a same chart with sensistive data. I want to use javascript
to this, but i have the data from a mysql php query... anibody have an
example for this case? I think for my case i don't use datasource
ready i'm like to create my datasource (rsrsrs but i don't now
how....). Please if anibody think this is a stupid idea telme....
Thanks.....


On 19 maio, 09:29, asgallant <[email protected]> wrote:
> If you don't want to create a data source to Google's specs, you can
> implement your own (just don't expect it to be compatible with anything
> anyone else does).  Set up an AJAX query (I like jQuery for this):
>
> // form is the js object for the form you are submitting
> function submitQuery (form) {
>
> var data = $(form).serialize();
>
> $.ajax({
>
> data: data,
>
> url: "path/to/source.php",
>
> method: "POST", // or method: "GET"
>
> success: function (json) {
>
> drawChart(json);
>
> }
> });
> }
>
> // drawChart takes the json and builds the data table with it
> function drawChart(json) {
>
> var data = new google.visualization.dataTable(json);
> var chart = new
> google.visualization.<chartType>(document.getElementById("chart_div");
> chart.draw(data, <options>);
>
> }
>
> then in your source php, query MySQL, build a json string out of your data
> (formatted for you chart), and echo it, with the "Content-type:
> application/json" header:
> <?php
>
> header("Content-type: application/json");
>
> // $json hold the json string
>
> echo $json;
> exit;
>
> ?>
>
> Information on the format of the JSON is 
> here:http://code.google.com/apis/chart/interactive/docs/dev/implementing_d...

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