Skip to main content

chartist

Classes​

Interfaces​

Namespaces​

Variables​

axisUnits​

• Const axisUnits: Object

Type declaration​

NameType
x{ pos: "x" = 'x'; len: "width" = 'width'; dir: "horizontal" = 'horizontal'; rectStart: "x1" = 'x1'; rectEnd: "x2" = 'x2'; rectOffset: "y2" = 'y2' }
x.pos"x"
x.len"width"
x.dir"horizontal"
x.rectStart"x1"
x.rectEnd"x2"
x.rectOffset"y2"
y{ pos: "y" = 'y'; len: "height" = 'height'; dir: "vertical" = 'vertical'; rectStart: "y2" = 'y2'; rectEnd: "y1" = 'y1'; rectOffset: "x1" = 'x1' }
y.pos"y"
y.len"height"
y.dir"vertical"
y.rectStart"y2"
y.rectEnd"y1"
y.rectOffset"x1"

Defined in​

axes/Axis.ts:13


namespaces​

• Const namespaces: Record<string, string>

This object contains all namespaces used within Chartist.

Defined in​

core/constants.ts:4


precision​

• Const precision: 8

Precision level used internally in Chartist for rounding. If you require more decimal places you can increase this number.

Defined in​

core/constants.ts:15


escapingMap​

• Const escapingMap: Record<string, string>

A map with characters to escape for strings to be safely used as attribute values.

Defined in​

core/constants.ts:20


EPSILON​

• Const EPSILON: 2.221e-16

Defined in​

core/math.ts:4


easings​

• Const easings: Object

This Object contains some standard easing cubic bezier curves. Then can be used with their name in the Svg.animate. You can also extend the list and use your own name in the animate function. Click the show code button to see the available bezier functions.

Type declaration​

NameType
easeInSinenumber[]
easeOutSinenumber[]
easeInOutSinenumber[]
easeInQuadnumber[]
easeOutQuadnumber[]
easeInOutQuadnumber[]
easeInCubicnumber[]
easeOutCubicnumber[]
easeInOutCubicnumber[]
easeInQuartnumber[]
easeOutQuartnumber[]
easeInOutQuartnumber[]
easeInQuintnumber[]
easeOutQuintnumber[]
easeInOutQuintnumber[]
easeInExponumber[]
easeOutExponumber[]
easeInOutExponumber[]
easeInCircnumber[]
easeOutCircnumber[]
easeInOutCircnumber[]
easeInBacknumber[]
easeOutBacknumber[]
easeInOutBacknumber[]

Defined in​

svg/animation.ts:12

Type Aliases​

XAxisUnits​

Ƭ XAxisUnits: typeof x

Defined in​

axes/Axis.ts:32


YAxisUnits​

Ƭ YAxisUnits: typeof y

Defined in​

axes/Axis.ts:33


AxisUnits​

Ƭ AxisUnits: XAxisUnits | YAxisUnits

Defined in​

axes/Axis.ts:34


AxisType​

Ƭ AxisType: typeof AutoScaleAxis | typeof FixedScaleAxis | typeof StepAxis

Defined in​

axes/types.ts:5


BarChartData​

Ƭ BarChartData: Data

Defined in​

charts/BarChart/BarChart.types.ts:13


BarChartOptionsWithDefaults​

Ƭ BarChartOptionsWithDefaults: RequiredKeys<BarChartOptions<RequiredKeys<AxisOptions, "offset" | "position" | "labelOffset" | "showLabel" | "showGrid" | "labelInterpolationFnc" | "scaleMinSpace">, RequiredKeys<AxisOptions, "offset" | "position" | "labelOffset" | "showLabel" | "showGrid" | "labelInterpolationFnc" | "scaleMinSpace">>, "referenceValue" | "chartPadding" | "seriesBarDistance" | "stackMode" | "axisX" | "axisY", "classNames">

Defined in​

charts/BarChart/BarChart.types.ts:69


BarChartCreatedEvent​

