1 | <?php
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_canvas.php');
|
---|
4 | require_once ('jpgraph/jpgraph_table.php');
|
---|
5 |
|
---|
6 | $data = array( array('','Jan','Feb','Mar','Apr','May','Jun'),
|
---|
7 | array('Team 1','15.2', '12.5', '9.9', '70.0', '22.4','21.5'),
|
---|
8 | array('Team 2','23.9', '14.2', '18.6', '71.3','66.8','42.6'),
|
---|
9 | array('Sum:')
|
---|
10 | );
|
---|
11 |
|
---|
12 | $r = count($data);
|
---|
13 | $c = 7;
|
---|
14 |
|
---|
15 | for( $i=1; $i < $c; ++$i ) {
|
---|
16 | $tmp=0;
|
---|
17 | for($j=1; $j < $r-1; ++$j) {
|
---|
18 | $tmp += $data[$j][$i];
|
---|
19 | }
|
---|
20 | $data[3][$i] = sprintf('%2.1f',$tmp);;
|
---|
21 | }
|
---|
22 |
|
---|
23 | $graph = new CanvasGraph(350,200);
|
---|
24 |
|
---|
25 | $table = new GTextTable();
|
---|
26 | $table->Init();
|
---|
27 | $table->Set($data);
|
---|
28 | $table->SetBorder(2,'black');
|
---|
29 |
|
---|
30 | // Highlight summation row
|
---|
31 | $table->SetRowFillColor($r-1,'yellow');
|
---|
32 | $table->SetCellAlign($r-1,0,'right');
|
---|
33 |
|
---|
34 | // Setup row and column headers
|
---|
35 | $table->SetRowFont(0,FF_ARIAL,FS_NORMAL,10);
|
---|
36 | $table->SetRowColor(0,'navy');
|
---|
37 | $table->SetRowFillColor(0,'lightgray');
|
---|
38 |
|
---|
39 | $table->SetColFont(0,FF_ARIAL,FS_NORMAL,10);
|
---|
40 | $table->SetColColor(0,'navy');
|
---|
41 | $table->SetColFillColor(0,'lightgray');
|
---|
42 |
|
---|
43 | $table->SetRowGrid($r-1,1,'black',TGRID_DOUBLE);
|
---|
44 |
|
---|
45 | $table->SetFont(1,4,2,6,FF_TIMES,FS_NORMAL,18);
|
---|
46 | $table->SetFillColor(1,1,2,3,'red');
|
---|
47 |
|
---|
48 | $table->MergeCol(1);
|
---|
49 | $graph->Add($table);
|
---|
50 | $graph->Stroke();
|
---|
51 |
|
---|
52 | ?>
|
---|
53 |
|
---|