API Docs for: 3.18.1
Show:

PieChart Class

Extends ChartBase
Module: charts-base
Parent Module: charts

The PieChart class creates a pie chart

Constructor

PieChart

()

Methods

_addAxes

() private

Adds axes to the chart.

_addSeries

() private

Renders the Graph.

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

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

Returns:

Axis

_getDefaultAxes

() private

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

Returns:

Object

_getGraph

() private

Default value function for the Graph attribute.

Returns:

Graph

_getSeriesCollection

() private

Calculates and returns a seriesCollection.

Returns:

Array

_getTooltip

() private

Default getter for tooltip attribute.

Returns:

Object

_groupMarkersChangeHandler

(
  • e
)
private

Handles groupMarkers change event.

Parameters:

_itemRendered

(
  • e
)
private

Handler for itemRendered event.

Parameters:

_markerEventDispatcher

(
  • e
)
private

Event handler for marker events.

Parameters:

_parseAxes

(
  • val
)
private

Creates Axis instances.

Parameters:

  • val Object

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

Returns:

Object

_parseSeriesAxes

(
  • c
)
private

Parse and sets the axes for the chart.

Parameters:

  • c Array

    A collection PieSeries instance.

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

    axis
    The value axis of the series.
    key
    The key for the series.
    value
    The value for the series item.
    displayName
    The display name of the series. (defaults to key if not provided)

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

_positionTooltip

(
  • e
)
private

Positions the tooltip

Parameters:

_redraw

() private

Redraws 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.

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

_tooltipChangeHandler

(
  • e
)
private

Event handler for the tooltipChange.

Parameters:

_tooltipLabelFunction

(
  • categoryItem
  • valueItem
  • itemIndex
  • series
)
HTMLElement private

Inherited from ChartBase but overwritten in charts/js/PieChart.js:290

Formats tooltip text for a pie chart.

Parameters:

  • categoryItem Object

    An object containing the following:

    axis
    The axis to which the category is bound.
    displayName
    The display name set to the category (defaults to key if not provided)
    key
    The key of the category.
    value
    The value of the category

  • valueItem Object

    An object containing the following:

    axis
    The axis to which the item's series is bound.
    displayName
    The display name of the series. (defaults to key if not provided)
    key
    The key for the series.
    value
    The value for the series item.

  • itemIndex Number

    The index of the item within the series.

  • series CartesianSeries

    The PieSeries instance of the item.

Returns:

_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 PieChart class.

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:

Returns:

CartesianSeries

getSeriesItem

(
  • series
  • index
)

Returns an object literal containing a categoryItem and a valueItem for a given series index.

Parameters:

  • series Object

    Reference to a series.

  • index Object

    Index of the specified item within a series.

Returns:

Object

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:

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:

  • val Array

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

Attributes

ariaDescription

String

Inherited from ChartBase but overwritten in charts/js/PieChart.js:434

Sets the aria description for the chart.

Fires event ariaDescriptionChange

Fires when the value for the configuration attribute ariaDescription is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

ariaLabel

String

Sets the aria-label for the chart.

Fires event ariaLabelChange

Fires when the value for the configuration attribute ariaLabel is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

axes

Object

Axes to appear in the chart.

Fires event axesChange

Fires when the value for the configuration attribute axes is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

axesCollection

Array

Reference to all the axes in the chart.

Fires event axesCollectionChange

Fires when the value for the configuration attribute axesCollection is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

categoryKey

String

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

Default: category

Fires event categoryKeyChange

Fires when the value for the configuration attribute categoryKey is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

categoryType

String

Indicates the type of axis to use for the category axis.

