PHP Classes

File: sample_grid.php

Recommend this page to a friend!
  Classes of Yuriy Rusinov   graph2d   sample_grid.php   Download  
File: sample_grid.php
Role: Example script
Content type: text/plain
Description: Example graphs with grid
Class: graph2d
Generates two dimensional graphic images
Author: By
Last change:
Date: 20 years ago
Size: 944 bytes
 

Contents

Class file image Download
<?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->SetGrid(TRUE, 0xA0, 0xA0, 0xA0);

   
$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();

?>