Google Chart API is very easy way to create and display different charts on your website online. There are many other projects which will help you with Flash or more dynamic charts, but Google Chart API is simple enough and powerful at the same time. You can create different charts with it by using minimum of your skills. The only thing you have to know is HTML, or better say, you have to know how to write an URL.
How to work with Google Chart API?
If you need to create a chart, you can construct it using a special URL. There is a sample from Google Chart API homepage:
Try to put the address above to your browser. You should see this pie chart:
So if you know how to construct the chart using the special URL, you are able to put it on your page using the HTML IMG tag with the URL as a source:
<img src=“https://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World“ />
You should be able to use a visual editor on your website if you are using any content management system. There is no problem with it.
Google Chart API has a nice documentation and I highly recommend to read it. You will see how to create more types of graphs, how to work with axes and so.
GChart: PHP library for Google Chart API
There is a new object oriented PHP library which will help you to create a Google Chart API URL in your PHP projects. So you will be able to dynamically construct the chart's URL and keep your code synoptic. This library I write about is called GChart and can be found at SourceForge.
The chart mentioned above could be created with GChart using this simple way:
<img src="<?php echo $pie3d->get_image_string(); ?>" />
As you can see, there are only three lines of code. At first you have to create a new object of a given type and dimensions.The next steps will add axes. And the final step is to print the URL for this chart to the HTML code. Fast and simple. GChart support these chart types:
- Pie Chart (including 2D-pie chart and 3D-pie chart)
- Line Chart
- Bar Chart (including vertical bar chart and horizontal bar chart)
- Radar Chart
- Scatter Plot Chart
- Google-O-Meter Chart
- QR-Code Chart