Location: PHPKode > projects > Monyet > plotter/jpgraph-2.2/src/Examples/barlinefreq_csimex1.php
// Example of CSIM frequence bar that uses the cache
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);

// We need to make this extra call for CSIM scripts
// that make use of the cache. If the cache contains this
// graph the HTML wrapper will be returned and then the
// method will call exit() and hence NO LINES AFTER THIS 
// $graph->CheckCSIMCache('auto');

// 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 targets and alt texts for the image maps. One for each bar
// (In this example this is just "dummy" targets)

// 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