chartist
Classes
- AutoScaleAxis
- Axis
- FixedScaleAxis
- StepAxis
- BarChart
- BaseChart
- LineChart
- PieChart
- EventEmitter
- Svg
- SvgList
- SvgPath
Interfaces
- BarChartOptions
- BarDrawEvent
- LineChartOptions
- PointDrawEvent
- LineDrawEvent
- AreaDrawEvent
- Dot
- PieChartOptions
- SliceDrawEvent
- SliceLabelDrawEvent
- BaseChartEventsTypes
- OptionsProvider
- ChartPadding
- ChartRect
- Options
- AxisOptions
- Bounds
- Segment
- SegmentData
- Data
- SeriesObject
- SeriesObjectValue
- FlatSeriesObjectValue
- NormalizedData
- CreatedEvent
- DrawEvent
- DataEvent
- OptionsChangedEvent
- GridDrawEvent
- GridBackgroundDrawEvent
- LabelDrawEvent
- BasePathParams
- CurveParams
- ArcParams
- SvgPathOptions
- AnimationDefinition
- AnimationEvent
Namespaces
Variables
axisUnits
• Const
axisUnits: Object
Type declaration
Name | Type |
---|---|
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
namespaces
• Const
namespaces: Record
<string
, string
>
This object contains all namespaces used within Chartist.
Defined in
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
escapingMap
• Const
escapingMap: Record
<string
, string
>
A map with characters to escape for strings to be safely used as attribute values.
Defined in
EPSILON
• Const
EPSILON: 2.221e-16
Defined in
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
Name | Type |
---|---|
easeInSine | number [] |
easeOutSine | number [] |
easeInOutSine | number [] |
easeInQuad | number [] |
easeOutQuad | number [] |
easeInOutQuad | number [] |
easeInCubic | number [] |
easeOutCubic | number [] |
easeInOutCubic | number [] |
easeInQuart | number [] |
easeOutQuart | number [] |
easeInOutQuart | number [] |
easeInQuint | number [] |
easeOutQuint | number [] |
easeInOutQuint | number [] |
easeInExpo | number [] |
easeOutExpo | number [] |
easeInOutExpo | number [] |
easeInCirc | number [] |
easeOutCirc | number [] |
easeInOutCirc | number [] |
easeInBack | number [] |
easeOutBack | number [] |
easeInOutBack | number [] |
Defined in
Type Aliases
XAxisUnits
Ƭ XAxisUnits: typeof x
Defined in
YAxisUnits
Ƭ YAxisUnits: typeof y
Defined in
AxisUnits
Ƭ AxisUnits: XAxisUnits
| YAxisUnits
Defined in
AxisType
Ƭ AxisType: typeof AutoScaleAxis
| typeof FixedScaleAxis
| typeof StepAxis
Defined in
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
Name | Type |
---|---|
pathCoordinates | number [] |
valueData | SegmentData [] |
Returns
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"
, "classNames"
>
Defined in
charts/PieChart/PieChart.types.ts:87
PieChartCreatedEvent
Ƭ PieChartCreatedEvent: Omit
<CreatedEvent
<PieChartOptions
>, "axisX"
| "axisY"
>
Defined in
charts/PieChart/PieChart.types.ts:100
PieChartEventsTypes
Ƭ PieChartEventsTypes: BaseChartEventsTypes
<PieChartCreatedEvent
, SliceDrawEvent
| SliceLabelDrawEvent
>
Defined in
charts/PieChart/PieChart.types.ts:125
Plugin
Ƭ Plugin: (chart
: any
, options?
: any
) => void
Type declaration
▸ (chart
, options?
): void
Parameters
Name | Type |
---|---|
chart | any |
options? | any |
Returns
void
Defined in
Meta
Ƭ Meta: any
Defined in
OptionsWithDefaults
Ƭ OptionsWithDefaults: RequiredKeys
<Options
<RequiredKeys
<AxisOptions
, "offset"
| "labelOffset"
| "labelInterpolationFnc"
>, RequiredKeys
<AxisOptions
, "offset"
| "labelOffset"
| "labelInterpolationFnc"
>>, "axisX"
| "axisY"
| "classNames"
>
Defined in
ResponsiveOptions
Ƭ ResponsiveOptions<T
>: [string
, T
][]
Type parameters
Name | Type |
---|---|
T | Options |
Defined in
AxisName
Ƭ AxisName: "x"
| "y"
Defined in
Multi
Ƭ Multi: { x
: number
| string
| Date
| null
; y
: number
| string
| Date
| null
} | { x
: number
| string
| Date
| null
} | { y
: number
| string
| Date
| null
}
Defined in
NormalizedMulti
Ƭ NormalizedMulti: { x
: number
; y
: number
} | { x
: number
} | { y
: number
}
Defined in
Label
Ƭ Label: string
| number
| Date
Data
Defined in
AllSeriesTypes
Ƭ AllSeriesTypes: FlatSeries
| (Series
| SeriesObject
)[]
Defined in
Series
Ƭ Series<T
>: SeriesValue
<T
>[]
Series
Type parameters
Name | Type |
---|---|
T | SeriesPrimitiveValue |
Defined in
SeriesValue
Ƭ SeriesValue<T
>: SeriesObjectValue
<T
> | T
Type parameters
Name | Type |
---|---|
T | SeriesPrimitiveValue |
Defined in
SeriesPrimitiveValue
Ƭ SeriesPrimitiveValue: number
| string
| boolean
| Date
| Multi
| null
| undefined
Defined in
FlatSeries
Ƭ FlatSeries<T
>: FlatSeriesValue
<T
>[]
Flat Series
Type parameters
Name | Type |
---|---|
T | FlatSeriesPrimitiveValue |
Defined in
FlatSeriesValue
Ƭ FlatSeriesValue<T
>: SeriesValue
<T
> | FlatSeriesObjectValue
<T
>
Type parameters
Name | Type |
---|---|
T | FlatSeriesPrimitiveValue |
Defined in
FlatSeriesPrimitiveValue
Ƭ FlatSeriesPrimitiveValue: number
| string
| null
| undefined
Defined in
AllNormalizedSeriesTypes
Ƭ AllNormalizedSeriesTypes: NormalizedFlatSeries
| NormalizedSeries
[]
Normalized Data
Defined in
NormalizedSeries
Ƭ NormalizedSeries: NormalizedSeriesValue
[]
Normalized Series
Defined in
NormalizedSeriesValue
Ƭ NormalizedSeriesValue: NormalizedSeriesPrimitiveValue
Defined in
NormalizedSeriesPrimitiveValue
Ƭ NormalizedSeriesPrimitiveValue: number
| NormalizedMulti
| undefined
Defined in
NormalizedFlatSeries
Ƭ NormalizedFlatSeries: number
[]
Normalized Flat Series
Defined in
AxesDrawEvent
Ƭ AxesDrawEvent: GridDrawEvent
| GridBackgroundDrawEvent
| LabelDrawEvent
Defined in
EventListener
Ƭ EventListener<T
>: (data
: T
) => void
Type parameters
Name | Type |
---|---|
T | any |
Type declaration
▸ (data
): void
Parameters
Name | Type |
---|---|
data | T |
Returns
void
Defined in
AllEventsListener
Ƭ AllEventsListener<T
>: (event
: string
, data
: T
) => void
Type parameters
Name | Type |
---|---|
T | any |
Type declaration
▸ (event
, data
): void
Parameters
Name | Type |
---|---|
event | string |
data | T |
Returns
void
Defined in
MoveParams
Ƭ MoveParams: BasePathParams
Defined in
LineParams
Ƭ LineParams: BasePathParams
Defined in
PathParams
Ƭ PathParams: MoveParams
| LineParams
| CurveParams
| ArcParams
Defined in
PathCommand
Ƭ PathCommand<T
>: { command
: string
; data?
: SegmentData
} & T
Type parameters
Name | Type |
---|---|
T | extends PathParams = PathParams |
Defined in
Attributes
Ƭ Attributes: Record
<string
, number
| string
| undefined
| null
>
Defined in
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
Name | Type |
---|---|
T | T |
K | extends string |
Defined in
RequiredKeys
Ƭ RequiredKeys<T
, K
, V
>: T
& Required
<Pick
<T
, K
| V
>> & { [key in V]: Required<T[V]> }
Type parameters
Name | Type |
---|---|
T | T |
K | extends keyof T |
V | extends keyof T = never |
Defined in
Functions
getSeriesOption
▸ getSeriesOption<T
>(series
, options
, key
): LineChartOptionsWithDefaults
[T
]
Type parameters
Name | Type |
---|---|
T | extends "width" | "height" | "axisX" | "axisY" | "showLine" | "showPoint" | "areaBase" | "lineSmooth" | "chartPadding" | "classNames" | "showArea" | "showGridBackground" | "fullWidth" | "reverseData" | "low" | "high" | "referenceValue" | "plugins" |
Parameters
Name | Type |
---|---|
series | Series <SeriesPrimitiveValue > | SeriesObject <SeriesPrimitiveValue > |
options | LineChartOptionsWithDefaults |
key | T |
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
Name | Type |
---|---|
center | Dot |
label | Dot |
direction | LabelDirection |
Returns
Defined in
charts/PieChart/PieChart.ts:79
createSvg
▸ createSvg(container
, width?
, height?
, className?
): Svg
Create or reinitialize the SVG element for the chart
Parameters
Name | Type | Default value | Description |
---|---|---|---|
container | Element | undefined | The containing DOM Node object that will be used to plant the SVG element |
width | string | number | '100%' | Set the width of the SVG element. Default is 100% |
height | string | number | '100%' | Set the height of the SVG element. Default is 100% |
className? | string | undefined | Specify a class to be added to the SVG element |
Returns
The created/reinitialized SVG element
Defined in
normalizePadding
▸ normalizePadding(padding
): Object
Converts a number into a padding object.
Parameters
Name | Type |
---|---|
padding | undefined | 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.
Name | Type |
---|---|
top | number |
right | number |
bottom | number |
left | number |
Defined in
createChartRect
▸ createChartRect(svg
, options
): Object
Initialize chart drawing rectangle (area where chart is drawn) x1,y1 = bottom left / x2,y2 = top right
Parameters
Name | Type | Description |
---|---|---|
svg | Svg | The svg element for the chart |
options | Options <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
Name | Type |
---|---|
x1 | number |
x2 | number |
y1 | number |
y2 | number |
padding | { top : number = padding; right : number = padding; bottom : number = padding; left : number = padding } |
padding.top | number |
padding.right | number |
padding.bottom | number |
padding.left | number |
width | () => number |
height | () => number |
Defined in
createGrid
▸ createGrid(position
, index
, axis
, offset
, length
, group
, classes
, eventEmitter
): void
Creates a grid line based on a projected value.
Parameters
Name | Type |
---|---|
position | number |
index | number |
axis | Axis |
offset | number |
length | number |
group | Svg |
classes | string [] |
eventEmitter | EventEmitter |
Returns
void
Defined in
createGridBackground
▸ createGridBackground(gridGroup
, chartRect
, className
, eventEmitter
): void
Creates a grid background rect and emits the draw event.
Parameters
Name | Type |
---|---|
gridGroup | Svg |
chartRect | ChartRect |
className | string |
eventEmitter | EventEmitter |
Returns
void
Defined in
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
Name | Type |
---|---|
position | number |
length | number |
index | number |
label | Label |
axis | Axis |
axisOffset | number |
labelOffset | Object |
labelOffset.x | number |
labelOffset.y | number |
group | Svg |
classes | string [] |
eventEmitter | EventEmitter |
Returns
void
Defined in
getBounds
▸ getBounds(axisLength
, highLow
, scaleMinSpace
, onlyInteger?
): Bounds
Calculate and retrieve all the bounds for the chart and return them in one array
Parameters
Name | Type | Default value | Description |
---|---|---|---|
axisLength | number | undefined | The length of the Axis used for |
highLow | Object | undefined | An object containing a high and low property indicating the value range of the chart. |
highLow.high | number | undefined | - |
highLow.low | number | undefined | - |
scaleMinSpace | number | undefined | The minimum projected length a step should result in |
onlyInteger | boolean | false |
Returns
All the values to set the bounds of the chart
Defined in
getMetaData
▸ getMetaData(seriesData
, index
): any
Get meta data of a specific value in a series.
Parameters
Name | Type |
---|---|
seriesData | FlatSeriesValue <FlatSeriesPrimitiveValue > | Series <SeriesPrimitiveValue > | SeriesObject <SeriesPrimitiveValue > |
index | number |
Returns
any
Defined in
isDataHoleValue
▸ isDataHoleValue(value
): value is undefined | null
Checks if a value is considered a hole in the data series.
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is undefined | null
True if the value is considered a data hole
Defined in
isArrayOfSeries
▸ isArrayOfSeries(value
): value is (Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[]
Checks if value is array of series objects.
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is (Series<SeriesPrimitiveValue> | SeriesObject<SeriesPrimitiveValue>)[]
Defined in
isMultiValue
▸ isMultiValue(value
): value is Multi
Checks if provided value object is multi value (contains x or y properties)
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is Multi
Defined in
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
Name | Type | Default value |
---|---|---|
value | unknown | undefined |
dimension | AxisName | 'y' |
Returns
undefined
| number
Defined in
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
Name | Type | Description |
---|---|---|
data | NormalizedSeries [] | The array that contains the data to be visualized in the chart |
options | Options <AxisOptions , AxisOptions > | The Object that contains the chart options |
dimension? | AxisName | Axis 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.
Name | Type |
---|---|
high | number |
low | number |
Defined in
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
Name | Type | Description |
---|---|---|
data | Data <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
▸ normalizeData(data
, reverse
, multi
): NormalizedData
<NormalizedSeries
[]>
Parameters
Name | Type |
---|---|
data | Data <(Series <SeriesPrimitiveValue > | SeriesObject <SeriesPrimitiveValue >)[]> |
reverse | undefined | boolean |
multi | true | AxisName |
Returns
NormalizedData
<NormalizedSeries
[]>
Defined in
▸ normalizeData(data
, reverse
, multi
, distributed
): NormalizedData
<NormalizedSeries
[]>
Parameters
Name | Type |
---|---|
data | Data <(Series <SeriesPrimitiveValue > | SeriesObject <SeriesPrimitiveValue >)[] | FlatSeries <FlatSeriesPrimitiveValue >> |
reverse | undefined | boolean |
multi | boolean | AxisName |
distributed | true |
Returns
NormalizedData
<NormalizedSeries
[]>
Defined in
▸ normalizeData(data
, reverse?
, multi?
): NormalizedData
<NormalizedFlatSeries
| NormalizedSeries
[]>
Parameters
Name | Type |
---|---|
data | Data <(Series <SeriesPrimitiveValue > | SeriesObject <SeriesPrimitiveValue >)[] | FlatSeries <FlatSeriesPrimitiveValue >> |
reverse? | boolean |
multi? | boolean | AxisName |
Returns
NormalizedData
<NormalizedFlatSeries
| NormalizedSeries
[]>
Defined in
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
Name | Type | Description |
---|---|---|
pathCoordinates | number [] | List of point coordinates to be split in the form [x1, y1, x2, y2 ... xn, yn] |
valueData | SegmentData [] | List of associated point values in the form [v1, v2 .. vn] |
options? | Object | Options set by user |
options.increasingX? | boolean | - |
options.fillHoles? | boolean | - |
Returns
Segment
[]
List of segments, each containing a pathCoordinates and valueData property.
Defined in
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
Name | Type |
---|---|
data | string | number | object |
Returns
string
Defined in
▸ serialize(data
): string
| null
| undefined
Parameters
Name | Type |
---|---|
data | unknown |
Returns
string
| null
| undefined
Defined in
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
Name | Type |
---|---|
T | extends string | number | object = object |
Parameters
Name | Type |
---|---|
data | string |
Returns
T
Defined in
▸ deserialize<T
>(data
): T
| null
| undefined
Type parameters
Name | Type |
---|---|
T | extends string | number | object = object |
Parameters
Name | Type |
---|---|
data | undefined | null | string |
Returns
T
| null
| undefined
Defined in
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
Name | Type |
---|---|
value | T |
unit | string |
Returns
string
| T
Returns the passed number value with unit.
Defined in
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
Name | Type |
---|---|
input | T |
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
alphaNumerate
▸ alphaNumerate(n
): string
Generates a-z from a number 0 to 26
Parameters
Name | Type | Description |
---|---|---|
n | number | A 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
orderOfMagnitude
▸ orderOfMagnitude(value
): number
Calculate the order of magnitude for the chart scale
Parameters
Name | Type | Description |
---|---|---|
value | number | The value Range of the chart |
Returns
number
The order of magnitude
Defined in
projectLength
▸ projectLength(axisLength
, length
, bounds
): number
Project a data length into screen coordinates (pixels)
Parameters
Name | Type | Description |
---|---|---|
axisLength | number | The svg element for the chart |
length | number | Single data value from a series array |
bounds | Bounds | All the values to set the bounds of the chart |
Returns
number
The projected data length in pixels
Defined in
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
Name | Type | Description |
---|---|---|
value | number | The value that should be rounded with precision |
digits? | number | The number of digits after decimal used to do the rounding |
Returns
number
Rounded value
Defined in
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
Name | Type | Description |
---|---|---|
num | number | An integer number where the smallest factor should be searched for |
Returns
number
The smallest integer factor of the parameter num.
Defined in
polarToCartesian
▸ polarToCartesian(centerX
, centerY
, radius
, angleInDegrees
): Object
Calculate cartesian coordinates of polar coordinates
Parameters
Name | Type | Description |
---|---|---|
centerX | number | X-axis coordinates of center point of circle segment |
centerY | number | X-axis coordinates of center point of circle segment |
radius | number | Radius of circle segment |
angleInDegrees | number | Angle of circle segment in degrees |
Returns
Object
Coordinates of point on circumference
Name | Type |
---|---|
x | number |
y | number |
Defined in
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
Name | Type |
---|---|
T | unknown |
Parameters
Name | Type | Description |
---|---|---|
options | T | Options set by user |
responsiveOptions | undefined | ResponsiveOptions <T > | Optional functions to add responsive behavior to chart |
eventEmitter | EventEmitter | The event emitter that will be used to emit the options changed events |
Returns
The consolidated options object from the defaults, base and matching responsive options
Defined in
extend
▸ extend<T
>(target
): T
Simple recursive object extend
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
target | T | Target 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
▸ extend<T
, A
>(target
, a
): T
& A
Type parameters
Name |
---|
T |
A |
Parameters
Name | Type |
---|---|
target | T |
a | A |
Returns
T
& A
Defined in
▸ extend<T
, A
, B
>(target
, a
, b
): T
& A
& B
Type parameters
Name |
---|
T |
A |
B |
Parameters
Name | Type |
---|---|
target | T |
a | A |
b | B |
Returns
T
& A
& B
Defined in
noop
▸ noop<T
>(n
): T
Helps to simplify functional style code
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
n | T | This exact value will be returned by the noop function |
Returns
T
The same value that was provided to the n parameter
Defined in
times
▸ times(length
): undefined
[]
Functional style helper to produce array with given length initialized with undefined values
Parameters
Name | Type |
---|---|
length | number |
Returns
undefined
[]
Defined in
▸ times<T
>(length
, filler
): T
[]
Type parameters
Name | Type |
---|---|
T | unknown |
Parameters
Name | Type |
---|---|
length | number |
filler | (index : number ) => T |
Returns
T
[]
Defined in
sum
▸ sum(previous
, current
): number
Sum helper to be used in reduce functions
Parameters
Name | Type |
---|---|
previous | number |
current | number |
Returns
number
Defined in
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
Name | Type |
---|---|
array | T [][] |
callback | (...args : T []) => K |
Returns
K
[]
Defined in
safeHasProperty
▸ safeHasProperty<T
, K
>(target
, property
): target is FilterByKey<T, K>
This function safely checks if an objects has an owned property.
Type parameters
Name | Type |
---|---|
T | T |
K | extends string |
Parameters
Name | Type | Description |
---|---|---|
target | T | The object where to check for a property |
property | K | The property name |
Returns
target is FilterByKey<T, K>
Returns true if the object owns the specified property
Defined in
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
Name | Type |
---|---|
value | number |
Returns
true
Defined in
▸ isNumeric(value
): boolean
Parameters
Name | Type |
---|---|
value | unknown |
Returns
boolean
Defined in
isFalseyButZero
▸ isFalseyButZero(value
): value is undefined | null | false | ""
Returns true on all falsey values except the numeric value 0.
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is undefined | null | false | ""
Defined in
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
Name | Type |
---|---|
value | number |
Returns
number
Defined in
▸ getNumberOrUndefined(value
): number
| undefined
Parameters
Name | Type |
---|---|
value | unknown |
Returns
number
| undefined
Defined in
isArrayOfArrays
▸ isArrayOfArrays(data
): data is unknown[][]
Checks if value is array of arrays or not.
Parameters
Name | Type |
---|---|
data | unknown |
Returns
data is unknown[][]
Defined in
each
▸ each<T
>(list
, callback
, reverse?
): void
Loop over array.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Default value |
---|---|---|
list | T [] | undefined |
callback | (item : T , index : number , itemIndex : number ) => void | undefined |
reverse | boolean | false |
Returns
void