CLASS GTextTable (Defined in: jpgraph_table.php : 438)

GTextTable

GTextTable()
Init()
MergeCells()
MergeCol()
MergeRow()
Set()
SetAlign()
SetAnchorPos()
SetBorder()
SetCellAlign()
SetCellColor()
SetCellCountryFlag()
SetCellCSIMTarget()
SetCellFillColor()
SetCellFont()
SetCellImage()
SetCellImageConstrain()
SetCellNumberFormat()
SetCellPadding()
SetColAlign()
SetColColor()
SetColFillColor()
SetColFont()
SetColGrid()
SetColImage()
SetColNumberFormat()
SetColor()
SetColPadding()
SetCSIMTarget()
SetFillColor()
SetFont()
SetGrid()
SetImage()
SetMinColWidth()
SetMinRowHeight()
SetNumberFormat()
SetPadding()
SetPos()
SetRowAlign()
SetRowColor()
SetRowFillColor()
SetRowFont()
SetRowGrid()
SetRowImage()
SetRowNumberFormat()
SetRowPadding()
SetScalePos()
toString()

Class usage and Overview
When visualizing data it is often useful to have both a quick graphical view which can show high level trends and a detailed view with the exact figures. The pro-version of JpGraph now supports the creation of graphic tables in all available graph types. The specification of the tables data, position, fonts, alignment, colors, borders etc. is all fully flexible with an intuitive set of APIs to control the table. In this HowTo we will start by showing how to build basic tables which we will augment with more advanced formatting by introducing the formatting capabilities one by one. In addition to adding data tables to graphs it is also possible to create graphic tables on the fly all by its own. This has the advantage compared with HTML tables to allow users to make copies of the table while maintaining the exact formatting of the table. Figure 2. shows an example with just a graphical table

Class Methods

function GTextTable()
Create a new Graphic text table

Description
Create a new Graphic text table. The next call should either be to specify a value for the table (using GTextTable::Set() ) or a call to GTextTable::Init() to specify the size of table.
See also
GTextTable::Init and GTextTable::Set

Example

$table = new GTextTable();
$table->Set($tableData);

function Init($aRows,$aCols,$aFillText)
Initialize the size for a newly created table

Argument | Default | Description
--- | --- | ---
$aRows | 0 | Number of rows in table
$aCols | 0 | Number of columns in table
$aFillText | '' | Deafult fill value for each cell

Description
After the table has been created the size of the table has to be established. This can either be done by a call to this method or by supplying a matrix in the call to Set().

If You plan on specifying the cells by individual calls to Set($row,$col,$value) then this method must have been called after the creation of the table.

When You set the entire table content with a call to Set() with a full 2D-matrix as argument the size of the matrix will be used to determine the size of the table.

Example

$table = new GTextTable();
$table->Init(5,7);

function MergeCells($aR1,$aC1,$aR2,$aC2,$aHAlign,$aVAlign)
Merge cells in the specified range

Argument | Default | Description
--- | --- | ---
$aR1 |  | Top left row
$aC1 |  | Top left column
$aR2 |  | Bottom right row
$aC2 |  | Bottom right column
$aHAlign | 'center' | Horizontal alignment
$aVAlign | 'center' | Vertical alignment

Description
Merge cells in the specified range. The alignment of the merged cells cab be set by the laet two optional arguments. Note: To merge all cells in a specific row or column use the alternative methods MergeCol() and MergeRow()
See also
GTextTable::MergeRow and GTextTable::MergeCol

Example

// Merge the top 2x2 cells
$table->MergeCells(0,0,1,1,"right");

function MergeCol($aCol,$aHAlign,$aVAlign)
Merge all cells in one column

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aHAlign | 'center' | Horizontal alignment
$aVAlign | 'center' | Vertical alignment

Description
Merge all cells in one column. Note: By default if no alignment is given the content in the merged cells will be centered both horixontally and vertically.
See also
GTextTable::MergeCells and GTextTable::MergeRow

Example

$table->MergeCol(3);

function MergeRow($aRow,$aHAlign,$aVAlign)
Merge all cells in one row.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aHAlign | 'center' | Horizontal alignment
$aVAlign | 'center' | Vertical alignment

Description
Merge all cells in one row. Note: By default if no alignment is given the content in the merged cells will be centered both horixontally and vertically.
See also
GTextTable::MergeCells and GTextTable::MergeCol

Example

$table->MergeRow(2,"right","top");

function Set($aArg1,$aArg2,$aArg3)
Set the value in cell or cells

