ChartBase Class
The ChartBase class is an abstract class used to create charts.
Constructor
ChartBase
()
Index
Methods
- _addTooltip
- _buildSeriesKeys
- _dataProviderChangeHandler
- _getAllKeys
- _getAxisClass
- _getGraph
- _getTooltip
- _groupMarkersChangeHandler
- _itemRendered
- _markerEventDispatcher
- _planarLabelFunction
- _positionTooltip
- _setAriaElements
- _setDataValues
- _setOffscreen
- _setText
- _showTooltip
- _tooltipChangeHandler
- _tooltipLabelFunction
- _updateTooltip
- _wereSeriesKeysExplicitlySet
- bindUI
- getAxisByKey
- getCategoryAxis
- getSeries
- hideTooltip
- initializer
- renderUI
- syncUI
- toggleTooltip
Attributes
Methods
_addTooltip
()
private
Adds a tooltip to the dom.
_buildSeriesKeys
-
dataProvider
Constructs seriesKeys if not explicitly specified.
Parameters:
-
dataProviderArray<p>The dataProvider for the chart.</p>
Returns:
<p>Array</p>
_dataProviderChangeHandler
-
e
Event handler for dataProviderChange.
Parameters:
-
eObject<p>Event object.</p>
_getAllKeys
-
dp
Returns all the keys contained in a dataProvider.
Parameters:
-
dpArray<p>Collection of objects to be parsed.</p>
Returns:
<p>Object</p>
_getAxisClass
-
t
Helper method that returns the axis class that a key references.
Parameters:
-
tString<p>The type of axis.</p>
Returns:
<p>Axis</p>
_getGraph
()
private
Default value function for the Graph attribute.
Returns:
<p>Graph</p>
_getTooltip
()
private
Default getter for tooltip attribute.
Returns:
<p>Object</p>
_groupMarkersChangeHandler
-
e
Handles groupMarkers change event.
Parameters:
-
eObject<p>Event object.</p>
_itemRendered
-
e
Handler for itemRendered event.
Parameters:
-
eObject<p>Event object.</p>
_markerEventDispatcher
-
e
Event handler for marker events.
Parameters:
-
eObject<p>Event object.</p>
_planarLabelFunction
-
categoryAxis -
valueItems -
index -
seriesArray -
seriesIndex
Formats tooltip text when interactionType is planar.
Parameters:
-
categoryAxisAxis<p>Reference to the categoryAxis of the chart.</p>
-
valueItemsArray<p>Array of objects for each series that has a data point in the coordinate plane of the event. Each object contains the following data: <dl> <dt>axis</dt><dd>The value axis of the series.</dd> <dt>key</dt><dd>The key for the series.</dd> <dt>value</dt><dd>The value for the series item.</dd> <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd> </dl></p>
-
indexNumber<p>The index of the item within its series.</p>
-
seriesArrayArray<p>Array of series instances for each value item.</p>
-
seriesIndexNumber<p>The index of the series in the <code>seriesCollection</code>.</p>
Returns:
_positionTooltip
-
e
Positions the tooltip
Parameters:
-
eObject<p>Event object.</p>
_setAriaElements
-
cb
Creates an aria live-region, aria-label and aria-describedby for the Chart.
Parameters:
-
cbNode<p>Reference to the Chart's <code>contentBox</code> attribute.</p>
_setDataValues
-
val
Setter method for dataProvider attribute.
Parameters:
-
valArray<p>Array to be set as <code>dataProvider</code>.</p>
Returns:
<p>Array</p>
_setOffscreen
()
private
Sets a node offscreen for use as aria-description or aria-live-regin.
Returns:
<p>Node</p>
_setText
-
label -
val
Updates the content of text field. This method writes a value into a text field using
appendChild. If the value is a String, it is converted to a TextNode first.
Parameters:
-
labelHTMLElement<p>label to be updated</p>
-
valString<p>value with which to update the label</p>
_showTooltip
-
msg -
x -
y
Shows a tooltip
_tooltipChangeHandler
-
e
Event handler for the tooltipChange.
Parameters:
-
eObject<p>Event object.</p>
_tooltipLabelFunction
-
categoryItem -
valueItem
Formats tooltip text when interactionType is marker.
Parameters:
-
categoryItemObject<p>An object containing the following: <dl> <dt>axis</dt><dd>The axis to which the category is bound.</dd> <dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided)</dd> <dt>key</dt><dd>The key of the category.</dd> <dt>value</dt><dd>The value of the category</dd> </dl></p>
-
valueItemObject<p>An object containing the following: <dl> <dt>axis</dt><dd>The axis to which the item's series is bound.</dd> <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd> <dt>key</dt><dd>The key for the series.</dd> <dt>value</dt><dd>The value for the series item.</dd> </dl></p>
Returns:
_updateTooltip
-
val
Updates the tooltip attribute.
Parameters:
-
valObject<p>Object containing properties for the tooltip.</p>
Returns:
<p>Object</p>
_wereSeriesKeysExplicitlySet
()
private
Utility method to determine if seriesKeys was explicitly provided
(for example during construction, or set by the user), as opposed to
being derived from the dataProvider for example.
Returns:
<p>boolean true if the <code>seriesKeys</code> attribute was explicitly set.</p>
bindUI
()
private
getAxisByKey
-
val
Returns an Axis instance by key reference. If the axis was explicitly set through the axes attribute,
the key will be the same as the key used in the axes object. For default axes, the key for
the category axis is the value of the categoryKey (category). For the value axis, the default
key is values.
Parameters:
-
valString<p>Key reference used to look up the axis.</p>
Returns:
<p>Axis</p>
getCategoryAxis
()
Returns the category axis for the chart.
Returns:
<p>Axis</p>
getSeries
-
val
Returns a series instance by index or key value.
Parameters:
-
valObject
Returns:
<p>CartesianSeries</p>
hideTooltip
()
Hides the default tooltip
initializer
()
private
renderUI
()
private
syncUI
()
private
toggleTooltip
-
e
Event listener for toggling the tooltip. If a tooltip is visible, hide it. If not, it will create and show a tooltip based on the event object.
Parameters:
-
eObject<p>Event object.</p>
Properties
_axes
Array
private
Collection of axes.
_axisClass
Object
private
Key value pairs of axis types.
_dataProvider
Array
private
Storage for the dataProvider attribute.
_direction
String
private
Default direction of the chart.
Default: horizontal
_seriesCollection
Array
private
Storage for seriesCollection attribute.
_setSeriesCollection
Unknown
private
Setter method for seriesCollection attribute.
Sub-properties:
-
valArray<p>Array of either <code>CartesianSeries</code> instances or objects containing series attribute key value pairs.</p>
Attributes
categoryType
String
Indicates the type of axis to use for the category axis.
<dl>
<dt>category</dt><dd>Specifies a CategoryAxis.</dd>
<dt>time</dt><dd>Specifies a `TimeAxis</dd>
</dl>
Default: category
groupMarkers
Boolean
Indicates whether or not markers for a series will be grouped and rendered in a single complex shape instance.
interactionType
String
Indicates the the type of interactions that will fire events.
<dl> <dt>marker</dt><dd>Events will be broadcasted when the mouse interacts with individual markers.</dd> <dt>planar</dt><dd>Events will be broadcasted when the mouse intersects the plane of any markers on the chart.</dd> <dt>none</dt><dd>No events will be broadcasted.</dd> </dl>
Default: marker
seriesKeys
Array
A collection of keys that map to the series axes. If no keys are set, they will be generated automatically depending on the data structure passed into the chart.
tooltip
Object
Reference to the default tooltip available for the chart.
<p>Contains the following properties:</p>
<dl>
<dt>node</dt><dd>Reference to the actual dom node</dd>
<dt>showEvent</dt><dd>Event that should trigger the tooltip</dd>
<dt>hideEvent</dt><dd>Event that should trigger the removal of a tooltip (can be an event or an array of events)</dd>
<dt>styles</dt><dd>A hash of style properties that will be applied to the tooltip node</dd>
<dt>show</dt><dd>Indicates whether or not to show the tooltip</dd>
<dt>markerEventHandler</dt><dd>Displays and hides tooltip based on marker events</dd>
<dt>planarEventHandler</dt><dd>Displays and hides tooltip based on planar events</dd>
<dt>markerLabelFunction</dt><dd>Reference to the function used to format a marker event triggered tooltip's text.
The method contains the following arguments:
<dl>
<dt>categoryItem</dt><dd>An object containing the following:
<dl>
<dt>axis</dt><dd>The axis to which the category is bound.</dd>
<dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided).</dd>
<dt>key</dt><dd>The key of the category.</dd>
<dt>value</dt><dd>The value of the category.</dd>
</dl>
</dd>
<dt>valueItem</dt><dd>An object containing the following:
<dl>
<dt>axis</dt><dd>The axis to which the item's series is bound.</dd>
<dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
<dt>key</dt><dd>The key for the series.</dd>
<dt>value</dt><dd>The value for the series item.</dd>
</dl>
</dd>
<dt>itemIndex</dt><dd>The index of the item within the series.</dd>
<dt>series</dt><dd> The CartesianSeries instance of the item.</dd>
<dt>seriesIndex</dt><dd>The index of the series in the seriesCollection.</dd>
</dl>
The method returns an HTMLElement which is written into the DOM using appendChild. If you override this method and choose
to return an html string, you will also need to override the tooltip's setTextFunction method to accept an html string.
</dd>
<dt>planarLabelFunction</dt><dd>Reference to the function used to format a planar event triggered tooltip's text
<dl>
<dt>categoryAxis</dt><dd> CategoryAxis Reference to the categoryAxis of the chart.
<dt>valueItems</dt><dd>Array of objects for each series that has a data point in the coordinate plane of the event. Each
object contains the following data:
<dl>
<dt>axis</dt><dd>The value axis of the series.</dd>
<dt>key</dt><dd>The key for the series.</dd>
<dt>value</dt><dd>The value for the series item.</dd>
<dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
</dl>
</dd>
<dt>index</dt><dd>The index of the item within its series.</dd>
<dt>seriesArray</dt><dd>Array of series instances for each value item.</dd>
<dt>seriesIndex</dt><dd>The index of the series in the seriesCollection.</dd>
</dl>
</dd>
</dl>
The method returns an HTMLElement which is written into the DOM using appendChild. If you override this method and choose
to return an html string, you will also need to override the tooltip's setTextFunction method to accept an html string.
</dd>
<dt>setTextFunction</dt><dd>Method that writes content returned from planarLabelFunction or markerLabelFunction into the
the tooltip node. Has the following signature:
<dl>
<dt>label</dt><dd>The HTMLElement that the content is to be added.</dd>
<dt>val</dt><dd>The content to be rendered into tooltip. This can be a String or HTMLElement. If an HTML string is used,
it will be rendered as a string.</dd>
</dl>
</dd>
</dl>
Events
markerEvent:click
Broadcasts when interactionType is set to marker and a series marker has received a click event.
Event Payload:
-
eEventFacade<p>Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd> <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd> <dt>node</dt><dd>The dom node of the marker.</dd> <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd> <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd> <dt>pageX</dt><dd>The x location of the event on the page (including scroll)</dd> <dt>pageY</dt><dd>The y location of the event on the page (including scroll)</dd> <dt>series</dt><dd>Reference to the series of the marker.</dd> <dt>index</dt><dd>Index of the marker in the series.</dd> <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd> <dt>originEvent</dt><dd>Underlying dom event.</dd> </dl></p>
markerEvent:mousedown
Broadcasts when interactionType is set to marker and a series marker has received a mousedown event.
Event Payload:
-
eEventFacade<p>Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd> <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd> <dt>node</dt><dd>The dom node of the marker.</dd> <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd> <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd> <dt>series</dt><dd>Reference to the series of the marker.</dd> <dt>index</dt><dd>Index of the marker in the series.</dd> <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd> </dl></p>
markerEvent:mouseout
Broadcasts when interactionType is set to marker and a series marker has received a mouseout event.
Event Payload:
-
eEventFacade<p>Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd> <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd> <dt>node</dt><dd>The dom node of the marker.</dd> <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd> <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd> <dt>series</dt><dd>Reference to the series of the marker.</dd> <dt>index</dt><dd>Index of the marker in the series.</dd> <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd> </dl></p>
markerEvent:mouseover
Broadcasts when interactionType is set to marker and a series marker has received a mouseover event.
Event Payload:
-
eEventFacade<p>Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd> <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd> <dt>node</dt><dd>The dom node of the marker.</dd> <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd> <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd> <dt>series</dt><dd>Reference to the series of the marker.</dd> <dt>index</dt><dd>Index of the marker in the series.</dd> <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd> </dl></p>
markerEvent:mouseup
Broadcasts when interactionType is set to marker and a series marker has received a mouseup event.
Event Payload:
-
eEventFacade<p>Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd> <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd> <dt>node</dt><dd>The dom node of the marker.</dd> <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd> <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd> <dt>series</dt><dd>Reference to the series of the marker.</dd> <dt>index</dt><dd>Index of the marker in the series.</dd> <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd> </dl></p>