<?php

    $action =  (isset($_REQUEST["action"])) ? $_REQUEST["action"] : '';

    switch($action)
    {
        case 'pieimage';
            include_once(SYS_BASE_PATH.'main/classes/chart.class.php');
            $w = new wChart();
            $w->title = 'Deadly mushrooms';
            $w->add('Один',50 );
            $w->add('Два', 75);
            $w->add('Три', 30);
            $w->show();
        break;
        case 'horbar';
            include_once(SYS_BASE_PATH.'main/classes/chart.class.php');
            $w = new wChart('hbar');
            $w->title = 'Most visited pages for www.example.com';
            $w->add('Один',50 );
            $w->add('Два', 75);
            $w->add('Три', 30);
            $w->show();
        break;
        case 'linechart';
            include_once(SYS_BASE_PATH.'main/classes/chart.class.php');
            $w = new wChart('line');
            $w->title = 'Sales for 2006';
            $w->add('06-01', 273);
            $w->add('06-02', 421);
            $w->add('06-03', 642);
            $w->add('06-04', 799);
            $w->add('06-05', 1009);
            $w->add('06-06', 1406);
            $w->add('06-07', 1820);
            $w->add('06-08', 2511);
            $w->add('06-09', 2832);
            $w->add('06-10', 3550);
            $w->add('06-11', 4143);
            $w->add('06-12', 4715);

            $w->show();
        break;
        case 'verbar';
            include_once(SYS_BASE_PATH.'main/classes/chart.class.php');
            $w = new wChart('vbar');
            $w->title = 'Monthly usage';
            $w->add('Jan 2005', 273);
            $w->add('Feb 2005', 421);
            $w->add('March 2005', 642);
            $w->add('April 2005', 800);
            $w->add('May 2005', 1200);
            $w->add('June 2005', 1500);
            $w->add('July 2005', 2600);

            $w->show();
        break;

        case 'horbar2';
            include_once(SYS_BASE_PATH.'main/classes/chart.class.php');
            $w = new wChart('vbar');
            $w->title = 'Firefox vs IE users: Age';
            $w->add('18-24', array(22,13, 30));
            $w->add('25-34', array(17,18, 25));
            $w->add('35-44', array(20,23, 34));
            $w->add('45-54', array(25,22, 40));
            $w->addLegend("Male");
            $w->addLegend("Female");
            $w->addLegend("Others");

            $w->show();
        break;

    }


    print("<img src=\"".$parser->makeUrl($parser->getPageId(), 'action=pieimage')."\"><br />");
    print("<img src=\"".$parser->makeUrl($parser->getPageId(), 'action=horbar')."\"><br />");
    print("<img src=\"".$parser->makeUrl($parser->getPageId(), 'action=linechart')."\"><br />");
    print("<img src=\"".$parser->makeUrl($parser->getPageId(), 'action=verbar')."\"><br />");
    print("<img src=\"".$parser->makeUrl($parser->getPageId(), 'action=horbar2')."\"><br />");

?>