Chart

common. Chart

Base class for charts subclasses.

Extends

(abstract) new Chart(optionsopt)

Parameters:

Name Type Description
options ChartOptions <optional> Common chart options
Source: common.mjs, line 301
Emits:

Methods

(protected) init(options)

Parameters:

Name Type Description
options ChartOptions
Source: common.mjs, line 389

addGradient(gradient) → {Gradient}

Description: Add a color gradient which can be used in SVG contexts

Parameters:

Name Type Description
gradient Gradient | GradientOptions
Source: common.mjs, line 398
Returns:
Type
Gradient

removeGradient(gradient)

Parameters:

Name Type Description
gradient Gradient
Source: common.mjs, line 411

(protected) adjustSize()

Source: common.mjs, line 453

setElement(el)

Description: Set the DOM element to be used by this chart

Parameters:

Name Type Description
el Element
Source: common.mjs, line 616

(protected) beforeSetElement()

Source: common.mjs, line 724

(protected) afterSetElement()

Source: common.mjs, line 729

getColor() → {external:CSS_Color}

Description: Retrieve the computed CSS color for this chart Source: common.mjs, line 736
Returns:
Type
external:CSS_Color

(protected) addChart(chart)

Parameters:

Name Type Description
chart Chart
Source: common.mjs, line 747

getAllCharts() → {Array.<Chart>}

Source: common.mjs, line 768
Returns:
All the charts sharing this chart's `el` property
Type
Array.<Chart>

addTooltip(id, options)

Description: Add a new tooltip to this chart.

Parameters:

Name Type Description
id string Identifier for this tooltip
options TooltipOptions Options for this tooltip
Source: common.mjs, line 779

removeTooltip()

Description: Remove a tooltip from this chart Source: common.mjs, line 851

(protected) onTooltip(options) → {Element}

Description: The default tooltip formatter

Parameters:

Name Type Description
options object
Properties
Name Type Description
entry DataEntry Data Entry
tooltip object Tooltip
Source: common.mjs, line 898
Returns:
Tooltip contents
Type
Element

(protected) onAxisLabel(options) → {string}

Description: The default Axis Label formatter

Parameters:

Name Type Description
options object
Properties
Name Type Description
orientation string "vertical" or "horizontal" orientation
percent number Normalized percentage of label, i.e. 0 -> 1
format function <optional> Optional format callback
Source: common.mjs, line 961
Returns:
Label contents
Type
string

hideTooltip(idopt)

Description: Hide tooltip (if visible)

Parameters:

Name Type Description
id string <optional> ID of the tooltip to hide
Source: common.mjs, line 1049

showTooltip(idopt)

Description: Show tooltip (if available)

Parameters:

Name Type Description
id string <optional> ID of the tooltip to show
Source: common.mjs, line 1071

suspendTooltip(idopt)

Description: Increment the tooltip's suspend reference count by 1. While the tooltip suspend reference count is > 0 the tooltip will not be available and thus won't be visible.

Parameters:

Name Type Description
id string <optional> ID of the tooltip to suspend
Source: common.mjs, line 1105

resumeTooltip(idopt)

Description: Decrement the tooltip's suspend reference count by 1

Parameters:

Name Type Description
id string <optional> ID of the tooltip to suspend
Source: common.mjs, line 1121

isTooltipAvailable(idopt) → {boolean}

Parameters:

Name Type Description
id string <optional> ID of the tooltip to check
Source: common.mjs, line 1137
Returns:
Is the tooltip suspended or disabled
Type
boolean

isTooltipPointing() → {boolean}

Returns:
Is the tooltip actively handling pointer events
Type
boolean

setTooltipPosition(options, idopt)

Description: Place the tooltip at specific data value coordinates or by data index

Parameters:

Name Type Description
options object
Properties
Name Type Description
x number <optional>
y number <optional>
index number <optional> Data index
id string <optional> ID of the tooltip to position
Source: common.mjs, line 1199

(protected) updateVisibleTooltips()

