<?php
require_once ('../jpgraph.php');
require_once ('../jpgraph_line.php');
require_once ('../jpgraph_date.php');
$xdata = array();
$ydata = array();
$sampling = 7200;
$n = 50;
for($i=0; $i < $n; ++$i ) {
$xdata[$i] = time() + $i * $sampling;
$ydata[0][$i] = rand(12,15);
$ydata[1][$i] = rand(100,155);
$ydata[2][$i] = rand(20,30);
}
function formatDate(&$aVal) {
$aVal = date('Y-m-d H:i',$aVal);
}
array_walk($xdata,'formatDate');
$graph = new Graph(600, 350);
$graph->title->Set('Accumulated values with specified X-axis scale');
$graph->SetScale('textlin');
$graph->SetMarginColor('green@0.95');
$graph->SetMargin(40,30,40,120);
$graph->xaxis->SetTickSide(SIDE_BOTTOM);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$p0 =new LinePlot($ydata[0]);
$p0->SetFillColor('sandybrown');
$p1 =new LinePlot($ydata[1]);
$p1->SetFillColor('lightblue');
$p2 =new LinePlot($ydata[2]);
$p2->SetFillColor('red');
$ap = new AccLinePlot(array($p0,$p1,$p2));
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetTextLabelInterval(4);
$graph->Add($ap);
$graph->xaxis->SetLabelAngle(90);
$graph->Stroke();
?> |