| 1 |
lars |
1 |
<?php
|
|
|
2 |
require_once("../jpgraph.php");
|
|
|
3 |
require_once("../jpgraph_line.php");
|
|
|
4 |
require_once("../jpgraph_date.php");
|
|
|
5 |
|
|
|
6 |
// Create a data set in range (50,70) and X-positions
|
|
|
7 |
DEFINE('NDATAPOINTS',360);
|
|
|
8 |
DEFINE('SAMPLERATE',240);
|
|
|
9 |
$start = time();
|
|
|
10 |
$end = $start+NDATAPOINTS*SAMPLERATE;
|
|
|
11 |
$data = array();
|
|
|
12 |
$xdata = array();
|
|
|
13 |
for( $i=0; $i < NDATAPOINTS; ++$i ) {
|
|
|
14 |
$data[$i] = rand(50,70);
|
|
|
15 |
$xdata[$i] = $start + $i * SAMPLERATE;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
// Create the new graph
|
|
|
20 |
$graph = new Graph(540,300);
|
|
|
21 |
|
|
|
22 |
// Slightly larger than normal margins at the bottom to have room for
|
|
|
23 |
// the x-axis labels
|
|
|
24 |
$graph->SetMargin(40,40,30,130);
|
|
|
25 |
|
|
|
26 |
// Fix the Y-scale to go between [0,100] and use date for the x-axis
|
|
|
27 |
$graph->SetScale('datlin',0,100);
|
|
|
28 |
$graph->title->Set("Example on Date scale");
|
|
|
29 |
|
|
|
30 |
// Set the angle for the labels to 90 degrees
|
|
|
31 |
$graph->xaxis->SetLabelAngle(90);
|
|
|
32 |
|
|
|
33 |
// The automatic format string for dates can be overridden
|
|
|
34 |
$graph->xaxis->scale->SetDateFormat('H:i');
|
|
|
35 |
|
|
|
36 |
// Adjust the start/end to a specific alignment
|
|
|
37 |
$graph->xaxis->scale->SetTimeAlign(MINADJ_10);
|
|
|
38 |
|
|
|
39 |
$line = new LinePlot($data,$xdata);
|
|
|
40 |
$line->SetLegend('Year 2005');
|
|
|
41 |
$line->SetFillColor('lightblue@0.5');
|
|
|
42 |
$graph->Add($line);
|
|
|
43 |
$graph->Stroke();
|
|
|
44 |
?>
|