Argument | Default | Description
--- | --- | ---
$aArg1 |  | 2D-Array or Row index
$aArg2 | NULL | [Oprional] Columns index
$aArg3 | NULL | (Optional) Value for cell

Description
This method is used to put values in a cell or initialize the table using a 2D-matrix. The method is polymorphic and can be called in two ways

1. Set($aTableMatrix), Specify the entire table by supplying a 2D-Matrix
2. Set($aRow,$aCol,$aValue), Set the value in a specific cell. Note that if You use this method then the size of the table muts have been previously specified with a call to Init()

Note: If the table is initialized with an 2D-matrix then there is no need to call the Init() method since the ovberall size of the table will be set to the same as the supplied matrix. Note: After the entire table have beedn specified with an initial 2D-array it is of course still possible to modify/set individual values with a call to the second version of the table.
See also
GTextTable::Init

Example

// Create a new table from a 2D-array
$data = array(
array("Jun",34,18,13),
array("Jul",15,9,12));
$table = new GTextTable();
$table->Set($data);
$table->SetAlign("right");
...
// Create a table by setting individual cells
$table = new GTextTable();
$table->Init(5,7); // 5 rows by 7 column sized table
for($i=0; $i < 5; ++$i) {
for($j=0; $j < 7; ++$j) {
$table->Set(0,0,$data[$i][$j]);
}
}
...
$table->Set(0,0,$data1);

function SetAlign($aR1HAlign,$aC1VAlign,$aR2,$aC2,$aHArg,$aVArg)
Set cell alignment for entire table or range of cells

Argument | Default | Description
--- | --- | ---
$aR1HAlign | null | Top left row OR horizontal alignment
$aC1VAlign | null | Top left column OR vertical alignment
$aR2 | null | Bottom right row
$aC2 | null | Bottom right column
$aHArg | null | Horizontal alignment
$aVArg | 'center' | Vertical alignment

Description
Set cell alignment for entire table or range of cells. The alignment fcan be specifed both horizontally and vertically. The possible settings for horizontal alignment are "left", "center", "right" Vertical alignment can be set as "top","center","bottom" Note that the alignment options are specified as strings.
See also
GTextTable::SetCellAlign, GTextTable::SetRowAlign and GTextTable::SetColAlign

Example

// Set the default alignment for the entire table
$table->SetAlign("right");
// The set the first column to use left alignment
$table->SetColAlign(0,"left");

function SetAnchorPos($aXAnchor,$aYAnchor)
Specify where the anchor position of the table should be

Argument | Default | Description
--- | --- | ---
$aXAnchor |  | Horizontal anchor
$aYAnchor | 'top' | Vertical anchor

Description
Specify where the anchor of the table should be. By default the anchor is top left corner so that the positoin you specify for the table is taken as the top left corner. This can be adjusted horixontally as "left", "center" or "right" Vertically it can be adjusted as "top","center","bottom"
See also
GTextTable::SetPos and GTextTable::SetScalePos

Example

// Make the position refer to the center of the table
$table->SetAnchorPos('center','center');

function SetBorder($aWeight,$aColor)
Set the color and weight on the border around the table-

Argument | Default | Description
--- | --- | ---
$aWeight |  | Weight of border
$aColor |  | Color of border

Description
Set the color and weight on the border around the table. By default the border is a 1 pixel black solid line. Note: Specify a weight of 0 to disable the border entirely.
See also
GTextTable::SetGrid

Example

...
$table->SetBorder(2,"navy");
...

function SetCellAlign($aRow,$aCol,$aHorAlign,$aVertAlign)
Set cell alignment for a specified cell.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aHorAlign |  | Horizontal alignment
$aVertAlign | 'bottom' | Vertical alignment

Description
Set cell alignment for a specified cell. The alignment can be specifed both horizontally and vertically. The possible settings for horizontal alignment are "left", "center", "right" Vertical alignment can be set as "top","center","bottom" Note that the alignment options are specified as strings.
See also
GTextTable::SetAlign, GTextTable::SetColAlign and GTextTable::SetRowAlign

Example

$table->SetCellAlign(2,5,'left');

function SetCellColor($aRow,$aCol,$aColor)
Set font color for a specific cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aColor |  | Font color

Description
Set font color for a specific cell. Note: To set the default color for all cells use the SetColor() method.
See also
GTextTable::SetColor, GTextTable::SetRowColor and GTextTable::SetColColor

Example

