2

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?

3 Answers 3

2

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/

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

Thanks but I have read this and it does not help me get that array with multiple years into the chart.
0

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

1 Comment

Thanks but I have read this and it does not help me get that array with multiple years into the chart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.