Location: PHPKode > projects > Monyet > plotter/jpgraph-2.2/src/Examples/barlinefreqex1.php
// Example of frequence bar 
include_once ("../jpgraph.php");
include_once ("../jpgraph_bar.php");
include_once ("../jpgraph_line.php");

// Utility function to calculate the accumulated frequence
// for a set of values and ocurrences
function accfreq($data) {
    $s = array_sum($data);
    $as = array($data[0]);
    $asp = array(100*$as[0]/$s);
    $n = count($data);
    for( $i=1; $i < $n; ++$i ) {
	$as[$i] = $as[$i-1]+$data[$i];
	$asp[$i] = 100.0*$as[$i]/$s;
    return $asp;

// some data
$data_freq = array(22,20,12,10,5,4,2);
$data_accfreq = accfreq($data_freq);

// Create the graph. 
$graph = new Graph(350,250);

// Setup some basic graph parameters

// Setup titles and fonts
$graph->title->Set("Frequence plot");


// Turn the tickmarks


// Create a bar pot
$bplot = new BarPlot($data_freq);

// Create accumulative graph
$lplot = new LinePlot($data_accfreq);

// We want the line plot data point in the middle of the bars

// Use transperancy

// Setup the bars

// Add it to the graph

// Send back the HTML page which will call this script again
// to retrieve the image.

Return current item: Monyet