$table->SetCellColor(3,1,'darkred');

function SetCellCountryFlag($aRow,$aCol,$aFlag,$aScale,$aMix,$aStdSize)
Set a country flag in the background of the specified cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aFlag |  | Flag specification partial name or index
$aScale |  | Scaling factor to be used
$aMix |  | Blending factor (0-100)
$aStdSize |  | Which original size of flag image to use

Description
Set a country flag in the background of the specified cell. Before this method can be used make sure that the file "jpgraph_flags.php" is included in the script. All supported countries can be specified by setting the '$aFlag" parameter to either

1. Numeric index, (0-238)
2. Full or partial name, e.g. "norway"
3. The unique string index for the country

For a list of all available flags please run the file "listallflags.php" in the Example directory.

The parameter "$aMix" is a value between 0-100 and specifies the blend factor for the flag.

The paraneter $aStdSize specifes one of three orignal izes of flag where size can be one of

1. FLAGSIZE1, corresponds to an original flag size of 35x35 pixels
2. FLAGSIZE2, corresponds to an original flag size of 60x60',
3. FLAGSIZE3, corresponds to an original flag size of 100x100',
4. FLAGSIZE4, corresponds to an original flag size of roughly 400x400

For best result always use an original flag that is at least as big as the size that is wanted, i.e. even though the scaling factor can be used to arbitrary change the size of any of these original flags the result when up scaling is not optimal since there is a need to interpolate. By starting with a larger original image which is the downsampled the result is much better.

Note 1: In order to lock either the height or the width of the flag to a specific value use the SetImageConstrain() method.

See also
GTextTable::SetImage

Example

// Set one row with a number of country flags and constrain
// the height to be 20 pixels
$countries = array('united states','united kingdom','french republic','denmark','iceland','canada');
$n = count($countries);
for($i=0; $i < $n; ++$i ) {
$table->SetCellCountryFlag(1,$i+1,$countries[$i]);
$table->SetCellImageConstrain(1,$i+1,TIMG_HEIGHT,20);
}

function SetCellCSIMTarget($aRow,$aCol,$aTarget,$aAlt)
Specify URL for CSIM target

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aTarget |  | Target URL
$aAlt |  | ALT text

Description
Specify URL and optional ALT text for CSIM target for the specified cell.
See also
GTextTable::SetCSIMTarget

Example

$table->SetCellCSIMTarget(3,0,'detail.php','View detailes');

function SetCellFillColor($aRow,$aCol,$aColor)
Specify background color in a cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aColor |  | background color

Description
Specify background color in a cell. Note: To set the default background fill color for all cells usde the SetFillColor() method.
See also
GTextTable::SetFillColor, GTextTable::SetRowFillColor and GTextTable::SetColFillColor

Example

// Highlight cell (7,0)
$table->SetCellFillColor(7,0,'yellow');

function SetCellFont($aRow,$aCol,$aFF,$aFS,$aFSize)
Specify font family and style for a specific cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aFF |  | Font family
$aFS |  | Font style
$aFSize |  | Font size

Description
Specify font family and style for a specific cell. Note:To set the default font for all cells use the SetFont() method.
Returns
VOID
See also
GTextTable::SetFont, GTextTable::SetRowFont and GTextTable::SetColFont

Example

// Highlight cell (4,1) with red on yellow background
$table->SetCellFillColor(4,1,'yellow');
$table->SetCellColor(4,1,'darkred');
$table->SetCellFont(4,1,FF_ARIAL,FS_BOLD,12);

function SetCellImage($aRow,$aCol,$aFile,$aScale,$aMix)
Set a background image in the specified cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aFile |  | Image file name
$aScale |  | Image scale factor
$aMix |  | Blending factor (0-100)

Description
Set a background image in the specified cell. The image is stored in the file with the name given as the third parameter. The image name must end with a valid image prefix, i.e. one of ".png", ".jpg" or possibly ".gif" Note: To set a default background image for all cells in the table use the SetImage() method.
Returns
VOID
See also
GTextTable::SetImage, GTextTable::SetRowImage and GTextTable::SetColImage

Example

// Put the image 'warning.jpg' in cell (3,6) and
// scale the image to half size
$table->SetCellImage(3,6,'warning.jpg',0.5);

function SetCellImageConstrain($aRow,$aCol,$aType,$aVal)
Lock either the image height or width in a particular cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aType |  | Specify width or height constrain
$aVal |  | Value of constrain

