thanks im gona try it rigth now, it looks way too easier!!!... On Wednesday, August 29, 2012 3:34:05 PM UTC-6, asgallant wrote: > > Here's an example that is a bit easier to follow: > https://groups.google.com/d/msg/google-visualization-api/GK0zwNbIwUo/i9DhpOUSKMEJ > > $table['cols'] is an array of arrays, where each sub-array is a column > definition with "type" and "label" members. Create one sub-array for each > column in your data set. > > In the while loop, you need to add one element to $temp for each column > (in the same order as your column definitions above). Each element here is > an array with one or two members: "v" (mandatory) is the value of the data > point, and "f" (optional) is a string-formatted value for the data point. > The value is used for all calculations, and the formatted value is used > whenever the data is output (ie, in a tooltip). If you leave out the > formatted value, the API will default to a string-interpreted version of > the value (unless you override this some other way [calling > #setFormattedValue, using a Formatter, etc]). > > Also note that there is a minor typo in the code, in the while loop, the > $i variables should be $r. > > On Wednesday, August 29, 2012 4:17:57 PM UTC-4, Diana Flores wrote: >> >> hi i know its kind of to late to post, but im not so sure if i >> understand ur code!!!..i have this case!!, a table 14(row)x10(col), the >> varible $getData_t1 etc.. is the variable where u get the query, i mean >> $getData=mysql_query("select * from table")? >> >> On Thursday, October 20, 2011 12:34:30 AM UTC-6, Dinga Bogdan wrote: >>> >>> Hi, I will try to help you. >>> >>> It is easy to get data from PHP/SQL using JASON format. >>> And also google api has a ajax "function" to get the data from the php >>> script. >>> >>> If you could give me the columns, rows from youre sql I can show you a >>> more precise example. >>> Here the short version: >>> For PHP script you have to build 2 main arrays "rows" and "cols" . >>> Each array contains more arrays with values. >>> Something like this: >>> $rows = array('c' => array( >>> array( 'v' => $timestamp, 'f' => NULL ), >>> array( 'v' => >>> (int)$getData_t1['power_avg'], 'f' => ''. >>> $getData_t1['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t2['power_avg'], 'f' => ''. >>> $getData_t2['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t3['power_avg'], 'f' => ''. >>> $getData_t3['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t4['power_avg'], 'f' => ''. >>> $getData_t4['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t5['power_avg'], 'f' => ''. >>> $getData_t5['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t6['power_avg'], 'f' => ''. >>> $getData_t6['power_avg'].' kWh' ), >>> array( 'v' => >>> (int)$getData_t7['power_avg'], 'f' => ''. >>> $getData_t7['power_avg'].' kWh' ) >>> )); >>> This is a single row with 8 columns. Now to build the columns: >>> $cols = array( >>> array( 'id' => '0', 'label' => 'Timestamp', >>> 'type' => 'string'), >>> array( 'id' => '1', 'label' => 'WTG01', 'type' >>> => 'number'), >>> array( 'id' => '2', 'label' => 'WTG02', 'type' >>> => 'number'), >>> array( 'id' => '3', 'label' => 'WTG03', 'type' >>> => 'number'), >>> array( 'id' => '4', 'label' => 'WTG04', 'type' >>> => 'number'), >>> array( 'id' => '5', 'label' => 'WTG05', 'type' >>> => 'number'), >>> array( 'id' => '6', 'label' => 'WTG06', 'type' >>> => 'number'), >>> array( 'id' => '7', 'label' => 'WTG07', 'type' >>> => 'number') >>> ); >>> Not that we have the columns and for now 1 row, we echo out the json >>> string like this: >>> >>> echo '{ "cols": '.json_encode($cols).', "rows": >>> '.json_encode($rows).'}'; >>> This is it for the PHP, the script accessed from the browser itself >>> should print the JSON string. >>> For the js it is even simpler. Lets say that this PHP file is named >>> test.php >>> var jsonData = $.ajax({ >>> url: "test.php", >>> dataType:"json", >>> async: false >>> }).responseText; >>> >>> var data = new google.visualization.DataTable(jsonData); >>> And here you have the data table made based on the PHP JSON file :) >>> >>> Give me the exact thing you want to do and I will try to make the >>> script for you. I had the same issue a few weeks ago. >>> >>> On Oct 19, 9:34 pm, rL <[email protected]> wrote: >>> > hey, >>> > >>> > i wanna build a simple PHP Page with retrieving all necessary data >>> > from mysql but the the html starts with the javascript google function >>> > and i cannot put my php data in cause php rendering is over... >>> > >>> > how can i build up those graphs in php with getting data from mysql >>> > without something complicated like JSON, AJAX and something... >>> > >>> > Or is there any example of this anywhere? >>> > >>> > Thanks >> >>
-- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/cKzUKgTbmNwJ. 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.
