Line | |
---|
1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
4 |
|
---|
5 | define('DATAPERMONTH',40);
|
---|
6 |
|
---|
7 | // Some data
|
---|
8 | $m=$gDateLocale->GetShortMonth();
|
---|
9 | $k=0;
|
---|
10 | for($i=0; $i < 480; ++$i) {
|
---|
11 | $datay[$i] = rand(1,40);
|
---|
12 | if( $i % DATAPERMONTH === 0 )
|
---|
13 | $months[$i] = $m[(int)($i/DATAPERMONTH)];
|
---|
14 | else
|
---|
15 | $months[$i] = 'xx';
|
---|
16 | }
|
---|
17 |
|
---|
18 |
|
---|
19 | // New graph with a drop shadow
|
---|
20 | $graph = new Graph(400,200);
|
---|
21 | //$graph->SetShadow();
|
---|
22 |
|
---|
23 | // Use a "text" X-scale
|
---|
24 | $graph->SetScale('textlin');
|
---|
25 |
|
---|
26 | // Specify X-labels
|
---|
27 | $graph->xaxis->SetTickLabels($months);
|
---|
28 | $graph->xaxis->SetTextTickInterval(DATAPERMONTH,0);
|
---|
29 | $graph->xaxis->SetTextLabelInterval(2);
|
---|
30 |
|
---|
31 | // Set title and subtitle
|
---|
32 | $graph->title->Set('Textscale with tickinterval=2');
|
---|
33 |
|
---|
34 | // Use built in font
|
---|
35 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
36 |
|
---|
37 | $graph->SetBox(true,'red');
|
---|
38 |
|
---|
39 | // Create the bar plot
|
---|
40 | $lp1 = new LinePlot($datay);
|
---|
41 | $lp1->SetLegend('Temperature');
|
---|
42 |
|
---|
43 | // The order the plots are added determines who's ontop
|
---|
44 | $graph->Add($lp1);
|
---|
45 |
|
---|
46 | // Finally output the image
|
---|
47 | $graph->Stroke();
|
---|
48 |
|
---|
49 | ?>
|
---|
50 |
|
---|
51 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.