Description
Use this method to locj either the width or height of the image ina a cell. The non-specified image width or height will be automatically determied so that the orignal propertion of the image is maintained. The $aType parameter is used to indicate if the value given should be interpretated as width or height constarin and is specifed as either

1. TIMG_WIDTH, Interpret as width
2. TIMG_HEIGHT,Interpret as height

Returns
VOID
See also
GTextTable::SetCellImage

Example

// Make sure image in cell (3,1) is exactlyb 20 pixels
// in height
$table->SetCellImageConstrain(3,1,TIMG_HEIGHT,20);

function SetCellNumberFormat($aRow,$aCol,$aF)
Set number format in cell

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aF |  | Format string

Description
Set number format in cell. The number format should be given in the style of printf() family format strings. A cell that contains non numeric data will not be affected in any way by this method. Note: It is the resposnibility of the client to make any necessary rounding of the numbers.

Example

// Use two decimals with leading 0 on numbers
$this->SetCellNumberFormat(3,1,'%0.2f');

function SetCellPadding($aRow,$aCol,$aPad)
Set internal cell margin

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aCol |  | Column index
$aPad |  | Internal cell margin (in pixels)

Description
Set internal cell margins in pixels. By default the internal cell padding is 5 pixels. Note: To change the default cell padding for all cells in the table use the Setpadding() method.

Example

// Set 8 pixel cell padding for cell (1,3)
$table->SerCellPadding(3,1,8);

function SetColAlign($aCol,$aHorAlign,$aVertAlign)
Set cell alignment for an entire column of cells.

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aHorAlign |  | Horizontal alignment
$aVertAlign | 'bottom' | Vertical alignment

Description
Set cell alignment for an entire column of cells. The alignment can be specifed both horizontally and vertically. The possible settings for horizontal alignment are "left", "center", "right" Vertical alignment can be set as "top","center","bottom" Note that the alignment options are specified as strings. Note2: In order to set the default alignment for all cells in the table use the SetAlign() method.
See also
GTextTable::SetAlign, GTextTable::SetCellAlign and GTextTable::SetRowAlign

Example

$table->SetColAlign(3,'center');

function SetColColor($aCol,$aColor)
Set font color for a entire column.

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aColor |  | Font color

Description
Set font color for a entire column. Note: To set the default color for all cells use the SetColor() method.
See also
GTextTable::SetColor, GTextTable::SetCellColor and GTextTable::SetRowColor

Example

$table->SetColColor(2,'blue');

function SetColFillColor($aCol,$aColor)
Specify background color in an entire column of cells

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aColor |  | Background color

Description
Specify background color in an entire column of cells. Note: To set the default background fill color for all cells usde the SetFillColor() method.
Returns
VOID
See also
GTextTable::SetCellFillColor, GTextTable::SetFillColor and GTextTable::SetRowFillColor

Example

// Highlight column 3 with white text on gray bakground
$table->SetColFillColor(3,'darkgray');
$table->SetColColor(3,'white');

function SetColFont($aCol,$aFF,$aFS,$aFSize)
Specify font family and style for an entire column of cells

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aFF |  | Font family
$aFS |  | Font style
$aFSize |  | Font size

Description
Specify font family and style for an entire column of cells Note:To set the default font for all cells use the SetFont() method.
See also
GTextTable::SetFont, GTextTable::SetRowFont and GTextTable::SetCellFont

Example

$table->SetColFont(0,FF_ARIAL,FS_NORMAL,12);

function SetColGrid($aCol,$aWeight,$aColor,$aStyle)
Set style, color and width of a specified vertical grid line

Argument | Default | Description
--- | --- | ---
$aCol |  | Grind line to specify
$aWeight |  | Width of line
$aColor |  | Color of line
$aStyle |  | Grid line style (see below)

Description
Set style, color and width of a specified vertical grid line in the table. The grid lines are numbered from 1 to columns-1 and from left to right. The grid lines are defined as the internal lines in the table. The outer border of the table is controlled separately with the SetBorder() method.

The style for the grid lines can be one of the following three

1. TGRID_SINGLE, Single solid line of the given color and weight
2. TGRID_DOUBLE, Two solid lines of the given color and weight. The distance between the lines is the same as the weight.
3. TGRID_DOUBLE2, Two solid lines of the given color. The first line has twice the weight as the second. This type of line is often used to mark a summation line in a table.

Note: In order to remove all grid lines in the table set the width to 0.

Example

$table->SetColGrid(1,1,'black',TGRID_DOUBLE2);

