Show:
Extends: ChartBase
Module: charts-base
Parent Module: charts

The CartesianChart class creates a chart with horizontal and vertical axes.

Constructor

CartesianChart

()

Index

Methods

_addAxes

() private

Adds axes to the chart.

_addGridlines

() private

Adds gridlines to the chart.

_addSeries

() private

Renders the Graph.

_addToAxesCollection

(
  • position
  • axis
)

Adds axis instance to the appropriate array based on position

Parameters:

  • position String

    The position of the axis

  • axis Axis

    The Axis instance

_addToAxesRenderQueue

(
  • axis
)
private

Adds an Axis instance to the _itemRenderQueue.

Parameters:

  • axis Axis

    An Axis instance.

_addTooltip

() private

Adds a tooltip to the dom.

_buildSeriesKeys

(
  • dataProvider
)
private

Constructs seriesKeys if not explicitly specified.

Parameters:

  • dataProvider Array

    The dataProvider for the chart.

Returns:

Array

_dataProviderChangeHandler

(
  • e
)
private

Event handler for dataProviderChange.

Parameters:

  • e Object

    Event object.

_getAllKeys

(
  • dp
)

Returns all the keys contained in a dataProvider.

Parameters:

  • dp Array

    Collection of objects to be parsed.

Returns:

Object

_getAriaMessage

(
  • key
)

Returns the appropriate message based on the key press.

Parameters:

  • key Number

    The keycode that was pressed.

Returns:

String

_getAxisClass

(
  • t
)
private

Helper method that returns the axis class that a key references.

Parameters:

  • t String

    The type of axis.

Returns:

Axis

_getBaseAttribute

(
  • item
  • key
)
private

Gets an attribute from an object, using a getter for Base objects and a property for object literals. Used for determining attributes from series/axis references which can be an actual class instance or a hash of properties that will be used to create a class instance.

Parameters:

  • item Object

    Object or instance in which the attribute resides.

  • key String

    Attribute whose value will be returned.

Returns:

Object

_getBottomOverflow

(
  • set1
  • set2
  • height
)
private

Returns the maximum distance in pixels that the extends outside the bottom bounds of all vertical axes.

Parameters:

  • set1 Array

    Collection of axes to check.

  • set2 Array

    Seconf collection of axes to check.

  • height Number

    Height of the axes

Returns:

Number

_getCategoryAxis

() private

Returns the category axis instance for the chart.

Returns:

Axis

_getDefaultAxes

() private

Default Function for the axes attribute.

Returns:

Object

_getDefaultAxisPosition

(
  • axis
  • valueAxes
  • position
)
private

Determines the position of an axis when one is not specified.

Parameters:

  • axis Axis

    Axis instance.

  • valueAxes Array

    Array of Axis instances.

  • position String

    Default position depending on the direction of the chart and type of axis.

Returns:

String

_getDefaultSeriesCollection

(
  • val
)
private

Returns the default value for the seriesCollection attribute.

Parameters:

  • val Array

    Array containing either CartesianSeries instances or objects containing data to construct series instances.

Returns:

Array

_getGraph

() private

Default value function for the Graph attribute.

Returns:

Graph

_getLeftOverflow

(
  • set1
  • set2
  • width
)
private

Returns the maximum distance in pixels that the extends outside the left bounds of all horizontal axes.

Parameters:

  • set1 Array

    Collection of axes to check.

  • set2 Array

    Seconf collection of axes to check.

  • width Number

    Width of the axes

Returns:

Number

_getRightOverflow

(
  • set1
  • set2
  • width
)
private

Returns the maximum distance in pixels that the extends outside the right bounds of all horizontal axes.

Parameters:

  • set1 Array

    Collection of axes to check.

  • set2 Array

    Seconf collection of axes to check.

  • width Number

    Width of the axes

Returns:

Number

_getSeriesAxis

(
  • key
)
private

Returns the value axis for a series.

Parameters:

  • key String

    The key value used to determine the axis instance.

Returns:

Axis

_getTooltip

() private

Default getter for tooltip attribute.

