Given your spreadsheet, you treat rows 11 through 13 as an array of arrays. Each row is an array with the values in that row. You get something like this in JSON:
[ ['Matn', 'value1', 'value2', 'value3', 'value4']. ['blabla', 100, 88, 84, 16], ['blabla 2', 100, 78, 34, 6] ] This can be fed directly into arrayToDataTable() on the javascript side to generate the same table shown in your chart. On Wed, Jul 11, 2012 at 8:25 AM, Adam Hardarson <[email protected]>wrote: > Thanks for the reply! > > I've looked at how the data should be formatted but I just cant wrap my > head around on how to accomplish it! > > To better illustrate what I'm going for I put in a spreadsheet: > https://docs.google.com/spreadsheet/ccc?key=0AsRWz3wVoWuLdGwtckVHS2k0a09KbkZXc1VCUGR6VFE > > > This is my code to get the approriate values from the two dropdowns > ($first and $second): > $result124 = mysql_query("SELECT Matningsnamn AS Matning, > Value1, > Value2 , > Value3 , > Value4 > FROM myDB WHERE Id ='$first' OR Id ='$second'"); > $rows = array(); > while($r = mysql_fetch_assoc($result124)) { > $rows[] = $r; > } > $gn = json_encode($rows); > > which results in: > > [{"Matning":"blabla","Value1":"100","value2":"88","value3":"84","value4":"16"}, > {"Matning":"blabla > 2","Value1":"100","value2":"78","value3":"34","value4":"6}] > > I didn't really understand your example, this is all so new to me... :-/ > > If you look in the spreadsheet on how the graph looks, do you have any > ideas on how to make it look like that or further reading suggestions?! > > Thank you all for engaging in my silly problem :) > Adam > > > Den tisdagen den 10:e juli 2012 kl. 21:17:54 UTC+2 skrev Allen "Prisoner" > Firstenberg: > >> Adam, >> >> It depends what you want to do, but the easiest solution would be to >> target a data format specified at https://developers.google.** >> com/chart/interactive/docs/**datatables_dataviews<https://developers.google.com/chart/interactive/docs/datatables_dataviews> >> In particular, you might want to look at the arrays that can be fed >> directly into arrayToDataTable() - the example on that page should show >> what it needs to look like. >> >> What I've done in this case is to take the associative array in PHP and >> iterate over all the keys. If the key is a number (tested by PHP's >> is_numeric() function), then throw it out. Otherwise, create a new array >> row with values being the key and value from the associative array and add >> this to the array to return. >> >> Your needs may vary, but this has worked for the things I've tried to do. >> >> Allen >> >> >> -- > 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/-/x5HHlSpyvO0J. > > 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. > -- 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.