function SetColImage($aCol,$aFile,$aScale,$aMix)
Set background image for an entire column of cells

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aFile |  | Filename of image
$aScale |  | Scale of image
$aMix |  | Blend factor for image (0-100)

Description
Set background image for an entire column of cells. The should be stored in a file whos filename is given as the second parameter. The scdaling factor can be specifed as an arbitary floating point value between 0-1.

The Blend factor is specified as an integer between 0 and 100 where 100 is 100% blend factor.

See also
GTextTable::SetImage, GTextTable::SetCellImage and GTextTable::SetRowImage

Example

$table->SetColImage(2,$imageFileNmae,0.7);

function SetColNumberFormat($aCol,$aF)
Set number format in an entire column of cells

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aF |  | Format string

Description
Set number format in an entire column of cells. The number format should be given in the style of printf() family format strings. A cell that contains non numeric data will not be affected in any way by this method. Note: It is the resposnibility of the client to make any necessary rounding of the numbers.
See also
GTextTable::SetCellNumberFormat, GTextTable::SetNumberFormat and GTextTable::SetRowNumberFormat

Example

// Use two decimals with leading zero
$table->SetColNumberFormat(4,'%0.2f');

function SetColor($aArgR1,$aC1,$aR2,$aC2,$aArg)
Set font color for the whole table or a range of cells.

Argument | Default | Description
--- | --- | ---
$aArgR1 |  | Top left row OR font color
$aC1 | null | Top left column
$aR2 | null | Bottom right row
$aC2 | null | Bottom right column
$aArg | null | Font color

Description
Set font color for the whol table or a range of cells. Thie method is polymorphic an can be called in two ways

- SetColor($aColor), Set the font color for the entire table
- SetColor($aR1,$aC1,$aR2,$aC2,$aColor), Set the font color for a range of cells specified by the top left and bottom right cell.

See also
GTextTable::SetCellColor, GTextTable::SetRowColor and GTextTable::SetColColor

Example

// Set the font color for the entire table
$table->SetColor('darkgray');
// Set the font color for the top left 2x2 cells
$table->SetColor(0,0,1,1,'blue');

function SetColPadding($aCol,$aPad)
Set internal cell margins in pixels for all cells in the specified column.

Argument | Default | Description
--- | --- | ---
$aCol |  | Column index
$aPad |  | Internal cell margin

Description
Set internal cell margins in pixels for all cells in the specified column. By default the internal cell padding is 5 pixels. Note: To change the default cell padding for all cells in the table use the Setpadding() method.
See also
GTextTable::SetCellPadding, GTextTable::SetPadding and GTextTable::SetRowPadding

Example

$table->SetColPadding(3,12):

function SetCSIMTarget($aTarget,$aAlt,$aAutoTarget)
Set URL CSIM target for all cells in the table

Argument | Default | Description
--- | --- | ---
$aTarget |  | Target URL
$aAlt |  | ALT etxt
$aAutoTarget |  | TRUE=Append auto row and column argument

Description
Set URL CSIM target for all cells in the table. If the $aAutoTarget is set to TRUE then an additional GET method argument will be appended to the base URL. This makes it possible to spcify a base URL which will then be called with the two additional arguments "row" and "col". This can be used to determien from which cell the click was made.

An example will clarify this.

Assume that the base URL is "target.php". If we then setup the table with $table->SetCSIMTarget('target.php','Click for details',true); then if the user clicks the cell (1,1) the url called will be "target.php?row=1&col=1", for cell (2,3) the call would be "target.php?row=2&col=3" and so on.

Example

// Assume that the base URL is "target.php".
$table->SetCSIMTarget('taregt.php','Click for details',true);

function SetFillColor($aArgR1,$aC1,$aR2,$aC2,$aArg)
Set background image for an entire range of cells or entire table

Argument | Default | Description
--- | --- | ---
$aArgR1 |  | Top left row OR color
$aC1 |  | Top left column
$aR2 |  | Bottom right row
$aC2 |  | Bottom right column
$aArg |  | Color for range

Description
Set background image for an entire range of cells or entire table. This method is polymorphic and can be called in two ways

1. SetFillColor($aFillColor), Set fill color for all cells in the table
2. SetFillColor($aR1,$aC1,$aR2,$aC2,$aFillColor), Set fill color for a range of cells

Returns
VOID
See also
GTextTable::SetCellFillColor, GTextTable::SetColFillColor and GTextTable::SetRowFillColor

Example