Returns:

Object

_getTopOverflow

(
  • set1
  • set2
  • width
)
private

Returns the maximum distance in pixels that the extends outside the top bounds of all vertical axes.

Parameters:

  • set1 Array

    Collection of axes to check.

  • set2 Array

    Seconf collection of axes to check.

  • width Number

    Width of the axes

Returns:

Number

_groupMarkersChangeHandler

(
  • e
)
private

Handles groupMarkers change event.

Parameters:

  • e Object

    Event object.

_itemRendered

(
  • e
)
private

Handler for itemRendered event.

Parameters:

  • e Object

    Event object.

_markerEventDispatcher

(
  • e
)
private

Event handler for marker events.

Parameters:

  • e Object

    Event object.

_parseAxes

(
  • axes
)
private

Generates and returns a key-indexed object containing Axis instances or objects used to create Axis instances.

Parameters:

  • axes Object

    Object containing Axis instances or Axis attributes.

Returns:

Object

_parseSeriesAxes

(
  • series
)
private

Parse and sets the axes for a series instance.

Parameters:

_parseSeriesCollection

(
  • val
)
private

Parses and returns a series collection from an object and default properties.

Parameters:

  • val Object

    Object contain properties for series being set.

Returns:

Object

_planarEventDispatcher

(
  • e
)
private

When interactionType is set to planar, listens for mouse move events and fires planarEvent:mouseover or planarEvent:mouseout depending on the position of the mouse in relation to data points on the Chart.

Parameters:

  • e Object

    Event object.

_planarLabelFunction

(
  • categoryAxis
  • valueItems
  • index
  • seriesArray
  • seriesIndex
)
HTMLElement private

Formats tooltip text when interactionType is planar.

Parameters:

  • categoryAxis Axis

    Reference to the categoryAxis of the chart.

  • valueItems Array

    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>

  • index Number

    The index of the item within its series.

  • seriesArray Array

    Array of series instances for each value item.

  • seriesIndex Number

    The index of the series in the seriesCollection.

Returns:

HTMLElement:

_positionTooltip

(
  • e
)
private

Positions the tooltip

Parameters:

  • e Object

    Event object.

_redraw

() private

Redraws and position all the components of the chart instance.

_setAriaElements

(
  • cb
)
private

Creates an aria live-region, aria-label and aria-describedby for the Chart.

Parameters:

  • cb Node

    Reference to the Chart's contentBox attribute.

_setAxes

(
  • val
)
private

Creates Axis instances.

Parameters:

  • val Object

    Object containing Axis instances or objects in which to construct Axis instances.

Returns:

Object

_setBaseAttribute

(
  • item
  • key
  • value
)
private

Sets an attribute on an object, using a setter of Base objects and a property for object literals. Used for setting attributes on a Base class, either directly or to be stored in an object literal for use at instantiation.

Parameters:

  • item Object

    Object or instance in which the attribute resides.

  • key String

    Attribute whose value will be assigned.

  • value Object

    Value to be assigned to the attribute.

_setDataValues

(
  • val
)
private

Setter method for dataProvider attribute.

Parameters:

  • val Array

    Array to be set as dataProvider.

Returns:

Array

_setOffscreen

() private

Sets a node offscreen for use as aria-description or aria-live-regin.

Returns:

Node

_setText

(
  • label
  • val
)
private

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:

  • label HTMLElement

    label to be updated

  • val String

    value with which to update the label

_showTooltip

(
  • msg
  • x
  • y
)
private

Shows a tooltip

Parameters:

  • msg String

    Message to dispaly in the tooltip.

  • x Number

    x-coordinate

  • y Number

    y-coordinate

_sizeChanged

(
  • e
)
private

Handler for sizeChanged event.

Parameters:

  • e Object

    Event object.

_tooltipChangeHandler

(
  • e
)
private

Event handler for the tooltipChange.

Parameters:

  • e Object

    Event object.

_tooltipLabelFunction

(
  • categoryItem
  • valueItem
)
HTMLElement private

Formats tooltip text when interactionType is marker.

