googleChart plugin |
| Written by kksou | |||
| Thursday, 10 December 2009 | |||
|
This plugin allows you to easily add pie charts, bar graphs, line charts, etc. right inside your content item or article. The charts are created using the Google Chart API. Unique Features
Chart TypesThe Google Chart API provides many different types of charts. However, if you take a look at the API documentation, each chart has its own set of syntax for data, labels, range, grid lines, etc. It gets quite confusing at times, especially with the very cryptic way of naming the parameters. In this plugin, I've selected some of the most commonly-used functions and give them a simpler and easier-to-remember parameter names. As this needs to be coded one by one, below are the list of charts that I've implemented to date. If you want other chart types, you can still access the entire Google Chart APIs using the Raw Mode.
{googleChart type=p width=200 height=100
data="10,20,30,40" label="Jan|Feb|Mar|Apr"}
{googleChart type=p3 width=250 height=100
data="10,20,30,40" label="Jan|Feb|Mar|Apr"}
{googleChart type=bvg width=250 height=100
data="10,40,60,90" label="Jan|Feb|Mar|Apr"}
{googleChart type=bvg width=250 height=100
data="40,10,60,90|20,60,80,100"
label="Jan|Feb|Mar|Apr" color="4D89D9,C6D9FD"}
{googleChart type=bvs width=250 height=100
data="40,10,60,90|20,60,30,10"
label="Jan|Feb|Mar|Apr" color="4D89D9,C6D9FD"}
{googleChart type=bhg width=250 height=128 data="10,40,60,90" label="Jan|Feb|Mar|Apr"}
{googleChart type=bhg width=250 height=250
data="40,10,60,90|20,60,80,100"
label="Jan|Feb|Mar|Apr" color="4D89D9,C6D9FD"}
{googleChart type=bhs width=250 height=128
data="40,10,60,90|20,60,30,10"
label="Jan|Feb|Mar|Apr" color="4D89D9,C6D9FD"}
{googleChart type=lc width=250 height=100
data="10,40,60,90" label="Jan|Feb|Mar|Apr"}
{googleChart type=lc width=250 height=100
data="10,40,60,90" label="Jan|Feb|Mar|Apr" color="4D89D9,C6D9FD"}
How to use
{googleChart type=p3 width=250 height=100
data="12,21,31" label="Label1|Label2|Label3"}
Parameters
For 2D pie charts, you can start with {googleChart type=p width=200 height=100
data="10,20,30,40" label="Jan|Feb|Mar|Apr"}
For 3D pie charts, you can try {googleChart type=p3 width=250 height=100
data="10,20,30,40" label="Jan|Feb|Mar|Apr"}
The largest possible area for all charts except maps is 300,000 pixels. As the maximum height or width is 1000 pixels, examples of maximum sizes are 1000x300, 300x1000, 600x500, 500x600, 800x375, and 375x800. For maps, the maximum size is 440 pixels wide by 220 pixels high. For pie charts, bar graphs and line charts, labels are specified simply by delimiting each label with the vertical bar (|). Note that for pie charts, the Google Chart API does not provide automatic display of data values in percentages. If you want to display the percentages, you have to manual input them in the labels as follows:
{googleChart type=p3 width=360 height=100
data="12,21,31"
label="Label1 (19%)|Label2 (33%)|Label3 (48%)"}
{googleChart type=bvg width=250 height=100
data="1,3,8,9" label="Jan|Feb|Mar|Apr"}
To set the range of the y-value, use the following, where 0 is the minimum y-value, and 10 is the maximum y-value: {googleChart type=bvg width=250 height=100
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,10"}
{googleChart type=bvg width=250 height=100
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,20,5"}
It's similar for horizontal pie chart: {googleChart type=bhg width=250 height=150
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,20,5"}
{googleChart type=bvg width=250 height=100
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,20,5,1"}
It's similar for horizontal pie chart: {googleChart type=bhg width=250 height=150
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,20,5,1"}
{googleChart type=bvg width=250 height=100
data="1,3,8,9" label="Jan|Feb|Mar|Apr" range="0,20,5,1"
color="66ff66"}
For charts such as the grouped bar chart, the colors for each chart are delimited by commas, as shown below: {googleChart type=bvg width=250 height=100
data="40,30,60,90|20,21,42,78" label="Jan|Feb|Mar|Apr"
range="0,100,20,1" color="66ff66,ff6699"}
For pie charts, if you specify 2 or more colors, Google will span colors across these colors as shown below: {googleChart type=p3 width=250 height=100
data="72,48,32,10,6,3" label="Jan|Feb|Mar|Apr|May|Jun"
color="FF3366,33CCFF,3366FF"}
{googleChart type=bvg width=250 height=100
data="40,30,60,90|20,21,42,78" label="2006|2007|2008|2009"
range="0,100,20,1" color="66ff66,ff6699"
legend="Sales|Profit"}
And this one floats to the left. Tag used:
Important: To break away from the float, use the following: {googleChart br=1}
Raw ModeFor power users, you can enter Google Chart APIs in raw mode so that you can tap onto 100% of the Google Chart APIs as provided Google. For example:
{googleChart raw="cht=pc&chd=s:Helo,Wrld&chs=200x100"}
{googleChart raw="cht=v&chs=200×100&chd=t:100,80,60,30,30,30,10"}
{googleChart raw="cht=lc&chd=s:2gounjqLaCf&chco=008000
&chls=2.0,4.0,1.0&chs=250x150&chxt=x&chxl=0:||c|d|a|o|s|v|V|x||&
chm=a,990066,0,3.0,9.0|c,FF0000,0,1.0,20.0|d,80C65A,0,2.0,20.0|
o,FF9900,0,4.0,12.0|s,3399CC,0,5.0,11.0|v,BBCCED,0,6.0,1.0|
V,3399CC,0,7.0,1.0|x,FFCC33,0,8.0,20.0|h,000000,0,0.30,0.5
&chma=0,0,30,0"}
Be a SponsorIf you find this plugin useful, Secure Payments by PayPal. DownloadJoomla 1.0.x: googleChart_v1.01.zip
Joomla 1.5.x: googleChart_v1.51.zip Joomla 1.6.x: googleChart_v1.61.zip Joomla 1.7.x: googleChart_v1.71.zip Joomla 2.5.x: googleChart_v2.51.zip Remove the "Powered by" linksIf you find the plugin useful and would like to use the plugin without the "Powered-by" links, you may do so by purchasing a "Powered-by" removal license for only USD $10 per site. Secured payment is processed by 2checkout.com. All major credit cards are accepted, including Visa, Mastercard and American Express, etc. You can also pay by PayPal. Once the transaction is completed, you will be given a link to download the registered version with the "Powered by" links removed. |
|||
| < Prev | Next > |
|---|





Comments
Glad you find it useful.
Will try to work on it tonight to see I can come out with the version for Joomla 2.5.
Will let you know once it's done.
Regards,
/kksou
RSS feed for comments to this post