Ƭ BarChartCreatedEvent: CreatedEvent<BarChartOptions>

Defined in​

charts/BarChart/BarChart.types.ts:101


BarChartEventsTypes​

Ƭ BarChartEventsTypes: BaseChartEventsTypes<BarChartCreatedEvent, AxesDrawEvent | BarDrawEvent>

Defined in​

charts/BarChart/BarChart.types.ts:112


LineInterpolation​

Ƭ LineInterpolation: (pathCoordinates: number[], valueData: SegmentData[]) => SvgPath

Type declaration​

▸ (pathCoordinates, valueData): SvgPath

Parameters​
NameType
pathCoordinatesnumber[]
valueDataSegmentData[]
Returns​

SvgPath

Defined in​

charts/LineChart/LineChart.types.ts:18


LineChartData​

Ƭ LineChartData: Data<(Series | SeriesObject)[]>

Defined in​

charts/LineChart/LineChart.types.ts:23


LineChartOptionsWithDefaults​

Ƭ LineChartOptionsWithDefaults: RequiredKeys<LineChartOptions<RequiredKeys<AxisOptions, "offset" | "position" | "labelOffset" | "showLabel" | "showGrid" | "labelInterpolationFnc">, RequiredKeys<AxisOptions, "offset" | "position" | "labelOffset" | "showLabel" | "showGrid" | "labelInterpolationFnc" | "scaleMinSpace">>, "showLine" | "showPoint" | "areaBase" | "lineSmooth" | "chartPadding" | "axisX" | "axisY", "classNames">

Defined in​

charts/LineChart/LineChart.types.ts:89


LineChartCreatedEvent​

Ƭ LineChartCreatedEvent: CreatedEvent<LineChartOptions>

Defined in​

charts/LineChart/LineChart.types.ts:121


LineChartEventsTypes​

Ƭ LineChartEventsTypes: BaseChartEventsTypes<LineChartCreatedEvent, AxesDrawEvent | PointDrawEvent | LineDrawEvent | AreaDrawEvent>

Defined in​

charts/LineChart/LineChart.types.ts:142


PieChartData​

Ƭ PieChartData: Data<FlatSeries>

Defined in​

charts/PieChart/PieChart.types.ts:14


LabelDirection​

Ƭ LabelDirection: "implode" | "neutral" | "explode"

Defined in​

charts/PieChart/PieChart.types.ts:16


AnchorPosition​

Ƭ AnchorPosition: "start" | "middle" | "end"

Defined in​

charts/PieChart/PieChart.types.ts:18


RadialLabelPosition​

Ƭ RadialLabelPosition: "inside" | "center" | "outside"

Defined in​

charts/PieChart/PieChart.types.ts:20


PieChartOptionsWithDefaults​

Ƭ PieChartOptionsWithDefaults: RequiredKeys<PieChartOptions, "chartPadding" | "startAngle" | "donutWidth" | "showLabel" | "labelOffset" | "labelPosition" | "labelInterpolationFnc" | "labelDirection" | "preventOverlappingLabelOffset", "classNames">

Defined in​

charts/PieChart/PieChart.types.ts:91


PieChartCreatedEvent​

Ƭ PieChartCreatedEvent: Omit<CreatedEvent<PieChartOptions>, "axisX" | "axisY">

Defined in​

charts/PieChart/PieChart.types.ts:105


PieChartEventsTypes​

Ƭ PieChartEventsTypes: BaseChartEventsTypes<PieChartCreatedEvent, SliceDrawEvent | SliceLabelDrawEvent>

Defined in​

charts/PieChart/PieChart.types.ts:130


Plugin​

Ƭ Plugin: (chart: any, options?: any) => void

Type declaration​

▸ (chart, options?): void

Parameters​
NameType
chartany
options?any
Returns​

void

Defined in​

core/types.ts:23


Meta​

Ƭ Meta: any

Defined in​

core/types.ts:26


OptionsWithDefaults​

