1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
4 | require_once ('jpgraph/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 | $line = new LinePlot($data,$xdata);
|
---|
34 | $line->SetLegend('Year 2005');
|
---|
35 | $line->SetFillColor('lightblue@0.5');
|
---|
36 | $graph->Add($line);
|
---|
37 | $graph->Stroke();
|
---|
38 | ?>
|
---|