What's new? | Help | Directory | Sign in
Google
gchart4mw
Mediawiki extension to use Google Chart in wiki pages easily
  
  
  
  
    
Search
for
Updated Dec 12, 2007 by d.festerling
UsingTheLinesTag  
step-by-step examples for using the <lines>-tag.

To draw lines-charts with gchart4mw put the data to show between <lines> and </lines> (<bars> and <pie> are also possible tags for charts). Just put one value per row:

If you put this code in a page of your wiki

<lines title="Site Visitors">
5345
3452
7843
</lines>

you will get this chart:

back

Setting the Y-Axis

By default the Y-Axis gets autoscaled by finding the greatest and the smallest value of all given data. If you would like to set the Y-Axis manually you can do so by using ymin and ymax (You don“t have to use both values):

<lines title="Site Visitors" ymin=0 ymax=8000>
5345
3452
7843
</lines>

back

Showing multiple data-lines

You can show multiple data lines in a chart if you put multiple values separated by a colon in each row:

<lines title="Site Visitors" ymin=0 ymax=8000>
4115,1230
2541,911
5410,2433
</lines>

To separate the data lines in a better way you can set the color of each line:

<lines title="Site Visitors" ymin=0 ymax=8000 colors=FF0000,00FF00>
4115,1230
2541,911
5410,2433
</lines>

back

Putting Labels on the Y-axis

To get an idea about the value of each data-point, put labels on the Y-axis. This puts 4 labels on the Y-axis:

<lines title="Site Visitors" ymin=0 ymax=8000 colors=FF0000,00FF00 ylabel=4>
4115,1230
2541,911
5410,2433
</lines>

back

Putting Labels on the X-axis

If you add the xlabel-parameter to the chart, the first column of the given data is handled as labels for the X-axis:

<lines title="Site Visitors" ymin=0 ymax=8000 colors=FF0000,00FF00 ylabel=4 xlabel>
Oct,4115,1230
Nov,2541,911
Dec,5410,2433
</lines>

back

Adding a legend to the chart

Especially for charts with multiple data lines you should add a legend to it. This can be done with the legend-parameter and putting the labels for the legend in the first row of the content.

<lines title="Site Visitors" ymin=0 ymax=8000 colors=FF0000,00FF00 ylabel=4 xlabel legend>
   ,EU  ,US
Oct,4115,1230
Nov,2541, 911
Dec,5410,2433
</lines>

Note: As you see in the example, if you also have labels on the X-axis, the first column of the first row is empty!

back

Putting a grid under the chart

It is easier to compare values if you put a grid under the chart. You can put lines for one axis only or for both X- and Y-axis:

<lines title="Site Visitors" ymin=0 ymax=8000 colors=FF0000,00FF00 ylabel=4 xlabel legend grid=xy>
   ,EU  ,US
Oct,4115,1230
Nov,2541, 911
Dec,5410,2433
</lines>

back


Comment by falieson, Mar 14, 2008

how do I make the graph larger, I am trying to put in a lot of data.

Comment by carl.wirth, May 12, 2008

With the parameter size, but size=500x600 seems to be the maximum.

Comment by martin.suska, Jun 20, 2008

Yes, there is restriction for Google chart size.

Comment by ZZZZ.T.Z, Jun 21, 2008

anyone know how to change the background color? i read the docs but it doesnt work for me in the extention... fill=#333333? chf=bg,s,333333?


Sign in to add a comment