1 | <?php
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_odo.php');
|
---|
4 |
|
---|
5 | // Create a new odometer graph (width=250, height=200 pixels)
|
---|
6 | $graph = new OdoGraph(570,220);
|
---|
7 |
|
---|
8 | $nstyle = array(
|
---|
9 | NEEDLE_STYLE_SIMPLE, NEEDLE_STYLE_STRAIGHT, NEEDLE_STYLE_ENDARROW,
|
---|
10 | NEEDLE_STYLE_SMALL_TRIANGLE,NEEDLE_STYLE_MEDIUM_TRIANGLE,
|
---|
11 | NEEDLE_STYLE_LARGE_TRIANGLE
|
---|
12 | );
|
---|
13 |
|
---|
14 | $captions = array(
|
---|
15 | "NEEDLE_STYLE_SIMPLE","NEEDLE_STYLE_STRAIGHT","NEEDLE_STYLE_ENDARROW",
|
---|
16 | "NEEDLE_STYLE_SMALL_TRIANGLE","NEEDLE_STYLE_MEDIUM_TRIANGLE",
|
---|
17 | "NEEDLE_STYLE_LARGE_TRIANGLE"
|
---|
18 | );
|
---|
19 |
|
---|
20 | $odo = array();
|
---|
21 |
|
---|
22 | for( $i=0; $i < 6; ++$i ) {
|
---|
23 | $odo[$i] = new Odometer();
|
---|
24 | $odo[$i]->SetColor("lightyellow");
|
---|
25 | $odo[$i]->needle->Set(80);
|
---|
26 | $odo[$i]->needle->SetStyle($nstyle[$i]);
|
---|
27 | $odo[$i]->caption->Set($captions[$i]);
|
---|
28 | $odo[$i]->caption->SetFont(FF_FONT1);
|
---|
29 | $odo[$i]->caption->SetMargin(3);
|
---|
30 | }
|
---|
31 |
|
---|
32 | // Use the automatic layout engine to positon the plots on the graph
|
---|
33 | $row1 = new LayoutHor( array($odo[0],$odo[1],$odo[2]) );
|
---|
34 | $row2 = new LayoutHor( array($odo[3],$odo[4],$odo[5]) );
|
---|
35 | $col1 = new LayoutVert( array($row1,$row2) );
|
---|
36 |
|
---|
37 | // Add the odometer to the graph
|
---|
38 | $graph->Add($col1);
|
---|
39 |
|
---|
40 | // ... and finally stroke and stream the image back to the browser
|
---|
41 | $graph->Stroke();
|
---|
42 |
|
---|
43 | ?> |
---|