Class GTextTable
(Defined in: jpgraph_table.php : 459)
 
 GTextTable 
 Init() 
 MergeCells() 
 MergeCol() 
 MergeRow() 
 Set() 
 SetAlign() 
 SetAnchorPos() 
 SetBorder() 
 SetCellAlign() 
 SetCellColor() 
 SetCellCountryFlag() 
 SetCellCSIMTarget() 
 SetCellFillColor() 
 SetCellFont() 
 SetCellImage() 
 SetCellImageConstrain() 
 SetCellNumberFormat() 
 SetCellPadding() 
 SetCellTextOrientation() 
 SetColAlign() 
 SetColColor() 
 SetColFillColor() 
 SetColFont() 
 SetColGrid() 
 SetColImage() 
 SetColNumberFormat() 
 SetColor() 
 SetColPadding() 
 SetColTextOrientation() 
 SetCSIMTarget() 
 SetFillColor() 
 SetFont() 
 SetGrid() 
 SetImage() 
 SetMinColWidth() 
 SetMinRowHeight() 
 SetNumberFormat() 
 SetPadding() 
 SetPos() 
 SetRowAlign() 
 SetRowColor() 
 SetRowFillColor() 
 SetRowFont() 
 SetRowGrid() 
 SetRowImage() 
 SetRowNumberFormat() 
 SetRowPadding() 
 SetRowTextOrientation() 
 SetScalePos() 
 SetTextOrientation() 
 toString() 
 __construct() 
 

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

 

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

ArgumentDefaultDescription
$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);


 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

$table->MergeCol(3);

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

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);



 

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

ArgumentDefaultDescription
$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:

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");

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$aWeight 1 Weight of border
$aColor 'black' 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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$aRow  Row index
$aCol  Column index
$aFlag  Flag specification partial name or index
$aScale 1.0 Scaling factor to be used
$aMix 100 Blending factor (0-100)
$aStdSize 3 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:

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);
}

 

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

ArgumentDefaultDescription
$aRow  Row index
$aCol  Column index
$aTarget  Target URL
$aAlt null ALT text

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

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$aRow  Row index
$aCol  Column index
$aFF  Font family
$aFS  Font style
$aFSize 10 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. 
 
See also:

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);

 

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

ArgumentDefaultDescription
$aRow  Row index
$aCol  Column index
$aFile  Image file name
$aScale 1.0 Image scale factor
$aMix 100 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. 
 
See also:

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);

 

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

ArgumentDefaultDescription
$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
 
 
See also:

Example:

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

 

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

ArgumentDefaultDescription
$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');

 

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

ArgumentDefaultDescription
$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);

 

GTextTable ::
SetCellTextOrientation($aRow, $aCol, $aO)

ArgumentDefaultDescription
$aRow  No description available
$aCol  No description available
$aO  No description available

Description:
No description available.

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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. 
 
See also:

Example:

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

 

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

ArgumentDefaultDescription
$aCol  Column index
$aFF  Font family
$aFS  Font style
$aFSize 10 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:

Example:

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

 

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

ArgumentDefaultDescription
$aCol  Grind line to specify
$aWeight 1 Width of line
$aColor 'black' Color of line
$aStyle TGRID_SINGLE 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);

 

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

ArgumentDefaultDescription
$aCol  Column index
$aFile  Filename of image
$aScale 1.0 Scale of image
$aMix 100 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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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  
 
See also:

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');

 

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

ArgumentDefaultDescription
$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:

Example:

$table->SetColPadding(3,12):

 

GTextTable ::
SetColTextOrientation($aCol, $aO)

ArgumentDefaultDescription
$aCol  No description available
$aO  No description available

Description:
No description available.

 

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

ArgumentDefaultDescription
$aTarget  Target URL
$aAlt null ALT etxt
$aAutoTarget false 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);

 

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

ArgumentDefaultDescription
$aArgR1  Top left row OR color
$aC1 null Top left column
$aR2 null Bottom right row
$aC2 null Bottom right column
$aArg null 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
 
 
See also:

Example:

// Set default fill color for entire table
$table->SetFillColor('lightgray');

// Highlight top left 2x2 cells
$table->SetFillColor(0,0,1,1,'yellow');

 

GTextTable ::
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
 
 
See also:

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);

 

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

ArgumentDefaultDescription
$aWeight 1 Width of grid lines
$aColor 'black' Color of grid lines
$aStyle TGRID_SINGLE 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.  
 
See also:

Example:

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

 

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

ArgumentDefaultDescription
$aFileR1  Top left row OR file name
$aScaleC1 null Top left column OR scale
$aMixR2 null Bottom right row OR blend factor
$aC2 null Bottom right column
$aFile null Image filename
$aScale 1.0 Image scale
$aMix 100 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:

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);

 

GTextTable ::
SetMinColWidth($aColWidth, $aWidth)
Specify minimum column width

ArgumentDefaultDescription
$aColWidth  Width or column index
$aWidth null 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. 
 
See also:

Example:

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

 

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

ArgumentDefaultDescription
$aRowHeight  Row index or height
$aHeight null 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:

Example:

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

 

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

ArgumentDefaultDescription
$aArgR1  Top left row OR format string
$aC1 null Top left column
$aR2 null Bottom right row
$aC2 null Bottom right column
$aArg null 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:

Example:

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

 

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

ArgumentDefaultDescription
$aArgR1  Top left row OR cell padding
$aC1 null Top left column
$aR2 null Bottom right row
$aC2 null Bottom right column
$aPad null 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:

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);

 

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

ArgumentDefaultDescription
$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:

Example:

$table->SetPos(10,10);

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

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

 

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

ArgumentDefaultDescription
$aRow  Row index
$aFF  Font family
$aFS  Font style
$aFSize 10 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:

Example:

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

 

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

ArgumentDefaultDescription
$aRow  Grind line to specify
$aWeight 1 Width of line
$aColor 'black' Color of line
$aStyle TGRID_SINGLE 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:

Example:

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

 

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

ArgumentDefaultDescription
$aRow  Row index
$aFile  Filename of image
$aScale 1.0 Scale of image
$aMix 100 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:

Example:

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

 

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

ArgumentDefaultDescription
$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. 
 
See also:

Example:

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

 

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

ArgumentDefaultDescription
$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:

Example:

$table->SetRowPadding(4,12);

 

GTextTable ::
SetRowTextOrientation($aRow, $aO)

ArgumentDefaultDescription
$aRow  No description available
$aO  No description available

Description:
No description available.

 

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

ArgumentDefaultDescription
$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. 
 

See also:

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);
...

 

GTextTable ::
SetTextOrientation($aArgR1, $aC1, $aR2, $aC2, $aO)

ArgumentDefaultDescription
$aArgR1  No description available
$aC1 null No description available
$aR2 null No description available
$aC2 null No description available
$aO null No description available

Description:
No description available.

 

GTextTable ::
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();

 

GTextTable ::
__construct()
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:

Example:

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