Ƭ OptionsWithDefaults: RequiredKeys<Options<RequiredKeys<AxisOptions, "offset" | "labelOffset" | "labelInterpolationFnc">, RequiredKeys<AxisOptions, "offset" | "labelOffset" | "labelInterpolationFnc">>, "axisX" | "axisY" | "classNames">

Defined in​

core/types.ts:140


ResponsiveOptions​

Ƭ ResponsiveOptions<T>: [string, T][]

Type parameters​

NameType
TOptions

Defined in​

core/types.ts:154


AxisName​

Ƭ AxisName: "x" | "y"

Defined in​

core/types.ts:180


Multi​

Ƭ Multi: { x: number | string | Date | null ; y: number | string | Date | null } | { x: number | string | Date | null } | { y: number | string | Date | null }

Defined in​

core/types.ts:182


NormalizedMulti​

Ƭ NormalizedMulti: { x: number ; y: number } | { x: number } | { y: number }

Defined in​

core/types.ts:194


Label​

Ƭ Label: string | number | Date

Data

Defined in​

core/types.ts:210


AllSeriesTypes​

Ƭ AllSeriesTypes: FlatSeries | (Series | SeriesObject)[]

Defined in​

core/types.ts:212


Series​

Ƭ Series<T>: SeriesValue<T>[]

Series

Type parameters​

NameType
TSeriesPrimitiveValue

Defined in​

core/types.ts:223


SeriesValue​

Ƭ SeriesValue<T>: SeriesObjectValue<T> | T

Type parameters​

NameType
TSeriesPrimitiveValue

Defined in​

core/types.ts:232


SeriesPrimitiveValue​

Ƭ SeriesPrimitiveValue: number | string | boolean | Date | Multi | null | undefined

Defined in​

core/types.ts:234


FlatSeries​

Ƭ FlatSeries<T>: FlatSeriesValue<T>[]

Flat Series

Type parameters​

NameType
TFlatSeriesPrimitiveValue

Defined in​

core/types.ts:252


FlatSeriesValue​

Ƭ FlatSeriesValue<T>: SeriesValue<T> | FlatSeriesObjectValue<T>

Type parameters​

NameType
TFlatSeriesPrimitiveValue

Defined in​

core/types.ts:254


FlatSeriesPrimitiveValue​

Ƭ FlatSeriesPrimitiveValue: number | string | null | undefined

Defined in​

core/types.ts:258


AllNormalizedSeriesTypes​

Ƭ AllNormalizedSeriesTypes: NormalizedFlatSeries | NormalizedSeries[]

Normalized Data

Defined in​

core/types.ts:271


NormalizedSeries​

Ƭ NormalizedSeries: NormalizedSeriesValue[]

Normalized Series

Defined in​

core/types.ts:286


NormalizedSeriesValue​

Ƭ NormalizedSeriesValue: NormalizedSeriesPrimitiveValue

Defined in​

core/types.ts:288


NormalizedSeriesPrimitiveValue​

Ƭ NormalizedSeriesPrimitiveValue: number | NormalizedMulti | undefined

Defined in​

core/types.ts:290


NormalizedFlatSeries​

Ƭ NormalizedFlatSeries: number[]

Normalized Flat Series

Defined in​

core/types.ts:299


AxesDrawEvent​

Ƭ AxesDrawEvent: GridDrawEvent | GridBackgroundDrawEvent | LabelDrawEvent

Defined in​

core/types.ts:369


EventListener​

Ƭ EventListener<T>: (data: T) => void

Type parameters​

NameType
Tany

Type declaration​

▸ (data): void

Parameters​
NameType
dataT
Returns​

void

Defined in​

event/EventEmitter.ts:2


AllEventsListener​

Ƭ AllEventsListener<T>: (event: string, data: T) => void

Type parameters​

NameType
Tany

Type declaration​

▸ (event, data): void

Parameters​
NameType
eventstring
dataT
Returns​

void

Defined in​

event/EventEmitter.ts:4


MoveParams​

Ƭ MoveParams: BasePathParams