findNearestFromXCoord(coord, dataopt) → {DataEntry}

Description: Binary search for nearest data entry using an X coordinate

Parameters:

Name Type Default Description
coord number X coord
data Array.<DataEntry> <optional> this._renderData
Source: common.mjs, line 1408
Returns:
Type
DataEntry

findNearestFromXValue(value, dataopt) → {DataEntry}

Description: Binary search for nearest data entry using an X value

Parameters:

Name Type Default Description
value number X value
data Array.<DataEntry> <optional> this._renderData
Source: common.mjs, line 1420
Returns:
Type
DataEntry

findNearestIndexFromXCoord(coord, dataopt) → {number}

Description: Binary search for nearest data index using an X coordinate

Parameters:

Name Type Default Description
coord number X coord
data Array.<DataEntry> <optional> this.normalizedData
Source: common.mjs, line 1432
Returns:
Type
number

findNearestIndexFromXValue(value, dataopt) → {number}

Description: Binary search for nearest data index using an X value

Parameters:

Name Type Default Description
value number X value
data Array.<DataEntry> <optional> this.normalizedData
Source: common.mjs, line 1443
Returns:
Type
number

setZoom(options)

Parameters:

Name Type Description
options object
Properties
Name Type Default Description
type "data" | "visual" <optional> "data" What coordinate scheme to use and how to keep this zoom anchored when data is updated
xRange CoordRange <optional> x axis coordinates (type=data only)
yRange CoordRange <optional> y axis coordinates (type=data only)
translate CoordTuple <optional> [x, y] coordinate offsets (type=visual only)
scale number <optional> Scaling factor (type=visual only)
Source: common.mjs, line 1505

setData(dataopt, optionsopt)

Parameters:

Name Type Description
data ChartData <optional>
options object <optional>
Source: common.mjs, line 1542

(protected) normalizeData(data) → {Array.<DataEntry>}

Parameters:

Name Type Description
data ChartData
Source: common.mjs, line 1556
Returns:
Type
Array.<DataEntry>

render(optionsopt)

Description: Render the chart

Parameters:

Name Type Description
options object <optional>
Source: common.mjs, line 1586

(protected) applyDataZoom()

(protected) applyVisualZoom()

(protected) beforeRender(optionsopt)

Description: Called before any visual reflow/painting

Parameters:

Name Type Description
options object <optional> Render options
Source: common.mjs, line 1679

(protected) adjustScale()

(abstract, protected) doLayout()

(protected) afterRender()

xValueScale(value) → {number}

Parameters:

Name Type Description
value number
Source: common.mjs, line 1742
Returns:
Type
number

yValueScale(value) → {number}

Parameters:

Name Type Description
value number
Source: common.mjs, line 1750
Returns:
Type
number

xValueToCoord(value) → {number}

Parameters:

Name Type Description
value number
Source: common.mjs, line 1758
Returns:
Type
number

yValueToCoord(value) → {number}

Parameters:

Name Type Description
value number
Source: common.mjs, line 1766
Returns:
Type
number

xCoordScale(coord) → {number}

Parameters:

Name Type Description
coord number
Source: common.mjs, line 1774
Returns:
Type
number

yCoordScale(coord) → {number}

Parameters:

Name Type Description
coord number
Source: common.mjs, line 1782
Returns:
Type
number

xCoordToValue(coord) → {number}

Parameters:

Name Type Description
coord number
Source: common.mjs, line 1790
Returns:
Type
number

yCoordToValue(coord) → {number}

Parameters:

Name Type Description
coord number
Source: common.mjs, line 1798
Returns:
Type
number

reset()

Description: Clear this charts data and rendering Source: common.mjs, line 1805

(abstract, protected) doReset()

makePath(coords, optionsopt)

Description: Create an SVG or CSS path

Parameters:

Name Type Description
coords Array.<CoordTuple>
options object <optional>
Properties
Name Type Description
css boolean <optional> CSS compatible output
closed boolean <optional> Close the Path so it can be filled
Source: common.mjs, line 1828