Class PlotMark
(Defined in: jpgraph_plotmark.inc.php : 17)

PlotMark
Hide() SetCallback() SetCallbackYX() 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

PlotMark ::
Hide($aHide)
Hide plot mark

Argument | Default | Description
--- | --- | ---
$aHide | true | True=Hide plot mark

Description:
Hide plot mark
See also:

- PlotMark::Show()

Example:

$linerplot->mark->Hide();

PlotMark ::
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

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

PlotMark ::
SetCallbackYX($aFunc)
Specify callback function

Argument | Default | Description
--- | --- | ---
$aFunc |  | Callback function

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

The difference from the ordinary SetCallback() is that the callback function specified in SetCallbackYX() gets passed both the Y and X coordinate (note the order!) as arguments.

Example:

function FCallback($aYVal,$aXVal) {
// Some code to the size and color
return array( ... );
}
...
// Specify the callback
$scatterplot->mark->SetCallbackYX("FCallback");

PlotMark ::
SetColor($aColor)
Specify color for plot mark

Argument | Default | Description
--- | --- | ---
$aColor |  | Color

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

- PlotMark::SetFillColor()

Example:

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

PlotMark ::
SetDefaultWidth()
Restore default size of mark

Description:
Restore default size of mark

Example:

$lineplot->mark->SetDefaultWidth()

PlotMark ::
SetFillColor($aFillColor)
Set fill color for mark

Argument | Default | Description
--- | --- | ---
$aFillColor |  | Color

Description:
Set fill color for mark
See also:

- PlotMark::SetColor()

Example:

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

PlotMark ::
SetSize($aWidth)
Set size of mark

Argument | Default | Description
--- | --- | ---
$aWidth |  | WIdth of mark in pixels

Description:
Synonym for SetWidth()
See also:

- PlotMark::SetWidth()

Example:

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

PlotMark ::
SetType($aType, $aFileName, $aScale)
Specify type of plot mark

Argument | Default | Description
--- | --- | ---
$aType |  | Type of plotmark, shape or built-in image
$aFileName | '' | Filename or country name depending on type of plotmark. See below.
$aScale | 1.0 | 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.
11. MARK_FLAG<n>, Use one of MARK_FLAG1, MARK_FLAG2, MARK_FLAG3, MARK_FLAG4 to indicate that you want to display a country flag. The numbers indicate which original size of the flag you want to use. 1 is the smallest size and 4 is the largest flag size. You can of course also scale a flag by specifying the scale as the third argument. Which country flag you want is specified in the second argument as either the full country name, partial country name or by ordinal number as specified in the table below. Please note that if you specify a partial name then the first country in alphabetic order that matches the partial name will be used.

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:

Type | Description | Colors
--- | --- | ---
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'

In terms of the builtin flags 230 countries are supported. The following table lists all available flags:

1: 'Afghanistan' | 2: 'Republic of Angola'
3: 'Republic of Albania' | 4: 'Alderney'
5: 'Democratic and Popular Republic of Algeria' | 6: 'Territory of American Samoa'
7: 'Principality of Andorra' | 8: 'British Overseas Territory of Anguilla'
9: 'Antarctica' | 10: 'Argentine Republic'
11: 'League of Arab States' | 12: 'Republic of Armenia'
13: 'Aruba' | 14: 'Commonwealth of Australia'
15: 'Republic of Austria' | 16: 'Azerbaijani Republic'
17: 'British Antarctic Territory' | 18: 'Kingdom of Belgium'
19: 'British Overseas Territory of Bermuda' | 20: 'Commonwealth of the Bahamas'
21: 'Kingdom of Bahrain' | 22: 'Republic of Belarus'
23: 'Republic of Bolivia' | 24: 'Belize'
25: 'Republic of Benin' | 26: 'Republic of Botswana'
27: 'Federative Republic of Brazil' | 28: 'Barbados'
29: 'British Indian Ocean Territory' | 30: 'Brunei Darussalam'
31: 'Republic of Burkina' | 32: 'Republic of Bulgaria'
33: 'Republic of Burundi' | 34: 'Overseas Territory of the British Virgin Islands'
35: 'Central African Republic' | 36: 'Kingdom of Cambodia'
37: 'Republic of Cameroon' | 38: 'Dominion of Canada'
39: 'Caribbean Community' | 40: 'Republic of Cape Verde'
41: 'Republic of Chad' | 42: 'Republic of Chile'
43: 'Territory of Christmas Island' | 44: 'Commonwealth of Independent States'
45: 'Cook Islands' | 46: 'Republic of Colombia'
47: 'Territory of Cocos Islands' | 48: 'Commonwealth'
49: 'Union of the Comoros' | 50: 'Republic of the Congo'
51: 'Republic of Costa Rica' | 52: 'Republic of Croatia'
53: 'Republic of Cuba' | 54: 'British Overseas Territory of the Cayman Islands'
55: 'Republic of Cyprus' | 56: 'The Czech Republic'
57: 'Kingdom of Denmark' | 58: 'Republic of Djibouti'
59: 'Commonwealth of Dominica' | 60: 'Dominican Republic'
61: 'Republic of Ecuador' | 62: 'Arab Republic of Egypt'
63: 'Republic of El Salvador' | 64: 'England'
65: 'Republic of Equatorial Guinea' | 66: 'State of Eritrea'
67: 'Republic of Estonia' | 68: 'Ethiopia'
69: 'European Union' | 70: 'British Overseas Territory of the Falkland Islands'
71: 'International Federation of Vexillological Associations' | 72: 'Republic of Fiji'
73: 'Republic of Finland' | 74: 'Territory of French Polynesia'
75: 'French Republic' | 76: 'Overseas Department of French Guiana'
77: 'Gabonese Republic' | 78: 'Republic of the Gambia'
79: 'Republic of Georgia' | 80: 'Federal Republic of Germany'
81: 'Republic of Ghana' | 82: 'Gibraltar'
83: 'Hellenic Republic' | 84: 'State of Grenada'
85: 'Overseas Department of Guadeloupe' | 86: 'Territory of Guam'
87: 'Republic of Guatemala' | 88: 'The Bailiwick of Guernsey'
89: 'Republic of Guinea' | 90: 'Republic of Haiti'
91: 'Hong Kong Special Administrative Region' | 92: 'Republic of Honduras'
93: 'Republic of Hungary' | 94: 'Republic of Iceland'
95: 'International Committee of the Red Cross' | 96: 'Republic of India'
97: 'Republic of Indonesia' | 98: 'Republic of Iraq'
99: 'Republic of Ireland' | 100: 'Organization of the Islamic Conference'
101: 'Isle of Man' | 102: 'State of Israel'
103: 'Italian Republic' | 104: 'Jamaica'
105: 'Japan' | 106: 'The Bailiwick of Jersey'
107: 'Hashemite Kingdom of Jordan' | 108: 'Republic of Kazakhstan'
109: 'Republic of Kenya' | 110: 'Republic of Kiribati'
111: 'State of Kuwait' | 112: 'Kyrgyz Republic'
113: 'Republic of Latvia' | 114: 'Lebanese Republic'
115: 'Kingdom of Lesotho' | 116: 'Republic of Liberia'
117: 'Principality of Liechtenstein' | 118: 'Republic of Lithuania'
119: 'Grand Duchy of Luxembourg' | 120: 'Macao Special Administrative Region'
121: 'Republic of Macedonia' | 122: 'Republic of Madagascar'
123: 'Republic of the Marshall Islands' | 124: 'Republic of Mali'
125: 'Federation of Malaysia' | 126: 'Republic of Malta'
127: 'Republic of Malawi' | 128: 'Overseas Department of Martinique'
129: 'Islamic Republic of Mauritania' | 130: 'Territorial Collectivity of Mayotte'
131: 'United Mexican States' | 132: 'Federated States of Micronesia'
133: 'Midway Islands' | 134: 'Republic of Moldova'
135: 'Principality of Monaco' | 136: 'Republic of Mongolia'
137: 'British Overseas Territory of Montserrat' | 138: 'Kingdom of Morocco'
139: 'Republic of Mozambique' | 140: 'Republic of Mauritius'
141: 'Union of Myanmar' | 142: 'Republic of Namibia'
143: 'North Atlantic Treaty Organization' | 144: 'Republic of Nauru'
145: 'Turkish Republic of Northern Cyprus' | 146: 'Netherlands Antilles'
147: 'Kingdom of Nepal' | 148: 'Kingdom of the Netherlands'
149: 'Territory of Norfolk Island' | 150: 'Federal Republic of Nigeria'
151: 'Republic of Nicaragua' | 152: 'Republic of Niger'
153: 'Niue' | 154: 'Commonwealth of the Northern Mariana Islands'
155: 'Province of Northern Ireland' | 156: 'Nordic Council'
157: 'Kingdom of Norway' | 158: 'Territory of New Caledonia and Dependencies'
159: 'New Zealand' | 160: 'Organization of American States'
161: 'Organization of African Unity' | 162: 'International Olympic Committee'
163: 'Sultanate of Oman' | 164: 'Islamic Republic of Pakistan'
165: 'Republic of Palau' | 166: 'Independent State of Papua New Guinea'
167: 'Republic of Paraguay' | 168: 'Republic of the Philippines'
169: 'British Overseas Territory of the Pitcairn Islands' | 170: 'Republic of Poland'
171: 'Republic of Portugal' | 172: 'Commonwealth of Puerto Rico'
173: 'State of Qatar' | 174: 'Russian Federation'
175: 'Republic of Rwanda' | 176: 'Kingdom of Saudi Arabia'
177: 'Republic of San Marino' | 178: 'Nordic Sami Conference'
179: 'Sark' | 180: 'Scotland'
181: 'Principality of Seborga' | 182: 'Republic of Sierra Leone'
183: 'Republic of Singapore' | 184: 'Republic of Korea'
185: 'Republic of Slovenia' | 186: 'Somali Republic'
187: 'Republic of Somaliland' | 188: 'Republic of South Africa'
189: 'Solomon Islands' | 190: 'Kingdom of Spain'
191: 'Secretariat of the Pacific Community' | 192: 'Democratic Socialist Republic of Sri Lanka'
193: 'Saint Lucia' | 194: 'Republic of the Sudan'
195: 'Republic of Suriname' | 196: 'Slovak Republic'
197: 'Kingdom of Sweden' | 198: 'Swiss Confederation'
199: 'Syrian Arab Republic' | 200: 'Kingdom of Swaziland'
201: 'Republic of China' | 202: 'Republic of Tajikistan'
203: 'United Republic of Tanzania' | 204: 'Kingdom of Thailand'
205: 'Autonomous Region of Tibet' | 206: 'Turkmenistan'
207: 'Togolese Republic' | 208: 'Tokelau'
209: 'Kingdom of Tonga' | 210: 'Tristan da Cunha'
211: 'Tromelin' | 212: 'Republic of Tunisia'
213: 'Republic of Turkey' | 214: 'Tuvalu'
215: 'United Arab Emirates' | 216: 'Republic of Uganda'
217: 'Ukraine' | 218: 'United Kingdom of Great Britain'
219: 'United Nations' | 220: 'United States of America'
221: 'Oriental Republic of Uruguay' | 222: 'Virgin Islands of the United States'
223: 'Republic of Uzbekistan' | 224: 'State of the Vatican City'
225: 'Republic of Vanuatu' | 226: 'Bolivarian Republic of Venezuela'
227: 'Republic of Yemen' | 228: 'Democratic Republic of Congo'
229: 'Republic of Zimbabwe'

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();
// Setting the plotmarks to a Swedish flag showing the three
// ways of doing it
....
$p1->mark->SetType(MARK_FLAG1,'sweden');
// OR
$p1->mark->SetType(MARK_FLAG1,197);
// OR
$p1->mark->SetType(MARK_FLAG1,'Kingdom of Sweden');

PlotMark ::
SetWeight($aWeight)
Specify line weight

Argument | Default | Description
--- | --- | ---
$aWeight |  | Line weight

Description:
Specify line weight

Example:

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

PlotMark ::
SetWidth($aWidth)
Set width of plot mark

Argument | Default | Description
--- | --- | ---
$aWidth |  | Width in pixels

Description:
Set width of plot mark

Example:

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

PlotMark ::
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.

Example:

$lineplot->mark->Show();