1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?php
require_once("../include/Util.php");
include ("../include/jpgraph/jpgraph.php");
include ("../include/jpgraph/jpgraph_line.php");
require_once ('../include/jpgraph/jpgraph_date.php');
// Create a data set in range (50,70) and X-positions
DEFINE('NDATAPOINTS',360);
DEFINE('SAMPLERATE',240);
$start = time();
$end = $start+NDATAPOINTS*SAMPLERATE;
$data = array();
$xdata = array();
for( $i=0; $i < NDATAPOINTS; ++$i ) {
$data[$i] = $start + $i *240* rand(1,10);
$xdata[$i] = $start + $i * SAMPLERATE;
}
// Create the new graph
$graph = new Graph(540,300);
// Slightly larger than normal margins at the bottom to have room for
// the x-axis labels
$graph->SetMargin(80,40,30,130);
$graph->SetScale('datint');
$graph->title->Set("Example on Date scale");
function yLabelFormat($aLabel) {
return date('Y-m-d',$aLabel);
}
$graph->yaxis->SetLabelFormatCallback('yLabelFormat');
// Set the angle for the labels to 90 degrees
$graph->xaxis->SetLabelAngle(90);
$line = new LinePlot($data,$xdata);
$line->SetLegend('Year 2005');
$line->SetFillColor('lightblue@0.5');
$graph->Add($line);
$graph->Stroke();
?> |
Partager