Login   Register  
PHP Classes
elePHPant
Icontem

File: test02.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  >  test02.php  >  Download  
File: test02.php
Role: Example script
Content type: text/plain
Description: Brush Line Chart
Class: Graph Drawing Class 2
Class to draw line, point, area, and bar graphs.
Author: By
Last change:
Date: 2001-03-04 20:00
Size: 1,781 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'] = 'Brush Line 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->parameter['point_size'] = 6;

// format for each data set
$chart->y_format['alpha'] =
  array(
'colour' => 'blue',
        
'line'   => 'brush',
        
'legend' => 'First Data Set');

$chart->y_format['beta'] =
  array(
'colour' => 'yellow',
        
'line'   => 'brush',
        
'legend' => 'Second Data Set');

$chart->y_format['theta'] =
  array(
'colour' => 'green',
        
'line'   => 'brush',
        
'legend' => 'Third Data Set');

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

$chart->parameter['x_axis_angle'] = 60// x_axis text rotation
$chart->parameter['y_decimal_left']= 2;
$chart->parameter['y_axis_num_ticks']= 6;

$chart->parameter['brush_size'] = 4;
$chart->parameter['shadow_offset'] = 4;

//$chart->parameter['legend'] = 'outside-left';
//$chart->parameter['legend_border'] = 'black';

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