Defined in​

svg/types.ts:10


LineParams​

Ƭ LineParams: BasePathParams

Defined in​

svg/types.ts:12


PathParams​

Ƭ PathParams: MoveParams | LineParams | CurveParams | ArcParams

Defined in​

svg/types.ts:29


PathCommand​

Ƭ PathCommand<T>: { command: string ; data?: SegmentData } & T

Type parameters​

NameType
Textends PathParams = PathParams

Defined in​

svg/types.ts:31


Attributes​

Ƭ Attributes: Record<string, number | string | undefined | null>

Defined in​

svg/types.ts:40


FilterByKey​

Ƭ FilterByKey<T, K>: T extends Record<K, unknown> ? T : T extends Partial<Record<K, unknown>> ? T & { [key in K]: T[K] } : never

Type parameters​

NameType
TT
Kextends string

Defined in​

utils/types.ts:1


RequiredKeys​

Ƭ RequiredKeys<T, K, V>: T & Required<Pick<T, K | V>> & { [key in V]: Required<T[V]> }

Type parameters​

NameType
TT
Kextends keyof T
Vextends keyof T = never

Defined in​

utils/types.ts:7

Functions​

getSeriesOption​

▸ getSeriesOption<T>(series, options, key): LineChartOptionsWithDefaults[T]

Type parameters​

NameType
Textends "width" | "height" | "axisX" | "axisY" | "showLine" | "showPoint" | "areaBase" | "lineSmooth" | "chartPadding" | "classNames" | "showArea" | "showGridBackground" | "fullWidth" | "reverseData" | "low" | "high" | "referenceValue" | "plugins" | "viewBox"

Parameters​

NameType
seriesSeries<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>
optionsLineChartOptionsWithDefaults
keyT

Returns​

LineChartOptionsWithDefaults[T]

Defined in​

charts/LineChart/LineChart.ts:32


determineAnchorPosition​

▸ determineAnchorPosition(center, label, direction): AnchorPosition

Determines SVG anchor position based on direction and center parameter

Parameters​

NameType
centerDot
labelDot
directionLabelDirection

Returns​

AnchorPosition

Defined in​

charts/PieChart/PieChart.ts:81


createSvg​

▸ createSvg(container, width?, height?, className?, viewBox?): Svg

Create or reinitialize the SVG element for the chart

Parameters​

NameTypeDefault valueDescription
containerElementundefinedThe containing DOM Node object that will be used to plant the SVG element
widthstring | number'100%'Set the width of the SVG element. Default is 100%
heightstring | number'100%'Set the height of the SVG element. Default is 100%
className?stringundefinedSpecify a class to be added to the SVG element
viewBox?ViewBoxundefined-

Returns​

Svg

The created/reinitialized SVG element

Defined in​

core/creation.ts:25


normalizePadding​

▸ normalizePadding(padding): Object

Converts a number into a padding object.

Parameters​

NameType
paddingundefined | number | Partial<ChartPadding>

Returns​

Object

Returns a padding object containing top, right, bottom, left properties filled with the padding number passed in as argument. If the argument is something else than a number (presumably already a correct padding object) then this argument is directly returned.

NameType
topnumber
rightnumber
bottomnumber
leftnumber

Defined in​

core/creation.ts:73


createChartRect​

▸ createChartRect(svg, options): Object

Initialize chart drawing rectangle (area where chart is drawn) x1,y1 = bottom left / x2,y2 = top right

Parameters​

NameTypeDescription
svgSvgThe svg element for the chart
optionsOptions<AxisOptions, AxisOptions>The Object that contains all the optional values for the chart

Returns​

Object

The chart rectangles coordinates inside the svg element plus the rectangles measurements

NameType
x1number
x2number
y1number
y2number
padding{ top: number = padding; right: number = padding; bottom: number = padding; left: number = padding }
padding.topnumber
padding.rightnumber
padding.bottomnumber
padding.leftnumber
width() => number
height() => number