// Set default fill color for entire table
$table->SetFillColor('lightgray');
// Highlight top left 2x2 cells
$table->SetFillColor(0,0,1,1,'yellow');

function SetFont()
Set font for entire table or range of cells.

Description
Set font for entire table or range of cells. This si a polymorphic method and can be called in two ways-

1. SetFont($aFF,$aFS,$aFSize), Set default font for entire table
2. SetFont($aR1,$aC1,$aR2,$aC2,$aFF,$aFS,$aFSize), Set default font for range of cells table

Returns
VOID
See also
GTextTable::SetCellFont, GTextTable::SetRowFont and GTextTable::SetColFont

Example

// Set default font for entire table
$table->SetFont(FF_TIMES,FS_NORMAL,11);
// Set font for the two top rows
$table->SetFont(0,0,1,5,FF_ARIAL,FS_BOLD,12);

function SetGrid($aWeight,$aColor,$aStyle)
Set style, color and width of all table grid lines

Argument | Default | Description
--- | --- | ---
$aWeight |  | Width of grid lines
$aColor |  | Color of grid lines
$aStyle |  | Style of grid lines

Description
Set style, color and width of all table grid lines. The grid lines are defined as the internal lines in the table. The outer border of the table is controlled separately with the SetBorder() method.

The style for the grid lines can be one of the following three

1. TGRID_SINGLE, Single solid line of the given color and weight
2. TGRID_DOUBLE, Two solid lines of the given color and weight. The distance between the lines is the same as the weight.
3. TGRID_DOUBLE2, Two solid lines of the given color. The first line has twice the weight as the second. This type of line is often used to mark a summation line in a table.

Note: In order to remove all grid lines in the table set the width to 0.
Returns
VOID
See also
GTextTable::SetColGrid and GTextTable::SetRowGrid

Example

// Set the default grid lines for whole table
$table->SetGrid(1,'gray',TGRID_SOLID);

function SetImage($aFileR1,$aScaleC1,$aMixR2,$aC2,$aFile,$aScale,$aMix)
Set background image for an entire range of cells or entire table

Argument | Default | Description
--- | --- | ---
$aFileR1 |  | Top left row OR file name
$aScaleC1 |  | Top left column OR scale
$aMixR2 |  | Bottom right row OR blend factor
$aC2 |  | Bottom right column
$aFile |  | Image filename
$aScale |  | Image scale
$aMix |  | Blend factor (0-100)

Description
Set background image for an entire rnage of cells or entire table. The should be stored in a file whos filename is given as the second parameter. The scdaling factor can be specifed as an arbitary floating point value between 0-1.

The Blend factor is specified as an integer between 0 and 100 where 100 is 100% blend factor.

See also
GTextTable::SetCellImage, GTextTable::SetRowImage and GTextTable::SetColImage

Example

// Set the same background image for all cells in the table
$table->SetImage($fileName,0.8);
// Set the background image for the top 2x2 cells
$table->SetImage(0,0,1,1,$fileName,0.8);

function SetMinColWidth($aColWidth,$aWidth)
Specify minimum column width

Argument | Default | Description
--- | --- | ---
$aColWidth |  | Width or column index
$aWidth |  | Width

Description
Specify minimum column width of all columns or a specific column. The method is polymorphic and can be called in two different ways.

1. SetMinColWidth($aWidth), Set the minimum width for all columns in the table
2. SetMinColWidth($aColIndex,$aWidth), Set the minimum width for the specified column

Note that the column width will always be wide enough to hold the widest text or image. This means that the table will never to adny clipping of data.
Returns
VOID
See also
GTextTable::SetMinRowHeight

Example

// Make all columns at least 50 pixels wide
$table->SetMinColWidth(50);

function SetMinRowHeight($aRowHeight,$aHeight)
Specify minimum row height of all rows or a specific row.

Argument | Default | Description
--- | --- | ---
$aRowHeight |  | Row index or height
$aHeight |  | Height

Description
Specify minimum row height of all rows or a specific row. The method is polymorphic and can be called in two different ways.

1. SetMinRowHeight($aWidth), Set the minimum height for all rows in the table
2. SetMinRowHeight($aRowIndex,$aWidth), Set the minimum height for the specified table row

Note that the row height will always be tall enough to hold the highest text or image. This means that the table will never to adny clipping of the data.
See also
GTextTable::SetMinColWidth

Example

// Make the top row at least 40 pixels in height
$table->SetMinRowHeight(0,40);