Parameters:

  • categoryItem Object

    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>

  • valueItem Object

    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>

Returns:

HTMLElement:

_updateTooltip

(
  • val
)
private

Updates the tooltip attribute.

Parameters:

  • val Object

    Object containing properties for the tooltip.

Returns:

Object

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

boolean true if the seriesKeys attribute was explicitly set.

bindUI

() private

destructor

() protected

Destructor implementation for the CartesianChart class. Calls destroy on all axes, series and the Graph instance. Removes the tooltip and overlay HTML elements.

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:

  • val String

    Key reference used to look up the axis.

Returns:

Axis

getCategoryAxis

()

Returns the category axis for the chart.

Returns:

Axis

getSeries

(
  • val
)

Returns a series instance by index or key value.

Parameters:

  • val Object

Returns:

CartesianSeries

getSeriesItems

(
  • series
  • index
)

Returns an object literal containing a categoryItem and a valueItem for a given series index. Below is the structure of each:

Parameters:

  • series CartesianSeries

    Reference to a series.

  • index Number

    Index of the specified item within a series.

Returns:

Object An object literal containing the following:

<dl> <dt>categoryItem</dt><dd>Object containing the following data related to the category axis of the series. <dl> <dt>axis</dt><dd>Reference to the category axis of the series.</dd> <dt>key</dt><dd>Category key for the series.</dd> <dt>value</dt><dd>Value on the axis corresponding to the series index.</dd> </dl> </dd> <dt>valueItem</dt><dd>Object containing the following data related to the category axis of the series. <dl> <dt>axis</dt><dd>Reference to the value axis of the series.</dd> <dt>key</dt><dd>Value key for the series.</dd> <dt>value</dt><dd>Value on the axis corresponding to the series index.</dd> </dl> </dd> </dl>

hideTooltip

()

Hides the default tooltip

initializer

() private

renderUI

() private

Inherited from ChartBase but overwritten in yui3/src/charts/js/CartesianChart.js:10

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:

  • e Object

    Event object.

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

_itemRenderQueue

Array private

Queue of axes instances that will be updated. This method is used internally to determine when all axes have been updated.

_seriesCollection

Array private

Storage for seriesCollection attribute.

_setSeriesCollection

Unknown private

Setter method for seriesCollection attribute.

Sub-properties:

  • val Array

    Array of either CartesianSeries instances or objects containing series attribute key value pairs.

_type

String private

Indicates the default series type for the chart.

Attributes

allowContentOverflow

Boolean

Indicates whether axis labels are allowed to overflow beyond the bounds of the chart's content box.

ariaDescription

String

Sets the aria description for the chart.

ariaLabel

String

Sets the aria-label for the chart.

axes

Object

Axes to appear in the chart. This can be a key indexed hash of axis instances or object literals used to construct the appropriate axes.

axesCollection

Array

Reference to all the axes in the chart.

axesStyles

Object private

Style object for the axes.

bottomAxesCollection

Array private

Reference to the bottom-aligned axes for the chart.

categoryAxis

Axis

Reference to the category axis used by the chart.

categoryAxisName

String

Indicates the key value used to identify a category axis in the axes hash. If not specified, the categoryKey attribute value will be used.

categoryKey

String

The key value used for the chart's category axis.

Default: category

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

dataProvider

Array

Data used to generate the chart.

direction

String

Direction of chart's category axis when there is no series collection specified. Charts can be horizontal or vertical. When the chart type is column, the chart is horizontal. When the chart type is bar, the chart is vertical.

graph

Graph

Reference to graph instance.

graphStyles

Object private

Styles for the graph.

groupMarkers

Boolean

Indicates whether or not markers for a series will be grouped and rendered in a single complex shape instance.

horizontalGridlines

Gridlines

Reference to the horizontalGridlines for the chart.

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

leftAxesCollection

Array private

Reference to the left-aligned axes for the chart.

rightAxesCollection

Array private

Reference to the right-aligned axes for the chart.

seriesCollection

Array