category
Specifies a CategoryAxis.
time
Specifies a `TimeAxis

Default: category

Fires event categoryTypeChange

Fires when the value for the configuration attribute categoryType is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

dataProvider

Array

Data used to generate the chart.

Fires event dataProviderChange

Fires when the value for the configuration attribute dataProvider is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

graph

Graph

Reference to graph instance.

Fires event graphChange

Fires when the value for the configuration attribute graph is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

groupMarkers

Boolean

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

Fires event groupMarkersChange

Fires when the value for the configuration attribute groupMarkers is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

interactionType

String

Indicates the the type of interactions that will fire events.

marker
Events will be broadcasted when the mouse interacts with individual markers.
planar
Events will be broadcasted when the mouse intersects the plane of any markers on the chart.
none
No events will be broadcasted.

Default: marker

Fires event interactionTypeChange

Fires when the value for the configuration attribute interactionType is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

seriesCollection

Array

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

Fires event seriesCollectionChange

Fires when the value for the configuration attribute seriesCollection is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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.

Fires event seriesKeysChange

Fires when the value for the configuration attribute seriesKeys is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

tooltip

Object

Reference to the default tooltip available for the chart.

Contains the following properties:

node
Reference to the actual dom node
showEvent
Event that should trigger the tooltip
hideEvent
Event that should trigger the removal of a tooltip (can be an event or an array of events)
styles
A hash of style properties that will be applied to the tooltip node
show
Indicates whether or not to show the tooltip
markerEventHandler
Displays and hides tooltip based on marker events
planarEventHandler
Displays and hides tooltip based on planar events
markerLabelFunction
Reference to the function used to format a marker event triggered tooltip's text. The method contains the following arguments:
categoryItem
An object containing the following:
axis
The axis to which the category is bound.
displayName
The display name set to the category (defaults to key if not provided).
key
The key of the category.
value
The value of the category.
valueItem
An object containing the following:
axis
The axis to which the item's series is bound.
displayName
The display name of the series. (defaults to key if not provided)
key
The key for the series.
value
The value for the series item.
itemIndex
The index of the item within the series.
series
The CartesianSeries instance of the item.
seriesIndex
The index of the series in the seriesCollection.
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.
planarLabelFunction
Reference to the function used to format a planar event triggered tooltip's text
categoryAxis
CategoryAxis Reference to the categoryAxis of the chart.
valueItems
Array of objects for each series that has a data point in the coordinate plane of the event. Each object contains the following data:
axis
The value axis of the series.
key
The key for the series.
value
The value for the series item.
displayName
The display name of the series. (defaults to key if not provided)
index
The index of the item within its series.
seriesArray
Array of series instances for each value item.
seriesIndex
The index of the series in the seriesCollection.
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.
setTextFunction
Method that writes content returned from planarLabelFunction or markerLabelFunction into the the tooltip node. Has the following signature:
label
The HTMLElement that the content is to be added.
val
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.

Fires event tooltipChange

Fires when the value for the configuration attribute tooltip is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

type

String

Type of chart when there is no series collection specified.

Fires event typeChange

Fires when the value for the configuration attribute type is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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:

    categoryItem
    Hash containing information about the category Axis.
    valueItem
    Hash containing information about the value Axis.
    node
    The dom node of the marker.
    x
    The x-coordinate of the mouse in relation to the Chart.
    y
    The y-coordinate of the mouse in relation to the Chart.
    pageX
    The x location of the event on the page (including scroll)
    pageY
    The y location of the event on the page (including scroll)
    series
    Reference to the series of the marker.
    index
    Index of the marker in the series.
    seriesIndex
    The order of the marker's series.
    originEvent
    Underlying dom event.

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:

    categoryItem
    Hash containing information about the category Axis.
    valueItem
    Hash containing information about the value Axis.
    node
    The dom node of the marker.
    x
    The x-coordinate of the mouse in relation to the Chart.
    y
    The y-coordinate of the mouse in relation to the Chart.
    series
    Reference to the series of the marker.
    index
    Index of the marker in the series.
    seriesIndex
    The order of the marker's series.

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:

    categoryItem
    Hash containing information about the category Axis.
    valueItem
    Hash containing information about the value Axis.
    node
    The dom node of the marker.
    x
    The x-coordinate of the mouse in relation to the Chart.
    y
    The y-coordinate of the mouse in relation to the Chart.
    series
    Reference to the series of the marker.
    index
    Index of the marker in the series.
    seriesIndex
    The order of the marker's series.

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:

    categoryItem
    Hash containing information about the category Axis.
    valueItem
    Hash containing information about the value Axis.
    node
    The dom node of the marker.
    x
    The x-coordinate of the mouse in relation to the Chart.
    y
    The y-coordinate of the mouse in relation to the Chart.
    series
    Reference to the series of the marker.
    index
    Index of the marker in the series.
    seriesIndex
    The order of the marker's series.

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:

    categoryItem
    Hash containing information about the category Axis.
    valueItem
    Hash containing information about the value Axis.
    node
    The dom node of the marker.
    x
    The x-coordinate of the mouse in relation to the Chart.
    y
    The y-coordinate of the mouse in relation to the Chart.
    series
    Reference to the series of the marker.
    index
    Index of the marker in the series.
    seriesIndex
    The order of the marker's series.