source: trunk/xgraph/jpgraph/Examples/table_flagex1.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.8 KB
Line 
1<?php
2include '../jpgraph.php';
3include '../jpgraph_canvas.php';
4include '../jpgraph_table.php';
5include '../jpgraph_iconplot.php';
6include '../jpgraph_flags.php';
7
8// Setup a basic canvas to use as graph to add the table
9$graph = new CanvasGraph(500,200);
10
11// Setup the basic table
12$data = array(
13    array('Areas'),
14    array(''),
15    array('','USA','UK','France','Denmark','Iceland','Canada'),
16    array('Feb',13,17,15,8,3,9),
17    array('Mar',34,35,26,20,22,16),
18    array('Apr',41,43,49,45,51,47),
19    array('Sum:',88,95,90,73,76,72));
20
21$countries = array('united states','united kingdom','french republic','denmark','iceland','canada');
22
23// Create a basic table and default fonr
24$table = new GTextTable();
25$table->Set($data);
26$table->SetFont(FF_TIMES,FS_NORMAL,11);
27
28// Adjust the font for row 0 and 6
29$table->SetColFont(0,FF_ARIAL,FS_BOLD,11);
30$table->SetRowFont(6,FF_TIMES,FS_BOLD,12);
31
32// Set the minimum heigth/width
33$table->SetMinRowHeight(2,10);
34$table->SetMinColWidth(70);
35
36// Add some padding (in pixels)
37$table->SetRowPadding(2,0);
38$table->SetRowGrid(6,1,'darkgray',TGRID_DOUBLE2);
39
40// Setup the grid
41$table->SetGrid(0);
42$table->SetRowGrid(6,1,'black',TGRID_DOUBLE2);
43
44// Merge all cells in row 0
45$table->MergeRow(0);
46
47// Set aligns
48$table->SetAlign(3,0,6,6,'right');
49$table->SetRowAlign(1,'center');
50$table->SetRowAlign(2,'center');
51
52// Set background colors
53$table->SetRowFillColor(0,'lightgray@0.5');
54$table->SetColFillColor(0,'lightgray@0.5');
55
56// Add the country flags in row 1
57$n = count($countries);
58for($i=0; $i < $n; ++$i ) {
59    $table->SetCellCountryFlag(1,$i+1,$countries[$i],0.5);
60    $table->SetCellImageConstrain(1,$i+1,TIMG_HEIGHT,20);
61}
62
63// Add the table to the graph
64$graph->Add($table);
65
66// Send back the table graph to the client
67$graph->Stroke();
68
69?>
70
Note: See TracBrowser for help on using the repository browser.