function SetNumberFormat($aArgR1,$aC1,$aR2,$aC2,$aArg)
Set number format for entire table or a range of cells.

Argument | Default | Description
--- | --- | ---
$aArgR1 |  | Top left row OR format string
$aC1 |  | Top left column
$aR2 |  | Bottom right row
$aC2 |  | Bottom right column
$aArg |  | Format string

Description
Set number format for entire table or a range of cells. The number format should be given in the style of printf() family format strings. A cell that contains non numeric data will not be affected in any way by this method. The method is polymorphic and can be called in two ways

1. SetNumberFormat($aFormat), Set the number format for the entire table
2. SetNumberFormat($aFormat), Set the number format for a range of cells

Note: It is the resposnibility of the client to make any necessary rounding of the numbers.
See also
GTextTable::SetCellNumberFormat, GTextTable::SetRowNumberFormat and GTextTable::SetColNumberFormat

Example

$table->SetNumberFormat('%0.2f');

function SetPadding($aArgR1,$aC1,$aR2,$aC2,$aPad)
Set internal cell margins for all cells in the specified range or entire table

Argument | Default | Description
--- | --- | ---
$aArgR1 |  | Top left row OR cell padding
$aC1 |  | Top left column
$aR2 |  | Bottom right row
$aC2 |  | Bottom right column
$aPad |  | Cell padding

Description
Set internal cell margins for all cells in the specified range or entire table By default the internal cell padding is 5 pixels. This method is polymorphic and can be called in two ways

1. SetPadding($aPadding), Set padding for all cells in the table
2. SetPadding($aR1,$aC1,$aR2,$aC2,$aPadding), Set padding for the specified range of cells

See also
GTextTable::SetCellPadding, GTextTable::SetColPadding and GTextTable::SetRowPadding

Example

// First set the default padding for all cells
$table->SetPadding(8);
// Set the padding much larger in the top left 2x2 cells
$table->SetPadding(0,0,1,1,20);

function SetPos($aX,$aY)
Set absolute pixel position the table

Argument | Default | Description
--- | --- | ---
$aX |  | X Coordinate of top left corner
$aY |  | Y Coordinate of top left corner

Description
Set absolute pixel position for top left corner of the table. This is the simplest way of positioning a table in the graph area.

Note: The anchor position of the table can also be adjusted by the method SetAnchorPos(). By deagule the top left corner of the table is aligned with the specified coordinates.

See also
GTextTable::SetScalePos

Example

$table->SetPos(10,10);

function SetRowAlign($aRow,$aHorAlign,$aVertAlign)
Set cell alignment for an entire row of cells.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aHorAlign |  | Horizontal alignment
$aVertAlign | 'bottom' | Vertical alignment

Description
Set cell alignment for an entire row of cells. The alignment can be specifed both horizontally and vertically. The possible settings for horizontal alignment are "left", "center", "right" Vertical alignment can be set as "top","center","bottom" Note that the alignment options are specified as strings. Note2: In order to set the default alignment for all cells in the table use the SetAlign() method.
See also
GTextTable::SetAlign, GTextTable::SetCellAlign and GTextTable::SetColAlign

Example

$table->SetRowAlign(6,'right');

function SetRowColor($aRow,$aColor)
Set font color for an entire row.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aColor |  | Font color

Description
Set font color for an entire row. Note: To set the default color for all cells use the SetColor() method.
See also
GTextTable::SetColor, GTextTable::SetCellColor and GTextTable::SetColColor

Example

$table->SetRowColor(5,'red');

function SetRowFillColor($aRow,$aColor)
Specify background color in an entire row of cells.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aColor |  | Background color

Description
Specify background color in an entire row of cells. Note: To set the default background fill color for all cells usde the SetFillColor() method.
See also
GTextTable::SetFillColor, GTextTable::SetCellFillColor and GTextTable::SetColFillColor

Example

// Highlight row 0 with white text on gray bakground
$table->SetRowFillColor(0,'darkgray');
$table->SetRowColor(0,'white');

function SetRowFont($aRow,$aFF,$aFS,$aFSize)
Specify font family and style for an entire row of cells

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aFF |  | Font family
$aFS |  | Font style
$aFSize |  | Font size

Description
Specify font family and style for an entire row of cells Note:To set the default font for all cells use the SetFont() method.
See also
GTextTable::SetFont, GTextTable::SetCellFont and GTextTable::SetColFont

Example

$table->SetRowFont(0,FF_ARIAL,FS_NORMAL,12);

