CLASS PlotMark
(Defined in: jpgraph.php : 6396) Class usage and Overview
In scatter plots and (possible) line plots each data point have a marker. This class implements these markers and the mtethod to modify it's apperance.
There are a number of possible marker, circle, filled circle, square, filled square, star, triangle and so on.
See PlotMark::PlotMark() below for details on how to specify what mark.
Marks are accessed thtough the 'mark' property in line and scatter plot, i.e LinePlot::mark and ScatterPlot::mark. Marks in line plot are by default turned off. To enable marks use the construction $lineplot->mark->Show().
You can modify the type of plotmarks by calling the SetType() method. Possible plot marks are:
- MARK_SQUARE, A filled square
- MARK_UTRIANGLE, A triangle pointed upwards
- MARK_DTRIANGLE, A triangle pointed downwards
- MARK_DIAMOND, A diamond
- MARK_CIRCLE, A circle
- MARK_FILLEDCIRCLE, A filled circle
- MARK_CROSS, A cross
- MARK_STAR, A star
- MARK_X, An 'X'
- MARK_LEFTTRIANGLE, A half triangle, vertical line to left (used as group markers for Gantt charts)
- MARK_RIGHTTRIANGLE, A half triangle, vertical line to right (used as group markers for Gantt charts)
- MARK_FLASH, A Zig-Zag vertical flash
See also related classes:
LinePlot and ScatterPlot
Class Methods
function Hide($aHide)
Hide plot mark
| Argument | Default | Description |
$aHide
|
true
| True=Hide plot mark |
Description
Hide plot mark
See also
PlotMark::Show
$linerplot->mark->Hide();
function SetCallback($aFunc)
Specify callback function for plotmark
| Argument | Default | Description |
$aFunc
| | Function name |
Description
Callback for plotmarks is only really used in one circumstance. Scatter plot. The callback can be used to individually adjust, sixe and color of the plot marks.
The specified callback function gets called with the Y-value for the current plotmark. The callback function should return an array consisting of three elements
- Plot size
- Color
- Fill color
function FCallback($aVal) {
// This callback will adjust the fill color and size of
// the datapoint according to the data value according to
if( $aVal < 30 ) $c = "blue";
elseif( $aVal < 70 ) $c = "green";
else $c="red";
return array(floor($aVal/3),"",$c);
}
...
// Specify the callback
$scatterplot->mark->SetCallback("FCallback");
function SetColor($aColor)
Specify color for plot mark
| Argument | Default | Description |
$aColor
| | Color |
Description
Specify the line color for plot mark
See also
PlotMark::SetFillColor
$lineplot->mark->SetColor('navy');
function SetDefaultWidth()
Restore default size of mark
Description
Restore default size of mark
$lineplot->mark->SetDefaultWidth()
function SetFillColor($aFillColor)
Set fill color for mark
| Argument | Default | Description |
$aFillColor
| | Color |
Description
Set fill color for mark
See also
PlotMark::SetColor
$lineplot->mark->SetFillColor('blue');
function SetSize($aWidth)
Set size of mark
| Argument | Default | Description |
$aWidth
| | WIdth of mark in pixels |
Description
Synonym for SetWidth()
See also
PlotMark::SetWidth
$lineplot->mark->SetSize(10);
function SetType($aType)
Specify type of plot mark
| Argument | Default | Description |
$aType
| | Type of plotmark |
Description
The following plot marks are available
- MARK_SQUARE, A filled square
- MARK_UTRIANGLE, A triangle pointed upwards
- MARK_DTRIANGLE, A triangle pointed downwards
- MARK_DIAMOND, A diamond
- MARK_CIRCLE, A circle
- MARK_FILLEDCIRCLE, A filled circle
- MARK_CROSS, A cross
- MARK_STAR, A star
- MARK_X, An 'X'
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->Show();
function SetWeight($aWeight)
Specify line weight
| Argument | Default | Description |
$aWeight
| | Line weight |
Description
Specify line weight
$line->mark->SetWeight(2);
function SetWidth($aWidth)
Set width of plot mark
| Argument | Default | Description |
$aWidth
| | Width in pixels |
Description
Set width of plot mark
$lineplot->mark->SetWidth(10);
function Show($aShow)
Enable or disable plotmarks
| Argument | Default | Description |
$aShow
|
true
| True=Show plot marks |
Description
Enable or disable plotmarks. By default plot marks are not shown so if you want to display them you need to use this method.
$lineplot->mark->Show();