CLASS DisplayValue (Defined in: jpgraph.php : 7902)

DisplayValue
HideZero() SetAlign() SetAngle() SetColor() SetFont() SetFormat() SetFormatCallback() SetMargin() Show()

Class usage and Overview
Property class which is used to represent the display value for graphs. For line and bar graphs they represent the propertied of the value that can be displayed at each data point. For bars it represents the value of each bar that can be displayed at top of the bars.

This class should never be used directly instead this is an internal class which is accessed through it's instance variable, for example,

$lineplot = new LinePlot($datay); // Access the instance of DisplayValue $lineplot->value->Show();

See also related classes:
LinePlot and BarPlot

Class Methods

function HideZero($aFlag)
Hide zero values

Argument | Default | Description
--- | --- | ---
$aFlag | true | True=Hide zero values

Description
Hide labels that have zero value
See also
DisplayValue::SetFormat and DisplayValue::SetFormatCallback

Example

$pieplot->value->HideZero();

function SetAlign($aHAlign,$aVAlign)
Specify horizontal and vertical alignment

Argument | Default | Description
--- | --- | ---
$aHAlign |  | Horizontal alignment
$aVAlign | '' | Vertical alignment

Description
Specify the alignment of the display value in relation to the data point. Possible values are 'left', 'right', 'center'

Example

$lineplot->value->SetAlign('center');
$lineplot->value->Show();

function SetAngle($aAngle)
Rotate the value a specified angle

Argument | Default | Description
--- | --- | ---
$aAngle |  | Angle in degrees

Description
Roates the text label a number of degrees. 0 degrees is horizontal.

Please rememberthat you must use TTF fonts if you need any angle other than 0 or 90 degrees (horizontal or vertical)

See also
DisplayValue::SetFont

Example

$bplot = new barPlot($datay);
// Setup the values that are displayed on top of each bar
$bplot->value->Show();
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
// Black color for positive values and darkred for negative values
$bplot->value->SetColor("black","darkred");

function SetColor($aColor,$aNegcolor)
Specify color for values

Argument | Default | Description
--- | --- | ---
$aColor |  | Color for positive values
$aNegcolor | "" | Color for negative values

Description
Specify the value for the labels. You can have one color for positive and one color for negative values. If no negative color value is specified it will be the same as the positive color.

Example

// Black color for positive values and darkred for negative values
$bplot->value->SetColor("black","darkred");

function SetFont($aFontFamily,$aFontStyle,$aFontSize)
Specify font for values

Argument | Default | Description
--- | --- | ---
$aFontFamily |  | Font family
$aFontStyle | FS_NORMAL | Font style
$aFontSize | 10 | Font size

Description
Specify font for display value
See also
DisplayValue::SetAngle

Example

// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);

function SetFormat($aFormat,$aNegFormat)
Specify printf() format string.

Argument | Default | Description
--- | --- | ---
$aFormat |  | Format for positive values
$aNegFormat | "" | Format for negative values

Description
Specify the format string for positive and negative values. The format string follows the same riules as the standard printf() format.

Please remember that if you want to format a number with a '%' sign you must use double '%%' as escape format, e.g. '%01.2.f%%' will format a number with two decimal places and a following '%' sign.

Example

// Format label as floating point with 2 decimal points and
// a dollar sign in front, e.g. '$237.56'
$bplot->SetFormt('$%01.2f');

function SetFormatCallback($aFunc)
Specify format callback function

Argument | Default | Description
--- | --- | ---
$aFunc |  | Name of callback function

Description
Specify a function that get's called to format any value.
See also
DisplayValue::SetFormat

Example

function barValueFormat($aLabel) {
// Format '1000 english style
return number_format($aLabel)
// Format '1000 french style
// return number_format($aLabel, 2, ',', ' ');
}
$barplot->value->SetFormatCallback('barValueFormat');

function SetMargin($aMargin)
Set nargin between value and anchor point in plot

Argument | Default | Description
--- | --- | ---
$aMargin |  | Margin in pixels

Description
Specify the margin between the data point and the label.

Example

$bplot->value->SetMargin(50);

function Show($aFlag)
Show value

Argument | Default | Description
--- | --- | ---
$aFlag | true | True=show value

Description
Enable display of the label. If you want to display a value you must enable it since it is turned off by default.

Example

// Enable display of each slice value
$pieplot->value->Show();