Legend Class
Legend for a chart;
Adds a div and an SVG element to the page to represent a chart's legend.
Item Index
Methods
Properties
Methods
__init__
-
legend
-
width
-
height
-
left
-
top
[Private method, not visible from consumers]
Parameters:
-
legend
Object[Mandatory] The legend object to be initialized;
-
width
Number[Mandatory] The width of the legend object;
-
height
Number[Mandatory] The height of the legend object;
-
left
Number[Mandatory] Horizontal absolute position of the legend;
-
top
Number[Mandatory] Vertical absolute position of the legend;
Returns:
__redrawLegend__
()
Undefined
protected
[Protected method, not visible outside this library]
Update the drawings of this legend object;
Returns:
addItem
-
labelText
-
labelColor
-
fillColor
Adds an item to the legend and then redraws it;
Parameters:
-
labelText
String[Mandatory] The text of the label for this new item;
-
labelColor
String[Mandatory] The color to be used to draw new item's label;
-
fillColor
String[Mandatory] The color associated with this new item;
Returns:
destroy
()
Null
Object's destructor: helps garbage collector freeing memory, and removes legend's DOM elements.
Object's destructor: helps garbage collector freeing memory, and removes chart DOM elements.
WARNING: calling destroy on an object will force any further reference
to its attributes / methods to throw exceptions.
NOTE: This function should be override by any class inheriting from this object.
In order to properly work, any overriding destroyer should:
- Free any array specific to the object on which is called;
- Remove any event listener on chart objects;
- Call super object's destroy method.
Returns:
LegendFactory
-
[width]
-
[height]
-
[left]
-
[top]
-
[parent=
Creates, upon request, a new Legend object and returns it;
Parameters:
-
[width]
Number optional[Mandatory] The desired width for the chart (can't be changed later) Can be any value that is or can be converted to a positive integer.
-
[height]
Number optional[Mandatory] The desired height for the chart (can't be changed later) Can be any value that is or can be converted to a positive integer.
-
[left]
Number optional[Optional] The horizontal position of the legend bounding box;
-
[top]
Number optional[Optional] The vertical position of the legend bounding box;
-
[parent=
Objectpage's body element] [Optional] The DOM element to which the diagram should be appended as a child
Returns:
removeItem
-
index
Parameters:
-
index
Number[Mandatory] The index of the item to update; Only positive Integers and values that can be converted to positive integers are accepted.
Returns:
setHeight
-
height
Sets the height of the legend bounding box.
Parameters:
-
height
Number[Mandatory] The new height of the legend; Only positive Integers and values that can be converted to positive integers are accepted.
Returns:
setPosition
-
left
-
top
Sets the position of the legend in the page. Position is assumed to be absolute.
Parameters:
-
left
Number[Mandatory] The horizontal position of the legend bounding box; Only Integers and values that can be converted to integers are accepted.
-
top
Number[Mandatory] The vertical position of the legend bounding box; Only Integers and values that can be converted to integers are accepted.
Returns:
setWidth
-
width
Sets the width of the legend bounding box.
Parameters:
-
width
Number[Mandatory] The new width of the legend; Only positive integers and values that can be converted to positive Integers are accepted.
Returns:
updateItem
-
index
-
[labelText]
-
[labelColor]
-
[fillColor]
Updates the attributes of an item of the legend and then redraws it;
Parameters:
-
index
Number[Mandatory] The index of the item to update;
-
[labelText]
String optional[Optional] The new text for the label of the index-th item; If omitted or undefined won't be changed;
-
[labelColor]
String optional[Optional] The new color to be used to draw the index-th item's label; If omitted or undefined won't be changed;
-
[fillColor]
String optional[Optional] The new color associated with the index-th item; If omitted or undefined won't be changed;
Returns:
Properties
__divElement__
Object
protected
The div element that will be a container to the legend's svg element
__items__
Array
protected
Array of the items contained in the legend
__svgElement__
Object
protected
The svg element for this Legend