Collection of series to appear on the chart. This can be an array of Series instances or object literals used to construct the appropriate series.

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.

seriesStyles

Object private

Style object for the series

showAreaFill

Boolean

Indicates whether or not an area is filled in a combo chart.

showLines

Boolean

Indicates whether to display lines in a combo chart.

showMarkers

Boolean

Indicates whether to display markers in a combo chart.

stacked

Boolean

Indicates whether or not the chart is stacked.

styles

Object

Style properties for the chart. Contains a key indexed hash of the following: <dl> <dt>series</dt><dd>A key indexed hash containing references to the styles attribute for each series in the chart. Specific style attributes vary depending on the series: <ul> <li><a href="AreaSeries.html#attr_styles">AreaSeries</a></li> <li><a href="BarSeries.html#attr_styles">BarSeries</a></li> <li><a href="ColumnSeries.html#attr_styles">ColumnSeries</a></li> <li><a href="ComboSeries.html#attr_styles">ComboSeries</a></li> <li><a href="LineSeries.html#attr_styles">LineSeries</a></li> <li><a href="MarkerSeries.html#attr_styles">MarkerSeries</a></li> <li><a href="SplineSeries.html#attr_styles">SplineSeries</a></li> </ul> </dd> <dt>axes</dt><dd>A key indexed hash containing references to the styles attribute for each axes in the chart. Specific style attributes can be found in the <a href="Axis.html#attr_styles">Axis</a> class.</dd> <dt>graph</dt><dd>A reference to the styles attribute in the chart. Specific style attributes can be found in the <a href="Graph.html#attr_styles">Graph</a> class.</dd> </dl>

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>

topAxesCollection

Array private

Reference to the top-aligned axes for the chart.

type

String

Type of chart when there is no series collection specified.

valueAxisName

String

Indicates the key value used to identify a the series axis when an axis not generated.

verticalGridlines

Gridlines

Reference to the verticalGridlines for the chart.

Events

markerEvent:click

Broadcasts when interactionType is set to marker and a series marker has received a click event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category Axis.</dd> <dt>valueItem</dt><dd>Hash containing information about the value Axis.</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 order of the marker's series.</dd> <dt>originEvent</dt><dd>Underlying dom event.</dd> </dl>

markerEvent:mousedown

Broadcasts when interactionType is set to marker and a series marker has received a mousedown event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category Axis.</dd> <dt>valueItem</dt><dd>Hash containing information about the value Axis.</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 order of the marker's series.</dd> </dl>

markerEvent:mouseout

Broadcasts when interactionType is set to marker and a series marker has received a mouseout event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category Axis.</dd> <dt>valueItem</dt><dd>Hash containing information about the value Axis.</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 order of the marker's series.</dd> </dl>

markerEvent:mouseover

Broadcasts when interactionType is set to marker and a series marker has received a mouseover event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category Axis.</dd> <dt>valueItem</dt><dd>Hash containing information about the value Axis.</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 order of the marker's series.</dd> </dl>

markerEvent:mouseup

Broadcasts when interactionType is set to marker and a series marker has received a mouseup event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>Hash containing information about the category Axis.</dd> <dt>valueItem</dt><dd>Hash containing information about the value Axis.</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 order of the marker's series.</dd> </dl>

planarEvent:mouseout

Broadcasts when interactionType is set to planar and a series' marker plane has received a mouseout event.

Event Payload:

planarEvent:mouseover

Broadcasts when interactionType is set to planar and a series' marker plane has received a mouseover event.

Event Payload:

  • e EventFacade

    Event facade with the following additional properties: <dl> <dt>categoryItem</dt><dd>An array of hashes, each containing information about the category Axis of each marker whose plane has been intersected.</dd> <dt>valueItem</dt><dd>An array of hashes, each containing information about the value Axis of each marker whose plane has been intersected.</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>items</dt><dd>An array including all the series which contain a marker whose plane has been intersected.</dd> <dt>index</dt><dd>Index of the markers in their respective series.</dd> <dt>originEvent</dt><dd>Underlying dom event.</dd> </dl>