Login   Register  
PHP Classes
elePHPant
Icontem

File: test01.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Herman Veluwenkamp  >  Graph Drawing Class 2  >  test01.php  >  Download  
File: test01.php
Role: Example script
Content type: text/plain
Description: Line and Point Chart
Class: Graph Drawing Class 2
Class to draw line, point, area, and bar graphs.
Author: By
Last change:
Date: 13 years ago
Size: 1,694 bytes
 

Contents

Class file image Download
<?php
include 'graph.php';

$chart = new graph(400,240);
$chart->parameter['path_to_fonts'] = 'fonts/'// path to where fonts are stored
$chart->parameter['title'] = 'Line and Point Chart';
$chart->parameter['x_label'] = 'Day of the Week';
$chart->parameter['y_label_left'] = 'Some Data';

$chart->x_data          = array('Friday''Monday''Tuesday''Wednesday''Thursday''Friday');

srand ((double) microtime() * 1000000);
$a 25;
$b 10;
$c 18;
$d 4;
$e 9;
$f 12;
foreach (array(
'alpha','beta','theta') as $i) {
    
$a += rand(-42);
    
$b += rand(-24);
    
$c += rand(-42);
    
$d += rand(-24);
    
$e += rand(-42);
    
$f += rand(-24);
    if (
$a 0$a 0;
    if (
$b 0$b 0;
    if (
$c 0$c 0;
    if (
$d 0$d 0;
    if (
$e 0$e 0;
    if (
$f 0$f 0;
    
$chart->y_data[$i] = array($a$b$c$d$e$f);
    
//$chart->y_data[$i] = array(-189, -222, -546, -223, -451, -567);

}

$chart->parameter['point_size'] = 6;

// format for each data set
$chart->y_format['alpha'] =
  array(
'colour' => 'blue''line' => 'line''point' => 'square-open');

$chart->y_format['beta'] =
  array(
'colour' => 'red''line' => 'line''point' => 'square');

$chart->y_format['theta'] =
  array(
'colour' => 'green''line' => 'line''point' => 'circle');

// order in which to draw data sets.
$chart->y_order = array('alpha''beta''theta');
//$chart->y_order = array('alpha');

//$chart->parameter['y_max_left']= -600;
//$chart->parameter['yMinLeft']= -10;

$chart->parameter['y_resolution_left']= 1;
$chart->parameter['y_decimal_left']= 0;

//$chart->init();
//expand_pre($chart);
//exit;

// draw it.
$chart->draw();
?>