BasicBarChart Class
Base Chart Class: BasicBarChart
Basic bar histogram chart.
Values are represented using vertical bars;
Each point or value can have up to 10 subcomponents, where each component can be
any non-nregative real number (i.e., each point can be in R_+^i, for 1 <= i <= 10).
Item Index
Methods
- __canAppendData__
- __clearDrawing__
- __clearHorizontalAxe__
- __clearVerticalAxe__
- __decodeCSSMultivalueString__
- __drawHorizontalAxe__
- __drawHorizontalAxeTitle__
- __drawNewData__
- __drawVerticalAxe__
- __drawVerticalAxeTitle__
- __encodeCSSMultivalueString__
- __formatValue__
- __getBarOpacity__
- __getChartAreaHeight__
- __getChartAreaWidth__
- __getDatasetLength__
- __getHeight__
- __getWidth__
- __initAxes__
- __initChart__
- __initData__
- __makeLabel__
- __onClearData__
- __redrawAll__
- __redrawInnerBackground__
- __redrawInnerBorder__
- __redrawOuterBackground__
- __redrawOuterBorder__
- __refreshDrawing__
- __selectData__
- __selectLabels__
- __updateAxes__
- __updateBackground__
- __updateDrawing__
- addLegend
- appendData
- areLabelsVisible
- BasicBarChart
- clearData
- destroy
- getAxesHeight
- getAxesWidth
- getBarsFillColor
- getBarsStrokeColor
- getBarWidth
- getFillColor deprecated
- getInnerBackgroundColor
- getInnerBorder
- getLabelColor
- getLabelsSize
- getOuterBackgroundColor
- getOuterBorder
- getStrokeColor deprecated
- removeHorizontalAxe
- removeVerticalAxe
- setAbbreviatedLabel
- setBarsFillColor
- setBarsStrokeColor
- setBarWidth
- setExtendedLabel
- setFillColor deprecated
- setFormatValueFunction
- setGlobalScaling
- setHeight
- setHorizontalAxe
- setInnerBackgroundColor
- setInnerBorder
- setLabelColor
- setLabelSize
- setLocalScaling
- setOuterBackgroundColor
- setOuterBorder
- setPosition
- setStrokeColor deprecated
- setTitle
- setVerticalAxe
- setWidth
- toggleLabels
Properties
- __abbreviatedLabels__
- __axeBottom__
- __axeLeft__
- __axeRight__
- __axeTop__
- __barsFillColors__
- __barsStrokeColors__
- __chartArea__
- __data__
- __dataCounter__
- __dataDim__
- __divElement__
- __horizontalAxe__
- __innerBackgroundColor__
- __innerBorder__
- __labelColors__
- __labelsSize__
- __labelsVisible__
- __legend__
- __margins__
- __maxVals__
- __outerBackgroundColor__
- __outerBorder__
- __parent__
- __scaleGlobally__
- __svgElement__
- __verticalAxe__
- __xScale__
- __yScale__
Methods
__canAppendData__
-
newDataArray
Checks that new data can be added to the chart (if the chart can represent only a limited number of points);
WARNING: This function SHOULD be overriden in any class inheriting from the base class
in order to handle differents needs
Parameters:
-
newDataArray
Array[Mandatory] The array of values that should be added;
Returns:
__clearDrawing__
-
dataSet
-
labelsSet
Removes the svg objects related to the data cleared by the caller (clearData).
Parameters:
-
dataSet
Object[Mandatory] List of drawing objects (default: rects) representing data
-
labelsSet
Object[Mandatory] List of labels related to data removed
Returns:
__clearHorizontalAxe__
()
Undefined
protected
Clear all the drawings related to the horizontal axe.
Returns:
__clearVerticalAxe__
()
Undefined
protected
Clear all the drawings related to the vertical axe.
Returns:
__decodeCSSMultivalueString__
-
str
-
defaultValue
Parameters:
-
str
String[Mandatory] A string representing a CSS property with 4 possible subfields, as for margins or border-width: top, right, bottom and left.
Unless undefinedOnMiss is passed and it's truthy, the format of the string is the same as for CSS margin; it can therefore be one of the following: <ul> <li>""<br>No margin is set</li> <li>"top-bottom-right-left;"<br>All 4 subfields are set to the same value</li> <li>"top-bottom right-left;"<br>Top and bottom and right and left subfields have the same value</li> <li>"top right-left bottom;"<br>right and left subfield are set to the same value</li> <li>"top right bottom left;"<br>All 4 subfields are set separately</li> </ul>
-
defaultValue
Boolean[Optional] If it is not passed or it's false, the standard CSS format specification for multivalue string attributes will be used, as described above. Otherwise, if less than 4 values are provided in the string, they are assigned to subfields in the order top, right, bottom, left, while for the fields for whom a value isn't explicitely inserted, a defaultValue is used.
Returns:
__drawHorizontalAxe__
()
Undefined
protected
Draws the horizontal axe.
Returns:
__drawHorizontalAxeTitle__
-
axe
-
width
-
x
-
y
Draws the horizontal axe's title.
Parameters:
-
axe
Object[Mandatory] The object storing horizontal axe's properties.
-
width
Number[Mandatory] The width of the title label (tipically the same width as the axe).
-
x
Number[Mandatory] The x coordinate for the title label.
-
y
Number[Mandatory] The y coordinate for the title label.
Returns:
__drawNewData__
-
dataSet
-
labelsSet
-
dataIndex
-
xScale
-
yScale
Called by appendData() to draw the newly added points in dataSet, once for
every data subcomponent.
WARNING: if you inherit from this class you might want to override both
this method and updateDrawing in order to obtain a custom chart.
Parameters:
-
dataSet
Object[Mandatory] The set of svg elements created so far to represent the data;
WARNING: this parameter should be generated by an appropriate call to selectData; -
labelsSet
Object[Mandatory] The set of svg elements created so far to represent the labels of the data;
WARNING: this parameter should be generated by an appropriate call to selectLabels; -
dataIndex
Number[Mandatory] The index of the component of the data which is to be drawn;
-
xScale
Object[Mandatory] D3 scale object for X axis;
-
yScale
Object[Mandatory] D3 scale object for Y axis (specific to current component);
Returns:
__drawVerticalAxe__
()
Undefined
protected
Draws the vertical axe.
Returns:
__drawVerticalAxeTitle__
-
axe
-
height
-
x
-
y
-
textAngle
-
textX
-
textPivot
Draws the vertical axe's title.
Parameters:
-
axe
Object[Mandatory] The object storing vertical axe's properties.
-
height
Number[Mandatory] The height of the title label (tipically the same height as the axe).
-
x
Number[Mandatory] The x coordinate for the title label.
-
y
Number[Mandatory] The y coordinate for the title label.
-
textAngle
Number[Mandatory] The textAngle for the rotation of the title label.
It can be + or - 90 degrees: together with x, y, textX and textPivot parameters, this allows to reuse this method for both left and right axes. -
textX
Number[Mandatory] Internally computed.
X position of the axe's title. -
textPivot
Number[Mandatory] Internally computed.
X position of the pivot point around whom the axe title has to be rotated.
Returns:
__encodeCSSMultivalueString__
-
obj
Parameters:
-
obj
Object[Mandatory] An object storing the values for the property.
Fields top, right, bottom, left are checked in order: as soon as one is missing, no more data will be added to the string
Returns:
__formatValue__
-
value
Checks that the value passed corresponds to the data format allowed for the current chart; This function can be overriden in any class inheriting from the base class in order to handle differents data formats (i.e. Objects or JSON).
Parameters:
-
value
Array | Object[Mandatory] The value to be tested;
Returns:
- An array with properly formatted values, each of whom converted to float <=> value is correctly validated
- null Otherwise
__getBarOpacity__
-
val
Computes and return the suggested value for the opacity of the bar drawn to represent a certain value.
Parameters:
-
val
Number[Mandatory] The value to be represented;
Accepts only normalized values (scaled between 0 and 1).
INVARIANT: to avoid defensive programming, it is assumed 0 <= val <=1
Returns:
__getChartAreaHeight__
()
Number
protected
Return the height of the drawing area for the chart.
Returns:
__getChartAreaWidth__
()
Number
protected
Return the width of the drawing area for the chart.
Returns:
__getDatasetLength__
()
Number
protected
Utility function to take account of the number of points currently added to the chart
Returns:
__getHeight__
()
Number
protected
Return the height of the drawing area for the chart.
Returns:
__getWidth__
()
Number
protected
Return the width of the drawing area for the chart.
Returns:
__initAxes__
-
width
-
height
Inits the 4 axes surrounding the chart main area according to the specific chart type.
WARNING: This method SHOULD be overridden in any inheriting class.
This method sets only those properties of the four axes that are peculiar to this chart
and that can be set:
- For top and bottom axes, only height can be set (their width is the same as the svg containing element)
- For left and right axes, only width can be set (their height is the same as the main chart area)
Parameters:
-
width
Number[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[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.
Returns:
__initChart__
-
chart
-
width
-
height
-
[margins]
Inits the chart DIV and SVG container, setting width and height, if they are passed as arguments;
Parameters:
-
chart
Object[Mandatory] The chart object that needs initialization;
-
width
Number[Mandatory] The desired width for the chart; If passed, MUST be a positive integer, or a value that can be converted to a positive integer
-
height
Number[Mandatory] The desired height for the chart; If passed, MUST be a positive integer, or a value that can be converted to a positive integer
-
[margins]
String optional[Optional] A String of 0 to 4 comma-separated valued that specifies the 4 margins of the chart.
Omitted margins will get the default margin for this class.
Returns:
__initData__
-
basicCharObj
-
[dataDim=1]
Performs all the settings related to the data handling area of the chart;
Parameters:
-
basicCharObj
Object[Mandatory] The chart object to init;
-
[dataDim=1]
Number optional[Optional] The dimension of the data space, i.e. the number of subvalues for each data entry;
Can take any value that is or can be converted to an integer between 1 and MAXSPACEDIMENSION.
Returns:
__makeLabel__
-
val
-
[index=0]
-
[forceAbbreviate=false]
Converts an input number to
Parameters:
-
val
Number[Mandatory] The value that must be used in the label.
-
[index=0]
Number optional[Optional] The index of the subcomponent of the data.
-
[forceAbbreviate=false]
Boolean optional[Optional] Should the label be coercefully abbreviated?
Returns:
__onClearData__
-
[n]
Takes care of the remaining details related to the removal of part of the values from the chart,
based on to the particular chart needs.
WARNING: Inherited objects MIGHT NEED to override this function.
Parameters:
-
[n]
Number optional[Mandatory] Must be a positive Integer, or a value that can be converted to a positive Integer; Number of elements removed from the chart
Returns:
__redrawAll__
()
Undefined
protected
Redraws completely the whole chart, updating all the non-fixed attributes of the drawings.
Returns:
__redrawInnerBackground__
()
Undefined
protected
Properly redraws the background of the main chart area
WARNING: if you inherit from this class you might want to override
this method to reflect its expected behaviour.
Returns:
__redrawInnerBorder__
-
[border=__innerBorder__]
Properly redraws the border of the inner chart area.
WARNING: if you inherit from this class you might want to override
this method to reflect its expected behaviour.
Parameters:
-
[border=__innerBorder__]
Object optional[Optional] An object summarizing all the border properties:
- fill: The color of the border;
- width: The width of the border line, in pixels;
- dash: The dash pattern of the line
Returns:
__redrawOuterBackground__
()
Undefined
protected
Properly redraws the background of the outer chart area
WARNING: if you inherit from this class you might want to override
this method to reflect its expected behaviour.
Returns:
__redrawOuterBorder__
-
[border=__outerBorder__]
Properly redraws the border of the outer chart area.
WARNING: if you inherit from this class you might want to override
this method to reflect its expected behaviour.
Parameters:
-
[border=__outerBorder__]
Object optional[Optional] An object summarizing all the border properties:
- fill: The color of the border;
- width: The width of the border line, in pixels;
- dash: The dash pattern of the line
Returns:
__refreshDrawing__
-
dataSet
-
labelsSet
-
dataIndex
-
xScale
-
yScale
Called by redrawAll() to redraw all the data-related drawings, once for
every data subcomponent.
The difference with updateDrawing is that the latter is incremental with respect to
drawNewData and updates only the properties used to provide animations of the drawing,
while this method redraws from scratch the data.
WARNING: if you inherit from this class you might want to override both
this method following updateDrawing behaviour in order to obtain a custom chart.
Parameters:
-
dataSet
Object[Mandatory] The set of svg elements created so far to represent the data;
WARNING: this parameter should be generated by an appropriate call to selectData; -
labelsSet
Object[Mandatory] The set of svg elements created so far to represent the labels of the data;
WARNING: this parameter should be generated by an appropriate call to selectLabels; -
dataIndex
Number[Mandatory] The index of the component of the data which is to be drawn;
-
xScale
Object[Mandatory] D3 scale object for X axis;
-
yScale
Object[Mandatory] D3 scale object for Y axis (specific to current component);
Returns:
__selectData__
-
data
-
index
-
[n]
Returns the list of the svg elements used to represent data subcomponents
with the required index.
I.e.: if data space is 3-dimensional (i.e. every point has 3 components)
selectData(data, 2) would select the svg elements representing
the 2nd component of every point in data
Parameters:
-
data
Array[Mandatory] The dataset on which selection should be applied
-
index
Number[Mandatory] The index of the required component
INVARIANT: to avoid defensive programming, it is assumed 0 <= index < this.dataDim -
[n]
Number optional[Optional] The maximum number of elements to return;
Returns:
__selectLabels__
-
data
-
index
-
[n]
Returns the list of the svg elements used to draw the labels of
subcomponents of data with the required index.
I.e.: if data space is 3-dimensional (i.e. every point has 3 components)
selectLabels(data, 3) would select the svg elements representing
the labels of the 3nd component of every point in data
Parameters:
-
data
Array[Mandatory] The dataset on which selection should be applied;
-
index
Number[Mandatory] The index of the required component;
INVARIANT: to avoid defensive programming, it is assumed 0 <= index < this.dataDim -
[n]
Number optional[Optional] The maximum number of elements to return;
Returns:
__updateAxes__
-
yScale
Called by updateDrawing() to update the labels of the vertical axe
when vertical scale changes;
WARNING: if you inherit from this class you might want to override
this method as well as drawNewData and updateDrawing
in order to obtain a custom chart.
Parameters:
-
yScale
Object[Mandatory] D3 scale object for Y axis;
Returns:
__updateBackground__
()
Undefined
protected
Called by drawNewData() to redraw the background properly;
WARNING: if you inherit from this class you might want to override
this method as well as drawNewData and updateDrawing
in order to obtain a custom chart.
Returns:
__updateDrawing__
-
dataSet
-
labelsSet
-
dataIndex
-
xScale
-
yScale
Called by appendData() to update drawing of the points in dataSet, once for
every data subcomponent.
After new data is inserted by drawNewData, appendData performs adjustments
to accomodate for scale change or shift in the drawing due to time, and this
function takes care of updating and fixing the chart representation.
WARNING: if you inherit from this class you might want to override both
this method and drawNewData in order to obtain a custom chart.
Parameters:
-
dataSet
Object[Mandatory] The set of svg elements created so far to represent the data;
WARNING: this parameter should be generated by an appropriate call to selectData; -
labelsSet
Object[Mandatory] The set of svg elements created so far to represent the labels of the data;
WARNING: this parameter should be generated by an appropriate call to selectLabels; -
dataIndex
Number[Mandatory] The index of the component of the data which is to be drawn;
-
xScale
Object[Mandatory] D3 scale object for X axis;
-
yScale
Object[Mandatory] D3 scale object for Y axis (specific to current component).
Returns:
addLegend
-
labels
Insert new data into the chart, at runtime;
Parameters:
-
labels
Array[Mandatory] An array containing exactly one label for each component of the data space.
A new legend object will be created and attached to the chart, and then for every subcomponent [label] a new item will be added to the legend.
Returns:
appendData
-
newDataArray
Insert new data into the chart, at runtime;
Parameters:
-
newDataArray
Array[Mandatory] An array containing the next values that needs to be drawn in the chart;
Each array element, in order to be added to the chart, must be compliant with the data format defined by the function formatData (which can itself be set at runtime, and by default accepts arrays of dataDim integers, neglecting to render the negative ones).
Returns:
areLabelsVisible
-
[index=0]
Checks if labels for the index-th dimension are visible
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be affected;
Returns:
BasicBarChart
-
width
-
height
-
[chartMargins=""]
-
[dataDim=1]
-
[parent=body]
Parameters:
-
width
Number[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[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. -
[chartMargins=""]
String optional[Optional] A String of 0 to 4 space-separated values that specifies the 4 margins of the chart.
The string should respect the following format: "top right bottom left;" (notice the trailing semicolon)
If less then 4 values are passed, only the covered subfield will be assigned using the input string, while the remaining ones will take a default value specified as an inner attribute of the class. -
[dataDim=1]
Number optional[Optional] The dimension of the data space, i.e. the number of subvalues for each data entry
Can be any value that is or can be converted to an integer between 1 and MAXSPACEDIMENSION. -
[parent=body]
Object optional[Optional] The DOM element to which the diagram should be appended as a child
Returns:
clearData
-
[n]
Remove all the data, or part of it, from the chart;
Parameters:
-
[n]
Number optional[Optional, For internal use only] The number of elements to remove from the beginning of the data array, i.e. how many of the oldest values should be removed from the chart;
Returns:
destroy
()
Null
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 chart.
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:
getAxesHeight
()
Array
Returns the height of each of the four axe areas surrounding the chart.
Returns:
getAxesWidth
()
Array
Returns the width of each of the four axe areas surrounding the chart.
Returns:
getBarsFillColor
-
[index=0]
Gets the fill color used to draw the index-th component of the data space.
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
getBarsStrokeColor
-
[index=0]
Gets the stroke color used to draw the index-th component of the data space.
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
getBarWidth
-
[xScale=this.__xScale__]
Gets the current bar width for this chart; For this chart, bar width is computed at runtime according to the number of bars plotted;
Parameters:
-
[xScale=this.__xScale__]
Object optional[Optional] It is possible to pass a d3 scale object to get the bar width computed with respect to a different scale metric;
On default, the value is computed with respect to this chart's current metric.
Returns:
getFillColor
()
deprecated
Use getBarsFillColor instead.
getInnerBackgroundColor
()
String | Object
Returns current color for background
Returns:
getInnerBorder
()
Object
Returns the current border settings for the main chart area.
Returns:
getLabelColor
-
[index=0]
Gets the fill color used for the labels attached to the index-th component of the data space.
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
getLabelsSize
-
[index=0]
Gets the size used for the labels attached to the index-th component of the data space.
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
getOuterBackgroundColor
()
String | Object
Returns current color for background
Returns:
getOuterBorder
()
Object
Returns the current border settings for the outer chart area.
Returns:
getStrokeColor
()
deprecated
Use getBarsStrokeColor instead.
removeHorizontalAxe
()
Object
chainable
Removes the horizontal axe object and all related drawings from this chart.
Returns:
removeVerticalAxe
()
Object
chainable
Removes the vertical axe object and all related drawings from this chart.
Returns:
setAbbreviatedLabel
-
[index=0]
Displays abbreviated text for bars' label.
F.i.: 1.1M instead of 1,123,543 or 4.3K instead of 4,356
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setBarsFillColor
-
{String|Object]
-
[index=0]
Sets the fill color used to draw the index-th component of the data space.
Parameters:
-
{String|Object]
Objectcolor [Mandatory] The new fill color for the selected component's;
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setBarsStrokeColor
-
color
-
[index=0]
Sets the stroke color used to draw the index-th component of the data space.
Parameters:
-
color
String[Mandatory] The new stroke color for the selected component's;
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setBarWidth
()
Sets the bars width property;
For this chart, bar width is computed at runtime according to the number of bars plotted,
so this property can't be set.
Unless overridden, any call to this method will cause an exception to be thrown
This method is declared to improve the consistency of the interface.
setExtendedLabel
-
[index=0]
Displays extended text for bars' label.
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setFillColor
()
deprecated
Use setBarsFillColor instead.
setFormatValueFunction
-
formaValueFunction
Change the data formatting function, allowing to pass a custom handler to cope with JSON or other data formats.
Parameters:
-
formaValueFunction
Function[Mandatory] The new data formatting/parsing function;
Returns:
setGlobalScaling
()
Object
chainable
Sets scaling to global
When data space has a dimension greater than 1 (i.e. when each data value has more than 1 component)
these charts support either global scaling (relative to the whole dataset)
or local scaling (relative to value of the same component) of each subcomponent.
Returns:
setHeight
-
height
Sets the height of the chart bounding box.
Parameters:
-
height
Number[Mandatory] The new height of the chart;
Only positive Integers and values that can be converted to positive integers are accepted.
Returns:
setHorizontalAxe
-
[displayOnTop=false]
-
[title=""]
-
[notches=0]
-
[lineWidth=DEFAULT_AXES_LINE_WIDTH]
-
[labelColor=DEFAULT_AXES_COLOR]
-
[labelSize=DEFAULT_AXES_LABEL_SIZE]
-
[titleColor=DEFAULT_AXES_COLOR]
-
[titleSize=DEFAULT_AXES_LABEL_SIZE]
Set the properties for an horizontal axe and draws it anew, clearing previous versions.
Parameters:
-
[displayOnTop=false]
Boolean optional[Optional] If passed and thrutey, the vertical axe will be added to the displayOnTop instead than to the bottom of the chart.
-
[title=""]
String optional[Optional] The title to use for the vertical axe.
-
[notches=0]
Number optional[Optional] Number of notches to display on the vertical axe (excluding the 2 extremes).
MUST be a non negative integer. -
[lineWidth=DEFAULT_AXES_LINE_WIDTH]
Number optional[Optional] The desired line width for the axe and notches.
If passed MUST be a positive integer; otherwise it is set to the default value. -
[labelColor=DEFAULT_AXES_COLOR]
String optional[Optional] Color to use for axe's drawings and labels.
-
[labelSize=DEFAULT_AXES_LABEL_SIZE]
Number optional[Optional] Size for the notches label's text.
-
[titleColor=DEFAULT_AXES_COLOR]
String optional[Optional] Color to use for axe's title.
-
[titleSize=DEFAULT_AXES_LABEL_SIZE]
Number optional[Optional] The desired size for the title.
If passed MUST be a positive integer; otherwise it is set to the default value.
Returns:
setInnerBackgroundColor
-
bgColor
Changes the background color
Parameters:
-
bgColor
String | Object[Mandatory] The new color for background;
Returns:
setInnerBorder
-
fill
-
[width]
-
[dash]
Changes the border of the main chart area.
Parameters:
-
fill
String | Object[Mandatory] The new color for the border, or "none" if it has to be removed;
-
[width]
Number optional[Mandatory] The width of the border line, in pixels;
-
[dash]
String optional[Mandatory] The dash pattern for the border;
The format for the dash string parameter allows to specify n couples of positive integers "#line1 #space1 #line2 #space2 ... #linen #spacen" where each #line and #space represents the number of pixels in the pattern for lines and spaces segments respectively.
Returns:
setLabelColor
-
color
-
[index=0]
Sets the fill color used for the labels attached to the index-th component of the data space.
Parameters:
-
color
String[Mandatory] The new color for the selected component's labels;
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setLabelSize
-
size
-
[index=0]
Sets the size used for the labels attached to the index-th component of the data space.
Parameters:
-
size
Number[Mandatory] The new size for the selected component's labels; Must be a positive integer, or a value that can be converted to a positive integer;
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be selected;
Returns:
setLocalScaling
()
Object
chainable
Sets scaling to local
When data space has a dimension greater than 1 (i.e. when each data value has more than 1 component)
these charts support either global scaling (relative to the whole dataset)
or local scaling (relative to value of the same component) of each subcomponent.
Returns:
setOuterBackgroundColor
-
bgColor
Changes the background color of the outer area of the chart.
Parameters:
-
bgColor
String | Object[Mandatory] The new color for background of the outer area;
Returns:
setOuterBorder
-
fill
-
[width]
-
[dash]
Changes the border of the outer chart area.
Parameters:
-
fill
String | Object[Mandatory] The new color for the border, or "none" if it has to be removed;
-
[width]
Number optional[Mandatory] The width of the border line, in pixels;
-
[dash]
String optional[Mandatory] The dash pattern for the border;
The format for the dash string parameter allows to specify n couples of positive integers "#line1 #space1 #line2 #space2 ... #linen #spacen" where each #line and #space represents the number of pixels in the pattern for lines and spaces segments respectively.
Returns:
setPosition
-
left
-
top
Sets the position of the chart in the page. Position is assumed to be absolute.
Parameters:
-
left
Number[Mandatory] The horizontal position of the chart bounding box;
-
top
Number[Mandatory] The vertical position of the chart bounding box;
Returns:
setStrokeColor
()
deprecated
Use setBarsStrokeColor instead.
setTitle
-
title
-
[size=DEFAULT
-
[color=black]
-
[left=centered]
-
[top=0]
Sets the title for the chart, including all its attributes.
Parameters:
-
title
String[Mandatory] The new title for the chart;
-
[size=DEFAULT
NumberTITLE SIZE] [Optional] The size of the new title;
Only positive Integers and values that can be converted to positive integers are accepted. -
[color=black]
String optional[Optional] The color of the new title;
-
[left=centered]
Number optional[Optional] The horizontal position of the title, relative to the chart; the text will be centered around this point
Only positive Integers and values that can be converted to positive integers are accepted. -
[top=0]
Number optional[Optional] The vertical position of the title, relative to the chart;
Only positive Integers and values that can be converted to positive integers are accepted.
Returns:
setVerticalAxe
-
[displayOnRight=false]
-
[title=""]
-
[notches=0]
-
[lineWidth=DEFAULT_AXES_LINE_WIDTH]
-
[labelColor=DEFAULT_AXES_COLOR]
-
[labelSize=DEFAULT_AXES_LABEL_SIZE]
-
[titleColor=DEFAULT_AXES_COLOR]
-
[titleSize=DEFAULT_AXES_LABEL_SIZE]
Set the properties for a vertical axe and draws it anew, clearing previous versions.
Parameters:
-
[displayOnRight=false]
Boolean optional[Optional] If passed and thrutey, the vertical axe will be added to the displayOnRight instead than to the left of the chart.
-
[title=""]
String optional[Optional] The title to use for the vertical axe.
-
[notches=0]
Number optional[Optional] Number of notches to display on the vertical axe (excluding the 2 extremes).
MUST be a non negative integer. -
[lineWidth=DEFAULT_AXES_LINE_WIDTH]
Number optional[Optional] The desired line width for the axe and notches.
If passed MUST be a positive integer; otherwise it is set to the default value. -
[labelColor=DEFAULT_AXES_COLOR]
String optional[Optional] Color to use for axe's drawings and labels.
-
[labelSize=DEFAULT_AXES_LABEL_SIZE]
Number optional[Optional] Size for the notches label's text.
-
[titleColor=DEFAULT_AXES_COLOR]
String optional[Optional] Color to use for axe's title.
-
[titleSize=DEFAULT_AXES_LABEL_SIZE]
Number optional[Optional] The desired size for the title.
If passed MUST be a positive integer; otherwise it is set to the default value.
Returns:
setWidth
-
width
Sets the width of the chart bounding box.
Parameters:
-
width
Number[Mandatory] The new width of the chart;
Only positive integers and values that can be converted to positive Integers are accepted.
Returns:
toggleLabels
-
[index=0]
-
[visible]
Toggles the visibility of labels in the chart
Parameters:
-
[index=0]
Number optional[Optional] For multi-dimensional data spaces, specifies which component is going to be affected;
-
[visible]
Boolean optional[Optional] If specified overwrites toggle behaviour and set the visibility to visible.
Returns:
Properties
__abbreviatedLabels__
Array
protected
For each data subcomponent, states whether or not its label is abbreviated (as in, f.i., 1.1M instead of 1,123,456)
Default: [false]*
__axeBottom__
Object
protected
The svg element for the bottom axe area
__axeLeft__
Object
protected
The svg element for the left axe area
__axeRight__
Object
protected
The svg element for the right axe area
__axeTop__
Object
protected
The svg element for the top axe area
__barsFillColors__
Array
protected
For each data subcomponent, stores the color to be used to fill its drawing component
__barsStrokeColors__
Array
protected
For each data subcomponent, stores the color to be used for the stroke of its drawing component
Default: ["black"]*
__chartArea__
Object
protected
The svg element for the main chart area
__data__
Array
protected
The array that will hold data, separately for each component Initially every component's array is set to []
__dataCounter__
Number
protected
Keeps track of how much data has been actually inserted into the chart from its creation (to synch the highlighted ticks).
Default: 0
__dataDim__
Number
protected
Dimension of the data space, i.e. number of subcomponents of each data "point"
__divElement__
Object
protected
The div element that will be a container to the chart's svg element
__horizontalAxe__
Object
protected
An object describing the X axe's properties, or null if
it isn't supposed to be drawn.
If assigned, the object must have the following fields:
- side - Can be either "top" or "bottom"
- svgElement - Can be either __axeBottom__ or __axeTop__
- notches - The number of notches to be shown (Must be a positive integer)
Default: null
__innerBackgroundColor__
String | Object
protected
Color of the background of the main chart area.
Default: DEFAULT_INNER_BACKGROUND
__innerBorder__
Object
protected
Border of the main chart area.
Default: DEFAULT_INNER_BORDER
__labelColors__
Array
protected
For each data subcomponent, stores the color to be used to draw its labels
Default: ["black"]*
__labelsSize__
Number
protected
For each data subcomponent, stores the size to be used for its label
Default: DEFAULT_LABEL_SIZE
__labelsVisible__
Array
protected
For each data subcomponent, states whether or not its label is visible
Default: [true]*
__legend__
Object
protected
Placeholder for a possible legend object, if the consumer decides to add a legend to the chart;
Default: null
__margins__
Object
protected
The four margins of the chart object;
__maxVals__
Number
protected
Array of maximum values for each component
(used to compute the vertical scale)
Default: [0]*
__outerBackgroundColor__
String | Object
protected
Color of the background of the outer area of the whole chart div.
Default: DEFAULT_OUTER_BACKGROUND
__outerBorder__
Object
protected
Color of the background of the outer area of the whole chart div.
Default: DEFAULT_OUTER_BORDER
__parent__
Object
protected
The parent object to whom the chart is added
__scaleGlobally__
Boolean
protected
For data space with dimension gt 1, states if the different components should scale locally or globally
Default: true
__svgElement__
Object
protected
The chart's svg element
__verticalAxe__
Object
protected
An object describing the Y axe's properties, or null if
it isn't supposed to be drawn.
If assigned, the object must have the following fields:
- side - Can be either "left" or "right"
- svgElement - Can be either __axeLeft__ or __axeRight__
- notches - The number of notches to be shown (Must be a positive integer)
Default: null
__xScale__
Object
protected
Scale object for the horizontal axis of the chart (common to all data subcomponents)
__yScale__
Array
protected
Scale objects for the vertical axis of the chart (array with one obj for each data subcomponents, so that each component can be scaled independently)