CLASS PlotMark
(Defined in: jpgraph.php : 7076)
 PlotMark 
 Hide() 
 SetCallback() 
 SetColor() 
 SetDefaultWidth() 
 SetFillColor() 
 SetSize() 
 SetType() 
 SetWeight() 
 SetWidth() 
 Show() 
 

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:

  1. MARK_SQUARE, A filled square
  2. MARK_UTRIANGLE, A triangle pointed upwards
  3. MARK_DTRIANGLE, A triangle pointed downwards
  4. MARK_DIAMOND, A diamond
  5. MARK_CIRCLE, A circle
  6. MARK_FILLEDCIRCLE, A filled circle
  7. MARK_CROSS, A cross
  8. MARK_STAR, A star
  9. MARK_X, An 'X'
  10. MARK_LEFTTRIANGLE, A half triangle, vertical line to left (used as group markers for Gantt charts)
  11. MARK_RIGHTTRIANGLE, A half triangle, vertical line to right (used as group markers for Gantt charts)
  12. MARK_FLASH, A Zig-Zag vertical flash

 

See also related classes:
LinePlot and ScatterPlot

 


Class Methods

 

 

function Hide($aHide)
Hide plot mark

ArgumentDefaultDescription
$aHide true True=Hide plot mark

Description
Hide plot mark  
 
See also
PlotMark::Show

Example

$linerplot->mark->Hide();

 

 

function SetCallback($aFunc)
Specify callback function for plotmark

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

  1. Plot size
  2. Color
  3. Fill color
 

Example

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

ArgumentDefaultDescription
$aColor  Color

Description
Specify the line color for plot mark  
 
See also
PlotMark::SetFillColor

Example

$lineplot->mark->SetColor('navy');

 

 

function SetDefaultWidth()
Restore default size of mark


Description
Restore default size of mark 

Example

$lineplot->mark->SetDefaultWidth()

 

 

function SetFillColor($aFillColor)
Set fill color for mark

ArgumentDefaultDescription
$aFillColor  Color

Description
Set fill color for mark 
 
See also
PlotMark::SetColor

Example

$lineplot->mark->SetFillColor('blue');

 

 

function SetSize($aWidth)
Set size of mark

ArgumentDefaultDescription
$aWidth  WIdth of mark in pixels

Description
Synonym for SetWidth() 
 
See also
PlotMark::SetWidth

Example

$lineplot->mark->SetSize(10);

 

 

function SetType($aType,$aFilename,$aScale)
Specify type of plot mark

ArgumentDefaultDescription
$aType  Type of plotmark, shape or built-in image
$aFilename  Filename for IMAGE plot marks OR color when aType specifies a built-in image
$aScale  Scaling of image

Description
This method is used to specify what type of plotmarks should be be displayed. There are two classes of plotmarks. The first class is a number of different shapes and the second class is a number of built-in renderd images.

The following shape (the first class) plot marks are available

  1. MARK_SQUARE, A filled square
  2. MARK_UTRIANGLE, A triangle pointed upwards
  3. MARK_DTRIANGLE, A triangle pointed downwards
  4. MARK_DIAMOND, A diamond
  5. MARK_CIRCLE, A circle
  6. MARK_FILLEDCIRCLE, A filled circle
  7. MARK_CROSS, A cross
  8. MARK_STAR, A star
  9. MARK_X, An 'X'
  10. MARK_IMAGE, Use the image specified with the filename and scale as the second and third argument as the mark.

For the second class (built-in images) the following table list the different images as well as what color they are available in. For the built-in images you specify the color with the second argument.

Note that some of the images are available in different sizes. The reason is that even though you can scale them by the third argument there is a visual degradation to scale an image larger than it's original size since some pixels needs to be interpolated. Reducing the size with a scale < 1.0 gives much better visual apperance.

The scaling works with both GD 1 and GD 2 but with GD 2 the quality of the scaling is much better.

Built-in images and available colors:
TypeDescriptionColors
MARK_IMG_PUSHPIN, MARK_IMG_SPUSHPIN Push-pin image 'red','blue','green','pink','orange'
MARK_IMG_LPUSHPIN A larger Push-pin image 'red','blue','green','pink','orange'
MARK_IMG_BALL, MARK_IMAGE_SBALL A round 3D rendered ball 'bluegreen','cyan','darkgray','greengray', 'gray','graypurple','green','greenblue','lightblue', 'lightred','navy','orange','purple','red','yellow'
MARK_IMAGE_MBALL A medium sized round 3D rendered ball 'blue','bluegreen','brown','cyan', 'darkgray','greengray','gray','green', 'greenblue','lightblue','lightred', 'purple','red','white','yellow'
MARK_IMAGE_LBALL A large sized round 3D rendered ball 'blue','lightblue','brown','darkgreen', 'green','purple','red','gray','yellow','silver','gray'
MARK_IMAGE_SQUARE A 3D rendered square 'bluegreen','blue','green', 'lightblue','orange','purple','red','yellow'
MARK_IMG_STAR A 3D rendered star image 'bluegreen','lightblue','purple','blue','green','pink','red','yellow'
MARK_IMG_DIAMOND A 3D rendered diamond 'lightblue','darkblue','gray', 'blue','pink','purple','red','yellow'
MARK_IMG_BEVEL A 3D rendered bevel style round ring 'green','purple','orange','red','yellow'
 

Example

// A standard shape
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->Show();

// Use image in file 'mark.jpg' as mark., aslo scale it to
// half the size
$lineplot->mark->SetType(MARK_IMAGE,'mark.jpg',0.5);
$lineplot->mark->Show();

// Using the built-in image diamond in yellow color and 70% of originally size
$lineplot->mark->SetType(MARK_IMG_DIAMOND, 'yellow', 0.7);
$lineplot->mark->Show();

 

 

function SetWeight($aWeight)
Specify line weight

ArgumentDefaultDescription
$aWeight  Line weight

Description
Specify line weight 

Example

$line->mark->SetWeight(2);

 

 

function SetWidth($aWidth)
Set width of plot mark

ArgumentDefaultDescription
$aWidth  Width in pixels

Description
Set width of plot mark 

Example

$lineplot->mark->SetWidth(10);

 

 

function Show($aShow)
Enable or disable plotmarks

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

Example

$lineplot->mark->Show();