Defined in​

core/creation.ts:99


createGrid​

▸ createGrid(position, index, axis, offset, length, group, classes, eventEmitter): void

Creates a grid line based on a projected value.

Parameters​

NameType
positionnumber
indexnumber
axisAxis
offsetnumber
lengthnumber
groupSvg
classesstring[]
eventEmitterEventEmitter

Returns​

void

Defined in​

core/creation.ts:183


createGridBackground​

▸ createGridBackground(gridGroup, chartRect, className, eventEmitter): void

Creates a grid background rect and emits the draw event.

Parameters​

NameType
gridGroupSvg
chartRectChartRect
classNamestring
eventEmitterEventEmitter

Returns​

void

Defined in​

core/creation.ts:216


createLabel​

▸ createLabel(position, length, index, label, axis, axisOffset, labelOffset, group, classes, eventEmitter): void

Creates a label based on a projected value and an axis.

Parameters​

NameType
positionnumber
lengthnumber
indexnumber
labelLabel
axisAxis
axisOffsetnumber
labelOffsetObject
labelOffset.xnumber
labelOffset.ynumber
groupSvg
classesstring[]
eventEmitterEventEmitter

Returns​

void

Defined in​

core/creation.ts:245


getBounds​

▸ getBounds(axisLength, highLow, scaleMinSpace, onlyInteger?): Bounds

Calculate and retrieve all the bounds for the chart and return them in one array

Parameters​

NameTypeDefault valueDescription
axisLengthnumberundefinedThe length of the Axis used for
highLowObjectundefinedAn object containing a high and low property indicating the value range of the chart.
highLow.highnumberundefined-
highLow.lownumberundefined-
scaleMinSpacenumberundefinedThe minimum projected length a step should result in
onlyIntegerbooleanfalse

Returns​

Bounds

All the values to set the bounds of the chart

Defined in​

core/data/bounds.ts:18


getMetaData​

▸ getMetaData(seriesData, index): any

Get meta data of a specific value in a series.

Parameters​

NameType
seriesDataFlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>
indexnumber

Returns​

any

Defined in​

core/data/data.ts:13


isDataHoleValue​

▸ isDataHoleValue(value): value is undefined | null

Checks if a value is considered a hole in the data series.

Parameters​

NameType
valueunknown

Returns​

value is undefined | null

True if the value is considered a data hole

Defined in​

core/data/data.ts:29


isArrayOfSeries​

