source: trunk/xgraph/jpgraph/Examples/dateaxisex2.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.0 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4require_once ('jpgraph/jpgraph_date.php');
5
6// Create a data set in range (50,70) and X-positions
7DEFINE('NDATAPOINTS',360);
8DEFINE('SAMPLERATE',240); 
9$start = time();
10$end = $start+NDATAPOINTS*SAMPLERATE;
11$data = array();
12$xdata = array();
13for( $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?>
Note: See TracBrowser for help on using the repository browser.