[42] | 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 |
|
---|
| 24 | $graph = new CanvasGraph(350,200);
|
---|
| 25 |
|
---|
| 26 | $table = new GTextTable();
|
---|
| 27 | $table->Init();
|
---|
| 28 | $table->Set($data);
|
---|
| 29 | $table->SetBorder(2,'black');
|
---|
| 30 |
|
---|
| 31 | // Highlight summation row
|
---|
| 32 | $table->SetRowFillColor($r-1,'yellow');
|
---|
| 33 | $table->SetCellAlign($r-1,0,'right');
|
---|
| 34 |
|
---|
| 35 | // Setup row and column headers
|
---|
| 36 | $table->SetRowFont(0,FF_ARIAL,FS_NORMAL,10);
|
---|
| 37 | $table->SetRowColor(0,'navy');
|
---|
| 38 | $table->SetRowFillColor(0,'lightgray');
|
---|
| 39 |
|
---|
| 40 | $table->SetColFont(0,FF_ARIAL,FS_NORMAL,10);
|
---|
| 41 | $table->SetColColor(0,'navy');
|
---|
| 42 | $table->SetColFillColor(0,'lightgray');
|
---|
| 43 |
|
---|
| 44 | $table->SetRowGrid($r-1,1,'black',TGRID_DOUBLE);
|
---|
| 45 |
|
---|
| 46 | $graph->Add($table);
|
---|
| 47 | $graph->Stroke();
|
---|
| 48 |
|
---|
| 49 | ?>
|
---|
| 50 |
|
---|