▸ isArrayOfSeries(value): value is (Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[]

Checks if value is array of series objects.

Parameters​

NameType
valueunknown

Returns​

value is (Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[]

Defined in​

core/data/data.ts:41


isMultiValue​

▸ isMultiValue(value): value is Multi

Checks if provided value object is multi value (contains x or y properties)

Parameters​

NameType
valueunknown

Returns​

value is Multi

Defined in​

core/data/data.ts:53


getMultiValue​

▸ getMultiValue(value, dimension?): undefined | number

Gets a value from a dimension value.x or value.y while returning value directly if it's a valid numeric value. If the value is not numeric and it's falsey this function will return defaultValue.

Parameters​

NameTypeDefault value
valueunknownundefined
dimensionAxisName'y'

Returns​

undefined | number

Defined in​

core/data/data.ts:64


getHighLow​

▸ getHighLow(data, options, dimension?): Object

Get highest and lowest value of data array. This Array contains the data that will be visualized in the chart.

Parameters​

NameTypeDescription
dataNormalizedSeries[]The array that contains the data to be visualized in the chart
optionsOptions<AxisOptions, AxisOptions>The Object that contains the chart options
dimension?AxisNameAxis dimension 'x' or 'y' used to access the correct value and high / low configuration

Returns​

Object

An object that contains the highest and lowest value that will be visualized on the chart.

NameType
highnumber
lownumber

Defined in​

core/data/highLow.ts:17


normalizeData​

▸ normalizeData(data, reverse?, multi?): NormalizedData<NormalizedFlatSeries>

Ensures that the data object passed as second argument to the charts is present and correctly initialized.

Parameters​

NameTypeDescription
dataData<FlatSeries<FlatSeriesPrimitiveValue>>The data object that is passed as second argument to the charts
reverse?boolean-
multi?false-

Returns​

NormalizedData<NormalizedFlatSeries>

The normalized data object

Defined in​

core/data/normalize.ts:27

▸ normalizeData(data, reverse, multi): NormalizedData<NormalizedSeries[]>

Parameters​

NameType
dataData<(Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[]>
reverseundefined | boolean
multitrue | AxisName

Returns​

NormalizedData<NormalizedSeries[]>

Defined in​

core/data/normalize.ts:32

▸ normalizeData(data, reverse, multi, distributed): NormalizedData<NormalizedSeries[]>

Parameters​

NameType
dataData<(Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[] | FlatSeries<FlatSeriesPrimitiveValue>>
reverseundefined | boolean
multiboolean | AxisName
distributedtrue

Returns​

NormalizedData<NormalizedSeries[]>

Defined in​

core/data/normalize.ts:37

▸ normalizeData(data, reverse?, multi?): NormalizedData<NormalizedFlatSeries | NormalizedSeries[]>

Parameters​

NameType
dataData<(Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[] | FlatSeries<FlatSeriesPrimitiveValue>>
reverse?boolean
multi?boolean | AxisName

Returns​

NormalizedData<NormalizedFlatSeries | NormalizedSeries[]>

Defined in​

core/data/normalize.ts:43


splitIntoSegments​

▸ splitIntoSegments(pathCoordinates, valueData, options?): Segment[]

Splits a list of coordinates and associated values into segments. Each returned segment contains a pathCoordinates valueData property describing the segment.

With the default options, segments consist of contiguous sets of points that do not have an undefined value. Any points with undefined values are discarded.

Options The following options are used to determine how segments are formed

var options = {
// If fillHoles is true, undefined values are simply discarded without creating a new segment. Assuming other options are default, this returns single segment.
fillHoles: false,
// If increasingX is true, the coordinates in all segments have strictly increasing x-values.
increasingX: false
};

Parameters​

NameTypeDescription
pathCoordinatesnumber[]List of point coordinates to be split in the form [x1, y1, x2, y2 ... xn, yn]
valueDataSegmentData[]List of associated point values in the form [v1, v2 .. vn]
options?ObjectOptions set by user
options.increasingX?boolean-
options.fillHoles?boolean-

Returns​

Segment[]

List of segments, each containing a pathCoordinates and valueData property.

Defined in​

core/data/segments.ts:27


serialize​

▸ serialize(data): string

This function serializes arbitrary data to a string. In case of data that can't be easily converted to a string, this function will create a wrapper object and serialize the data using JSON.stringify. The outcoming string will always be escaped using Chartist.escapingMap. If called with null or undefined the function will return immediately with null or undefined.

Parameters​

NameType
datastring | number | object

Returns​

string

Defined in​

core/data/serialize.ts:7

▸ serialize(data): string | null | undefined

Parameters​

NameType
dataunknown

Returns​

string | null | undefined

Defined in​

core/data/serialize.ts:8


deserialize​

▸ deserialize<T>(data): T

This function de-serializes a string previously serialized with Chartist.serialize. The string will always be unescaped using Chartist.escapingMap before it's returned. Based on the input value the return type can be Number, String or Object. JSON.parse is used with try / catch to see if the unescaped string can be parsed into an Object and this Object will be returned on success.

Type parameters​

NameType
Textends string | number | object = object

Parameters​

NameType
datastring

Returns​

T

Defined in​

core/data/serialize.ts:35

▸ deserialize<T>(data): T | null | undefined

Type parameters​

NameType
Textends string | number | object = object

Parameters​

NameType
dataundefined | null | string

Returns​

T | null | undefined

Defined in​

core/data/serialize.ts:38


ensureUnit​

▸ ensureUnit<T>(value, unit): string | T

Converts a number to a string with a unit. If a string is passed then this will be returned unmodified.

Type parameters​

Name
T

Parameters​

NameType
valueT
unitstring

Returns​

string | T

Returns the passed number value with unit.

Defined in​

core/lang.ts:5


quantity​

▸ quantity<T>(input): { value: number ; unit: undefined | string } | { unit: undefined ; value: number }

Converts a number or string to a quantity object.

Type parameters​

Name
T

Parameters​

NameType
inputT

Returns​

{ value: number ; unit: undefined | string } | { unit: undefined ; value: number }

Returns an object containing the value as number and the unit as string.

Defined in​

core/lang.ts:17


alphaNumerate​

▸ alphaNumerate(n): string

Generates a-z from a number 0 to 26

Parameters​

NameTypeDescription
nnumberA number from 0 to 26 that will result in a letter a-z

Returns​

string

A character from a-z based on the input number n

Defined in​

core/lang.ts:36


orderOfMagnitude​

▸ orderOfMagnitude(value): number

Calculate the order of magnitude for the chart scale

Parameters​

NameTypeDescription
valuenumberThe value Range of the chart

Returns​

number

The order of magnitude

Defined in​

core/math.ts:11


projectLength​

▸ projectLength(axisLength, length, bounds): number

Project a data length into screen coordinates (pixels)

Parameters​

NameTypeDescription
axisLengthnumberThe svg element for the chart
lengthnumberSingle data value from a series array
boundsBoundsAll the values to set the bounds of the chart

Returns​

number

The projected data length in pixels

Defined in​

core/math.ts:22


roundWithPrecision​

▸ roundWithPrecision(value, digits?): number

This helper function can be used to round values with certain precision level after decimal. This is used to prevent rounding errors near float point precision limit.

Parameters​

NameTypeDescription
valuenumberThe value that should be rounded with precision
digits?numberThe number of digits after decimal used to do the rounding

Returns​

number

Rounded value

Defined in​

core/math.ts:36


rho​

▸ rho(num): number

Pollard Rho Algorithm to find smallest factor of an integer value. There are more efficient algorithms for factorization, but this one is quite efficient and not so complex.

Parameters​

NameTypeDescription
numnumberAn integer number where the smallest factor should be searched for

Returns​

number

The smallest integer factor of the parameter num.

Defined in​

core/math.ts:46


polarToCartesian​

▸ polarToCartesian(centerX, centerY, radius, angleInDegrees): Object

Calculate cartesian coordinates of polar coordinates

Parameters​

NameTypeDescription
centerXnumberX-axis coordinates of center point of circle segment
centerYnumberX-axis coordinates of center point of circle segment
radiusnumberRadius of circle segment
angleInDegreesnumberAngle of circle segment in degrees

Returns​

Object

Coordinates of point on circumference

NameType
xnumber
ynumber

Defined in​

core/math.ts:88


optionsProvider​

▸ optionsProvider<T>(options, responsiveOptions, eventEmitter): OptionsProvider<T>

Provides options handling functionality with callback for options changes triggered by responsive options and media query matches

Type parameters​

NameType
Tunknown

Parameters​

NameTypeDescription
optionsTOptions set by user
responsiveOptionsundefined | ResponsiveOptions<T>Optional functions to add responsive behavior to chart
eventEmitterEventEmitterThe event emitter that will be used to emit the options changed events

Returns​

OptionsProvider<T>

The consolidated options object from the defaults, base and matching responsive options

Defined in​

core/optionsProvider.ts:17


extend​

▸ extend<T>(target): T

Simple recursive object extend

Type parameters​

Name
T

Parameters​

NameTypeDescription
targetTTarget object where the source will be merged into

Returns​

T

An object that has the same reference as target but is extended and merged with the properties of source

Defined in​

utils/extend.ts:7

▸ extend<T, A>(target, a): T & A

Type parameters​

Name
T
A

Parameters​

NameType
targetT
aA

Returns​

T & A

Defined in​

utils/extend.ts:8

▸ extend<T, A, B>(target, a, b): T & A & B

Type parameters​

Name
T
A
B

Parameters​

NameType
targetT
aA
bB

Returns​

T & A & B

Defined in​

utils/extend.ts:9


noop​

▸ noop<T>(n): T

Helps to simplify functional style code

Type parameters​

Name
T

Parameters​

NameTypeDescription
nTThis exact value will be returned by the noop function

Returns​

T

The same value that was provided to the n parameter

Defined in​

utils/functional.ts:6


times​

▸ times(length): undefined[]

Functional style helper to produce array with given length initialized with undefined values

Parameters​

NameType
lengthnumber

Returns​

undefined[]

Defined in​

utils/functional.ts:11

▸ times<T>(length, filler): T[]

Type parameters​

NameType
Tunknown

Parameters​

NameType
lengthnumber
filler(index: number) => T

Returns​

T[]

Defined in​

utils/functional.ts:12


sum​

▸ sum(previous, current): number

Sum helper to be used in reduce functions

Parameters​

NameType
previousnumber
currentnumber

Returns​

number

Defined in​

utils/functional.ts:26


serialMap​

▸ serialMap<T, K>(array, callback): K[]

Map for multi dimensional arrays where their nested arrays will be mapped in serial. The output array will have the length of the largest nested array. The callback function is called with variable arguments where each argument is the nested array value (or undefined if there are no more values).

For example:

Example

const data = [[1, 2], [3], []];
serialMap(data, cb);

// where cb will be called 2 times
// 1. call arguments: (1, 3, undefined)
// 2. call arguments: (2, undefined, undefined)

Type parameters​

Name
T
K

Parameters​

NameType
arrayT[][]
callback(...args: T[]) => K

Returns​

K[]

Defined in​

utils/functional.ts:43


safeHasProperty​

▸ safeHasProperty<T, K>(target, property): target is FilterByKey<T, K>

This function safely checks if an objects has an owned property.

Type parameters​

NameType
TT
Kextends string

Parameters​

NameTypeDescription
targetTThe object where to check for a property
propertyKThe property name

Returns​

target is FilterByKey<T, K>

Returns true if the object owns the specified property

Defined in​

utils/utils.ts:9


isNumeric​

▸ isNumeric(value): true

Checks if a value can be safely coerced to a number. This includes all values except null which result in finite numbers when coerced. This excludes NaN, since it's not finite.

Parameters​

NameType
valuenumber

Returns​

true

Defined in​

utils/utils.ts:24

▸ isNumeric(value): boolean

Parameters​

NameType
valueunknown

Returns​

boolean

Defined in​

utils/utils.ts:25


isFalseyButZero​

▸ isFalseyButZero(value): value is undefined | null | false | ""

Returns true on all falsey values except the numeric value 0.

Parameters​

NameType
valueunknown

Returns​

value is undefined | null | false | ""

Defined in​

utils/utils.ts:33


getNumberOrUndefined​

▸ getNumberOrUndefined(value): number

Returns a number if the passed parameter is a valid number or the function will return undefined. On all other values than a valid number, this function will return undefined.

Parameters​

NameType
valuenumber

Returns​

number

Defined in​

utils/utils.ts:42

▸ getNumberOrUndefined(value): number | undefined

Parameters​

NameType
valueunknown

Returns​

number | undefined

Defined in​

utils/utils.ts:43


isArrayOfArrays​

▸ isArrayOfArrays(data): data is unknown[][]

Checks if value is array of arrays or not.

Parameters​

NameType
dataunknown

Returns​

data is unknown[][]

Defined in​

utils/utils.ts:51


each​

▸ each<T>(list, callback, reverse?): void

Loop over array.

Type parameters​

Name
T

Parameters​

NameTypeDefault value
listT[]undefined
callback(item: T, index: number, itemIndex: number) => voidundefined
reversebooleanfalse

Returns​

void

Defined in​

utils/utils.ts:62