Extension:Google Chart

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Google Chart

Release status: beta

GoogleChartExample.png
Implementation Parser function
Description Use google chart in your wiki.
Author(s) Jflycn
Last version 0.1 (2/27/2010)
MediaWiki 1.16
License No license specified
Download Following
Example Following

Check usage (experimental)

This is a very simple extension just for using google chart in your wiki.

There is a potential risk of cross-site scripting attacks, so it is only suitable when user register and guest editing are closed.

Contents

[edit] Installation

The only thing you need to do is

  1. create a file named GoogleChart.php in the extensions folder,
  2. paste the following code into it,
  3. put require_once("$IP/extensions/GoogleChart.php"); into LocalSettings.php.
<?php
 
if ( !defined( 'MEDIAWIKI' ) ) die();
 
// credits
$wgExtensionCredits['specialpage'][] = array(
        'path' => __FILE__,
        'name' => 'Google Chart',
        'version' => '0.1',
        'author' => 'Jflycn', 
        'url' => 'http://jiaoyan.org/',
        'description' => 'An extension to use google charts in your wiki.'
);
 
$wgExtensionFunctions[] = "jfGoogleChart";
 
function jfGoogleChart() {
        global $wgParser;
        $wgParser->setHook( "chart", "returnGoogleChart" );
}
 
function returnGoogleChart($code, $args)
{
 
        if (is_null($args)) return;
 
        foreach($args as $name => $value) {
                $txt.="&".$name."=".$value;
        }
 
        $img='<img src="http://chart.apis.google.com/chart?1=1'.$txt.'">';
 
        return $img;
}
 
?>

[edit] Usage

You must learn the markup of Google Chart first. After that, everything is very simple.

For example, if you input the following code:

<chart cht=bvs chs=800x300 chbh=20,1 chxt=x,y chco=76A4FB chls=2.0 chd=t:1,2,3,6,9,13,20,28,37,49,60,72,83,92,98,100,98,92,83,72,60,49,37,28,20,13,9,6,3,2,1 />

then you get a histogram of a normal distribution: GoogleChartExample.png

By the way, you can also use this extension to create math formulas with latex markup.

For example, if you input the following code: <chart cht=tx chl=\LaTeX />, then you get a LaTeX logo.

[edit] History

Release Notes
0.1 Initial public release

[edit] See Also

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox