Reputation: 97
I have the following php array
Array ( [0] =>
Array ( [year] => 2009
[month] => January
[month_sales] => 728
[year_totalsales] => 2663 )
[1] =>
Array ( [year] => 2009
[month] => February
[month_sales] => 640
[year_totalsales] => 2663 )
[2] =>
Array ( [year] => 2009
[month] => March
[month_sales] => 636
[year_totalsales] => 2663 )
[3] =>
Array ( [year] => 2010
[month] => January
[month_sales] => 636
[year_totalsales] => 2663 )
[4] =>
Array ( [year] => 2010
[month] => February
[month_sales] => 23
[year_totalsales] => 2663 ) )
How do I get this to display in Google charts?
Upvotes: 2
Views: 6200
Reputation: 207
Beaware that Oliver's answer is for the (static) Image Chart Google API which is being depreciated and not available after 2015. (I didn't have enough rep to comment)
This class is to aid using PHP with the current Google Chart API. I'm yet to use/test them myself but it seems to be straight forward from the examples.
https://code.google.com/p/php-class-for-google-chart-tools/
Upvotes: 2
Reputation: 3171
You will have to loop into your array and generate a pipe delimited string for use in your chart.
I suggets also to read the following
Google Chart Tools & Data Formats
Upvotes: 0
Reputation: 1516
There are scripts which google have provided to make this sort of thing much easier.
I hope the following link helps you: http://code.google.com/p/googlechartphplib/wiki/GettingStarted
It's fairly easy from what I've dabbled in, however, you have to be careful as I have made many mistakes doing this and I managed to mess up the data which I was trying to input which then gave me a totally different chart.
I hope this helps though
Upvotes: 1