function SetRowGrid($aRow,$aWeight,$aColor,$aStyle)
Set style, color and width of a specified horizontal grid line

Argument | Default | Description
--- | --- | ---
$aRow |  | Grind line to specify
$aWeight |  | Width of line
$aColor |  | Color of line
$aStyle |  | Grid line style (see below)

Description
Set style, color and width of a specified horizontal grid line in the table. The grid lines are numbered from 1 to columns-1 and from top to bottom. The grid lines are defined as the internal lines in the table. The outer border of the table is controlled separately with the SetBorder() method.

The style for the grid lines can be one of the following three

1. TGRID_SINGLE, Single solid line of the given color and weight
2. TGRID_DOUBLE, Two solid lines of the given color and weight. The distance between the lines is the same as the weight.
3. TGRID_DOUBLE2, Two solid lines of the given color. The first line has twice the weight as the second. This type of line is often used to mark a summation line in a table.

Note: In order to remove a grid line in the table set the width to 0.
See also
GTextTable::SetGrid and GTextTable::SetColGrid

Example

// Add a double line of width=2 to mark the summation row
// in a atable
$table->SetRowGrid(4,2,'black',TGRID_DOUBLE2);

function SetRowImage($aRow,$aFile,$aScale,$aMix)
Set background image for an entire row of cells

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aFile |  | Filename of image
$aScale |  | Scale of image
$aMix |  | Blend factor for image (0-100)

Description
Set background image for an entire row of cells. The should be stored in a file whos filename is given as the second parameter. The scdaling factor can be specifed as an arbitary floating point value between 0-1.

The Blend factor is specified as an integer between 0 and 100 where 100 is 100% blend factor.

See also
GTextTable::SetImage, GTextTable::SetCellImage and GTextTable::SetColImage

Example

$table->SetRowImage(1,$fileName,0.5,60);

function SetRowNumberFormat($aRow,$aF)
Set number format in an entire row of cells.

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aF |  | Format string

Description
Set number format in an entire row of cells. The number format should be given in the style of printf() family format strings. A cell that contains non numeric data will not be affected in any way by this method. Note: It is the resposnibility of the client to make any necessary rounding of the numbers.
Returns
VOID
See also
GTextTable::SetNumberFormat, GTextTable::SetCellNumberFormat and GTextTable::SetCellNumberFormat

Example

// Use 2 decimals with leading zero
$table->SetRowNumberFormat('%0.2f');

function SetRowPadding($aRow,$aPad)
Set internal cell margins in pixels for all cells in the specified row

Argument | Default | Description
--- | --- | ---
$aRow |  | Row index
$aPad |  | Internal cell margin

Description
Set internal cell margins in pixels for all cells in the specified row. By default the internal cell padding is 5 pixels. Note: To change the default cell padding for all cells in the table use the Setpadding() method.
See also
GTextTable::SetCellPadding, GTextTable::SetPadding and GTextTable::SetColPadding

Example

$table->SetRowPadding(4,12);

function SetScalePos($aX,$aY)
Set position of the entire table on the graphn using the current X,Y sclae

Argument | Default | Description
--- | --- | ---
$aX |  | X-position according to current scle
$aY |  | Y position according to curent scale

Description
This method makes it possible to place the table at specific scale coordinates within the plot area of the graph. This could for example be used to place a small table at each of the data points in a line graph (or some other type of plot) to show fyrther details.

Note: The anchor position of the table can also be adjusted by the method SetAnchorPos(). By deagule the top left corner of the table is aligned with the specified coordinates.

Returns
VOID
See also
GTextTable::SetPos and GTextTable::SetAnchorPos

Example

// Create the tables and position them at each data point
// In the line plot
// The data for each table is held in $tabledata[] array
// and the plot data is available in $datay[] array.
$n = count($datay);
$table=array();
for($i=0; $i < $n; ++$i ) {
$table[$i] = new GTextTable();
$table[$i]->Set($tabledata[$i]);
$table[$i]->SetScalePos($i,$datay[$i]);
$table[$i]->SetFillColor('lightyellow@0.5');
// We center all tables on the data point
$table[$i]->SetAnchorPos('center','middle');
$graph->Add($table[$i]);
}
...
// Create the line
$l1 = new LinePlot($datay);
$l1->SetWeight(2);
$graph->Add($l1);
...

function toString()
Return basic HTML version of the table

Description
Return basic HTML version of the table. Note that this is just a very basic representation of the table without any of the formatting applied the table.

Example

$str = $table->toString();