Location: PHPKode > scripts > graph2d > graph2d/sample.php
<?php
    require_once ('graph2d.class.php');

    $xmin=0.0;
    $xmax=1.0;
    $xstep=0.001;

    $ymin=0.0;
    $ymax=1.0;
    $ystep=0.1;

    $xarr=array();
    $yarr1=array();
    $yarr2=array();
    $yarr3=array();

    $n=1001;
    for ($i=0; $i<$n; $i++)
    {
        $xarr[$i]=$xmin+$xstep*$i;
        $yarr1[$i]=$xarr[$i];
        $yarr2[$i]=$xarr[$i]*$xarr[$i];
        $yarr3[$i]=sqrt ($xarr[$i]);
    }

    $test=new graph2d ("jpeg", 700, 350, 60, 20, 20, 40);

    $test->SetAxisScales ($xmin, $xmax, 0.1, 1, $ymin, $ymax, $ystep, 1);

    $test->SetTitle ("Test");
    $test->SetXLegend ("X");
    $test->SetYLegend ("Y");

    $test->GraphCoord();

    $test->Draw($xarr, $yarr1, 0xFF, 0, 0);

    $test->Draw($xarr, $yarr2, 0, 0xFF, 0);

    $test->Draw($xarr, $yarr3, 0, 0, 0xFF);

    $test->ImageOut("");

    $test->Close();

?>
Return current item: graph2d