These are the 1.x classes and what only they use, kept so 1.x code runs unchanged. New code uses the chart functions: see Charts, and Coming from 1.x for moving over.
class LineChart extends PresetChart<LineChartEventsTypes, LineChartData, LineChartOptions>new LineChart(query: string | Element | null, data: LineChartData, options?: LineChartOptions<AxisOptions, AxisOptions>, responsiveOptions?: ResponsiveOptions<LineChartOptions<AxisOptions, AxisOptions>>)The 1.x line chart class: a wrapper over the lineChart preset with the 1.x API. 1.x events and 1.x plugin functions need the compat plugin (chartist/compat).
Deprecated. Use lineChart(). Removed in 3.0.
See also: lineChart for the v2 functional API.
class BarChart extends PresetChart<BarChartEventsTypes, BarChartData, BarChartOptions>new BarChart(query: string | Element | null, data: BarChartData, options?: BarChartOptions<AxisOptions, AxisOptions>, responsiveOptions?: ResponsiveOptions<BarChartOptions<AxisOptions, AxisOptions>>)The 1.x bar chart class: a wrapper over the barChart preset with the 1.x API. 1.x events and 1.x plugin functions need the compat plugin (chartist/compat).
Deprecated. Use barChart(). Removed in 3.0.
See also: barChart for the v2 functional API.
class PieChart extends PresetChart<PieChartEventsTypes, PieChartData, PieChartOptions>new PieChart(query: string | Element | null, data: PieChartData, options?: PieChartOptions, responsiveOptions?: ResponsiveOptions<PieChartOptions>)The 1.x pie chart class: a wrapper over the pieChart preset with the 1.x API. 1.x events and 1.x plugin functions need the compat plugin (chartist/compat).
Deprecated. Use pieChart(). Removed in 3.0.
See also: pieChart for the v2 functional API.
class BaseChart<TEventsTypes = BaseChartEventsTypes>new BaseChart<TEventsTypes = BaseChartEventsTypes<CreatedEvent<Options<AxisOptions, AxisOptions>>, DrawEvent>>(query: string | Element | null, data: Data, defaultOptions: Options, options: Options, responsiveOptions?: ResponsiveOptions<Options<AxisOptions, AxisOptions>>)The base class of the 1.x chart classes (LineChart, BarChart, PieChart): the container, update, detach, on and off.
Deprecated. Use the chart functions: lineChart(), barChart(), pieChart() and chart(). Removed in 3.0.
function getSeriesOption<T extends 'height' | 'width' | 'viewBox' | 'axisX' | 'axisY' | 'classNames' | 'high' | 'low' | 'referenceValue' | 'chartPadding' | 'plugins' | 'showLine' | 'showPoint' | 'showArea' | 'areaBase' | 'lineSmooth' | 'showGridBackground' | 'fullWidth' | 'reverseData'>(series: Series | SeriesObject<SeriesPrimitiveValue>, options: LineChartOptionsWithDefaults, key: T): LineChartOptionsWithDefaults[T]Reads a line chart option for a series: the per-series value from options.series[name] if the series has a name and sets it, the chart's value otherwise.
Deprecated. Part of the 1.x chart classes, with no functional counterpart. Removed in 3.0.
Parameters
seriesSeries | SeriesObject<SeriesPrimitiveValue>optionsLineChartOptionsWithDefaultskeyT
function createSvg(container: Element, width?: string | number, height?: string | number, className?: string, viewBox?: ViewBox): SvgCreate or reinitialize the SVG element for the chart
Deprecated. Part of the 1.x chart classes. The functional API builds a scene instead. Removed in 3.0.
Parameters
containerElementThe 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?stringSpecify a class to be added to the SVG element
viewBox?ViewBox
Returns
The created/reinitialized SVG element
function createGrid(position: number, index: number, axis: Axis, offset: number, length: number, group: Svg, classes: string[], eventEmitter: EventEmitter): voidCreates a grid line based on a projected value.
Deprecated. Use the axisGrid() layer. Removed in 3.0.
Parameters
positionnumberindexnumberaxisAxisoffsetnumberlengthnumbergroupSvgclassesstring[]eventEmitterEventEmitter
function createGridBackground(gridGroup: Svg, chartRect: ChartRect, className: string, eventEmitter: EventEmitter): voidCreates a grid background rect and emits the draw event.
Deprecated. Use the axisGrid() layer. Removed in 3.0.
Parameters
gridGroupSvgchartRectChartRectclassNamestringeventEmitterEventEmitter
function createLabel(position: number, length: number, index: number, label: Label, axis: Axis, axisOffset: number, labelOffset: { x: number; y: number }, group: Svg, classes: string[], eventEmitter: EventEmitter): voidCreates a label based on a projected value and an axis.
Deprecated. Use the axisLabels() layer. Removed in 3.0.
Parameters
positionnumberlengthnumberindexnumberlabelLabelaxisAxisaxisOffsetnumberlabelOffset{ x: number; y: number }groupSvgclassesstring[]eventEmitterEventEmitter
function optionsProvider<T = unknown>(options: T, responsiveOptions: ResponsiveOptions<T> | undefined, eventEmitter: EventEmitter): OptionsProvider<T>Provides options handling functionality with callback for options changes triggered by responsive options and media query matches
Deprecated. Part of the 1.x chart classes. Responsive options are an argument of the chart functions. Removed in 3.0.
Parameters
optionsTOptions set by user
responsiveOptionsResponsiveOptions<T> | undefinedOptional functions to add responsive behavior to chart
eventEmitterEventEmitterThe 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
class AutoScaleAxis extends Axisnew AutoScaleAxis(axisUnit: AxisUnits, data: NormalizedSeries[], chartRect: ChartRect, options: AxisOptions)The 1.x axis with a scale fitted to the values, in round steps at least scaleMinSpace px apart.
Deprecated. Use autoScaleAxis(). Removed in 3.0.
class Axisnew Axis(units: AxisUnits, chartRect: ChartRect, ticks: Label[])The base class of the 1.x axes: projects values to px along the drawing area and draws its grid lines and labels.
Deprecated. Use the scale functions autoScaleAxis(), fixedScaleAxis() and stepAxis(). Removed in 3.0.
class FixedScaleAxis extends Axisnew FixedScaleAxis(axisUnit: AxisUnits, data: NormalizedSeries[], chartRect: ChartRect, options: AxisOptions)The 1.x axis with fixed ticks: the ticks option, or divisor equal steps from low to high, with a tick at both ends.
Deprecated. Use fixedScaleAxis(). Removed in 3.0.
class StepAxis extends Axisnew StepAxis(axisUnit: AxisUnits, _data: unknown, chartRect: ChartRect, options: AxisOptions)The 1.x axis with one step per tick, such as the labels of a line chart's X axis.
Deprecated. Use stepAxis(). Removed in 3.0.
class EventEmitternew EventEmitter()The 1.x event emitter: on, off and emit by event name, with '*' for all events.
Deprecated. Use the chart handle's on() and off(). Removed in 3.0.
type AxisType = typeof AutoScaleAxis | typeof FixedScaleAxis | typeof StepAxisThe 1.x axis classes an axis's type option takes: AutoScaleAxis, FixedScaleAxis or StepAxis.
Deprecated. Use the scale functions autoScaleAxis(), fixedScaleAxis() and stepAxis(). Removed in 3.0.
interface BarChartOptions<TXAxisOptions = AxisOptions, TYAxisOptions = TXAxisOptions> extends Options<TXAxisOptions, TYAxisOptions>The options of a bar chart (1.x BarChart, and barChart).
Deprecated. For barChart(), the options type is BarChartPresetOptions. Removed in 3.0.
Properties
classNames?{ … }The class names of the chart's elements. Change them to style the chart with your own CSS instead of Chartist's.
classNames.chart?stringdefault'ct-chart-bar'The chart's SVG element.
classNames.horizontalBars?stringdefault'ct-horizontal-bars'The chart's SVG element, with
horizontalBars.classNames.label?stringdefault'ct-label'Each axis label.
classNames.labelGroup?stringdefault'ct-labels'The group of an axis's labels.
classNames.series?stringdefault'ct-series'The group of each series.
classNames.bar?stringdefault'ct-bar'Each bar.
classNames.grid?stringdefault'ct-grid'Each grid line.
classNames.gridGroup?stringdefault'ct-grids'The group of the grid lines.
classNames.gridBackground?stringdefault'ct-grid-background'The grid background (with
showGridBackground).classNames.vertical?stringdefault'ct-vertical'Labels and grid lines of the vertical axis.
classNames.horizontal?stringdefault'ct-horizontal'Labels and grid lines of the horizontal axis.
classNames.start?stringdefault'ct-start'Labels at the start of their axis (left or top).
classNames.end?stringdefault'ct-end'Labels at the end of their axis (right or bottom).
seriesBarDistance?numberdefault15The distance in px between the bars of a group (one bar per series).
stackBars?booleandefaultfalseStacks the bars of a group on each other;
stackModesays how.stackMode?boolean | 'accumulate' | 'accumulate-relative'default'accumulate'How stacked bars stack:
accumulateadds up each group's values (the value axis fits the totals),accumulate-relativestacks positive values up and negative values down, andtruedraws every bar from zero, overlapping.horizontalBars?booleandefaultfalseDraws horizontal bars. The axes swap: the Y axis shows the labels and the X axis the values, so swap their options too.
distributeSeries?booleandefaultfalseTreats one flat array of values as one series per value, each in its own color: a profile rather than values over time.
reverseData?booleandefaultfalseReverses the labels, the order of the series and each series' values.
showGridBackground?booleandefaultfalseFills the grid area with a background (class
ct-grid-background).width?string | numberThe chart's width: px as a number, or a CSS length such as
'100%'. Without it, the chart takes the width of its container.height?string | numberThe chart's height: px as a number, or a CSS length such as
'300px'. Without it, the chart takes the height of its container.low?numberThe lowest value the value axis shows, instead of the data's lowest. Values below it are drawn outside the drawing area.
high?numberThe highest value the value axis shows, instead of the data's highest. Values above it are drawn outside the drawing area.
referenceValue?numberdefault0A value the value axis always includes, such as 0, so it shows even when all values are above or below it. Bar charts use 0.
chartPadding?number | Partial<ChartPadding>default{ top: 15, right: 15, bottom: 5, left: 10 }Space in px between the chart's edges and its drawing area (labels sit in it): one number for every side, or an object with some sides.
axisX?TXAxisOptionsdefault{ offset: 30, position: 'end', labelOffset: { x: 0, y: 0 }, showLabel: true, showGrid: true, scaleMinSpace: 30, onlyInteger: false }Options of the X axis.
axisY?TYAxisOptionsdefault{ offset: 40, position: 'start', labelOffset: { x: 0, y: 0 }, showLabel: true, showGrid: true, scaleMinSpace: 20, onlyInteger: false }Options of the Y axis.
plugins?(Plugin | [Plugin, any] | { readonly name: string; install: (chart: any, options?: any) => void })[]1.x plugin functions (they run with the compat plugin) and v2 plugins such as
compat.viewBox?ViewBoxA
viewBoxfor the SVG, so the drawing scales with its box instead of being drawn for its size. Text scales too: adjust it with responsive options.viewBox.widthnumberThe viewBox width, in SVG units.
viewBox.heightnumberThe viewBox height, in SVG units.
type 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'>BarChartOptions after the defaults are applied: the 1.x BarChart works with these.
Deprecated. The resolved options of the 1.x BarChart. Removed in 3.0.
type BarChartCreatedEvent = CreatedEvent<BarChartOptions>The payload of a bar chart's 1.x created event.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface BarDrawEvent extends DrawEventThe 1.x draw event of a bar, one per value. The bar is a line element from its base (x1, y1) to its value (x2, y2).
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'bar'Always
'bar'.valuenumber | NormalizedMultiThe bar's normalized value: a number, or
{ x, y }numbers.x1numberThe x of the bar's base, in px.
y1numberThe y of the bar's base, in px.
x2numberThe x of the bar's end (its value), in px.
y2numberThe y of the bar's end (its value), in px.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
seriesIndexnumberThe index of the series in the data.
type BarChartEventsTypes = BaseChartEventsTypes<BarChartCreatedEvent, AxesDrawEvent | BarDrawEvent>The 1.x events of a BarChart and their payloads, by event name.
Deprecated. The 1.x events of a BarChart. On barChart(), the handle's on() knows its events. Removed in 3.0.
Properties
type LineInterpolation = (pathCoordinates: number[], valueData: SegmentData[]) => SvgPathTurns a series' points into the path of its line (see Interpolation).
interface LineChartOptions<TXAxisOptions = AxisOptions, TYAxisOptions = TXAxisOptions> extends Options<TXAxisOptions, TYAxisOptions>The options of a line chart (1.x LineChart, and lineChart).
Deprecated. For lineChart(), the options type is LineChartPresetOptions. Removed in 3.0.
Properties
classNames?{ … }The class names of the chart's elements. Change them to style the chart with your own CSS instead of Chartist's.
classNames.chart?stringdefault'ct-chart-line'The chart's SVG element.
classNames.label?stringdefault'ct-label'Each axis label.
classNames.labelGroup?stringdefault'ct-labels'The group of an axis's labels.
classNames.series?stringdefault'ct-series'The group of each series.
classNames.line?stringdefault'ct-line'Each line.
classNames.point?stringdefault'ct-point'Each point.
classNames.area?stringdefault'ct-area'Each area.
classNames.grid?stringdefault'ct-grid'Each grid line.
classNames.gridGroup?stringdefault'ct-grids'The group of the grid lines.
classNames.gridBackground?stringdefault'ct-grid-background'The grid background (with
showGridBackground).classNames.vertical?stringdefault'ct-vertical'Labels and grid lines of the vertical axis.
classNames.horizontal?stringdefault'ct-horizontal'Labels and grid lines of the horizontal axis.
classNames.start?stringdefault'ct-start'Labels at the start of their axis (left or top).
classNames.end?stringdefault'ct-end'Labels at the end of their axis (right or bottom).
showLine?booleandefaulttrueDraws the lines.
showPoint?booleandefaulttrueDraws a point at each value.
showArea?booleandefaultfalseFills the area between each line and
areaBase.areaBase?numberdefault0The value the areas close at, usually 0.
lineSmooth?boolean | LineInterpolationdefaulttrueHow a line runs between its points:
truesmooths it withInterpolation.monotoneCubic,falsedraws straight segments (Interpolation.none), or pass an interpolation such asInterpolation.cardinal(),Interpolation.step()or your own.showGridBackground?booleandefaultfalseFills the grid area with a background (class
ct-grid-background).fullWidth?booleandefaultfalseStretches the X axis so the last value lands on the right edge, without a last grid line. The last label may need chart padding to fit.
reverseData?booleandefaultfalseReverses the labels, the order of the series and each series' values.
series?Record<string, Omit<LineChartOptions<TXAxisOptions, TYAxisOptions>, 'series'>>Options per series, by series name: line options for one series.
width?string | numberThe chart's width: px as a number, or a CSS length such as
'100%'. Without it, the chart takes the width of its container.height?string | numberThe chart's height: px as a number, or a CSS length such as
'300px'. Without it, the chart takes the height of its container.low?numberThe lowest value the value axis shows, instead of the data's lowest. Values below it are drawn outside the drawing area.
high?numberThe highest value the value axis shows, instead of the data's highest. Values above it are drawn outside the drawing area.
referenceValue?numberA value the value axis always includes, such as 0, so it shows even when all values are above or below it. Bar charts use 0.
chartPadding?number | Partial<ChartPadding>default{ top: 15, right: 15, bottom: 5, left: 10 }Space in px between the chart's edges and its drawing area (labels sit in it): one number for every side, or an object with some sides.
axisX?TXAxisOptionsdefault{ offset: 30, position: 'end', labelOffset: { x: 0, y: 0 }, showLabel: true, showGrid: true }Options of the X axis.
axisY?TYAxisOptionsdefault{ offset: 40, position: 'start', labelOffset: { x: 0, y: 0 }, showLabel: true, showGrid: true, scaleMinSpace: 20, onlyInteger: false }Options of the Y axis.
plugins?(Plugin | [Plugin, any] | { readonly name: string; install: (chart: any, options?: any) => void })[]1.x plugin functions (they run with the compat plugin) and v2 plugins such as
compat.viewBox?ViewBoxA
viewBoxfor the SVG, so the drawing scales with its box instead of being drawn for its size. Text scales too: adjust it with responsive options.viewBox.widthnumberThe viewBox width, in SVG units.
viewBox.heightnumberThe viewBox height, in SVG units.
type 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'>LineChartOptions after the defaults are applied: the 1.x LineChart works with these.
Deprecated. The resolved options of the 1.x LineChart. Removed in 3.0.
type LineChartCreatedEvent = CreatedEvent<LineChartOptions>The payload of a line chart's 1.x created event.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface PointDrawEvent extends DrawEventThe 1.x draw event of a line chart's point, one per value. The point is a very short line element at x, y (CSS gives it a round cap).
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'point'Always
'point'.valueNormalizedSeriesPrimitiveValueThe point's normalized value:
{ x, y }numbers, or a number.xnumberThe point's x, in px.
ynumberThe point's y, in px.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
seriesIndexnumberThe index of the series in the data.
interface LineDrawEvent extends DrawEventThe 1.x draw event of a line, one per series. index is the series' index and meta the series' meta.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'line'Always
'line'.valuesNormalizedSeriesAll normalized values of the series.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
seriesIndexnumberThe index of the series in the data.
interface AreaDrawEvent extends DrawEventThe 1.x draw event of an area (with showArea), one per series and segment. index is the series' index and meta the series' meta.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'area'Always
'area'.valuesNormalizedSeriesAll normalized values of the series.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
seriesIndexnumberThe index of the series in the data.
type LineChartEventsTypes = BaseChartEventsTypes<LineChartCreatedEvent, AxesDrawEvent | PointDrawEvent | LineDrawEvent | AreaDrawEvent>The 1.x events of a LineChart and their payloads, by event name.
Deprecated. The 1.x events of a LineChart. On lineChart(), the handle's on() knows its events. Removed in 3.0.
Properties
type LabelDirection = 'implode' | 'neutral' | 'explode'Which way pie labels anchor: see labelDirection in PieChartOptions.
type AnchorPosition = 'start' | 'middle' | 'end'The text-anchor of a pie label: 'start', 'middle' or 'end'.
type RadialLabelPosition = 'inside' | 'center' | 'outside'Where pie labels go: see labelPosition in PieChartOptions.
interface DotA point in px, such as the center of a pie.
interface PieChartOptions extends Omit<Options, 'axisX' | 'axisY'>The options of a pie or donut chart (1.x PieChart, and pieChart).
Deprecated. For pieChart(), the options type is PieChartPresetOptions. Removed in 3.0.
Properties
classNames?{ … }The class names of the chart's elements. Change them to style the chart with your own CSS instead of Chartist's.
classNames.chartPie?stringdefault'ct-chart-pie'The chart's SVG element, for pies.
classNames.chartDonut?stringdefault'ct-chart-donut'The chart's SVG element, for donuts.
classNames.series?stringdefault'ct-series'The group of each series.
classNames.slicePie?stringdefault'ct-slice-pie'Each pie slice.
classNames.sliceDonut?stringdefault'ct-slice-donut'Each donut slice.
classNames.label?stringdefault'ct-label'Each axis label.
startAngle?numberdefault0Where the first slice starts, in degrees clockwise from the top.
total?numberThe value a full circle stands for. With a total above the sum of the values, the pie stays open, as for a gauge.
donut?booleandefaultfalseDraws a donut: rings instead of filled slices.
donutWidth?string | numberThe width of a donut's ring: px as a number, or a share of the radius as a string (
'30%'). Without it, the stylesheet sets the width (--ct-donut-width, 60px by default), and in the browser the ring is laid out for the width the stylesheet gives a slice. Without a DOM (renderToString()), it's laid out for 60 px.showLabel?booleandefaulttrueDraws a label for each slice.
labelOffset?numberdefault0Moves the labels away from the center (positive) or toward it (negative), in px.
labelPosition?RadialLabelPositiondefault'inside'Where labels go:
inside(halfway out on a pie, on the middle of a donut's ring, pluslabelOffset),outside(at the outer edge) orcenter(in the middle; move them withlabelOffset).labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each slice's label (or value) and index into the text to show. Return
nullorundefinedto leave a label out.labelDirection?LabelDirectiondefault'neutral'Which way labels anchor:
neutral,explode(away from the center, for labels outside the pie) orimplode(toward it).ignoreEmptyValues?booleandefaultfalseLeaves out the slices and labels of empty values.
preventOverlappingLabelOffset?numberdefault0Moves labels apart so they don't overlap, using this offset in px. The overlap is judged by the length of the drawn label text. 0 leaves them where they are.
width?string | numberThe chart's width: px as a number, or a CSS length such as
'100%'. Without it, the chart takes the width of its container.height?string | numberThe chart's height: px as a number, or a CSS length such as
'300px'. Without it, the chart takes the height of its container.low?numberThe lowest value the value axis shows, instead of the data's lowest. Values below it are drawn outside the drawing area.
high?numberThe highest value the value axis shows, instead of the data's highest. Values above it are drawn outside the drawing area.
referenceValue?numberA value the value axis always includes, such as 0, so it shows even when all values are above or below it. Bar charts use 0.
chartPadding?number | Partial<ChartPadding>default{ top: 5, right: 5, bottom: 5, left: 5 }Space in px between the chart's edges and its drawing area (labels sit in it): one number for every side, or an object with some sides.
plugins?(Plugin | [Plugin, any] | { readonly name: string; install: (chart: any, options?: any) => void })[]1.x plugin functions (they run with the compat plugin) and v2 plugins such as
compat.viewBox?ViewBoxA
viewBoxfor the SVG, so the drawing scales with its box instead of being drawn for its size. Text scales too: adjust it with responsive options.viewBox.widthnumberThe viewBox width, in SVG units.
viewBox.heightnumberThe viewBox height, in SVG units.
type PieChartOptionsWithDefaults = RequiredKeys<PieChartOptions, 'chartPadding' | 'startAngle' | 'showLabel' | 'labelOffset' | 'labelPosition' | 'labelInterpolationFnc' | 'labelDirection' | 'preventOverlappingLabelOffset', 'classNames'>PieChartOptions after the defaults are applied: the 1.x PieChart works with these.
Deprecated. The resolved options of the 1.x PieChart. Removed in 3.0.
type PieChartCreatedEvent = Omit<CreatedEvent<PieChartOptions>, 'axisX' | 'axisY'>The payload of a pie chart's 1.x created event: as for other charts, without axes.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface SliceDrawEvent extends Omit<DrawEvent, 'axisX' | 'axisY' | 'seriesIndex'>The 1.x draw event of a pie or donut slice, one per value. index is the slice's index and series its value as given in the data.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'slice'Always
'slice'.valueNormalizedSeriesPrimitiveValueThe slice's value.
totalDataSumnumberThe value of the full circle: the sum of all values, or the
totaloption.radiusnumberThe radius of the pie, in px.
startAnglenumberWhere the slice starts, in degrees clockwise from the top.
endAnglenumberWhere the slice ends, in degrees clockwise from the top.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
interface SliceLabelDrawEvent extends Omit<DrawEvent, 'axisX' | 'axisY' | 'seriesIndex'>The 1.x draw event of a pie slice's label. index is the slice's index; the label is a text element anchored at x, y.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type'label'Always
'label'.textstringThe label as shown, after
labelInterpolationFnc.xnumberThe x the label is anchored at, in px.
ynumberThe y the label is anchored at, in px.
metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
type PieChartEventsTypes = BaseChartEventsTypes<PieChartCreatedEvent, SliceDrawEvent | SliceLabelDrawEvent>The 1.x events of a PieChart and their payloads, by event name.
Deprecated. The 1.x events of a PieChart. On pieChart(), the handle's on() knows its events. Removed in 3.0.
Properties
interface BaseChartEventsTypes<TCreateEvent = CreatedEvent, TDrawEvents = DrawEvent>The 1.x events every chart class emits and their payloads, by event name.
Deprecated. The 1.x events of the chart classes. On the chart functions, the handle's on() knows its events. Removed in 3.0.
Properties
interface OptionsProvider<T = unknown>What optionsProvider returns: the current options, and a way to stop listening to media queries.
Deprecated. Part of the 1.x chart classes. Responsive options are an argument of the chart functions. Removed in 3.0.
Properties
removeMediaQueryListeners() => voidgetCurrentOptions() => T
interface ChartPaddingSpace in px between the chart's edges and its drawing area, per side.
type Plugin = (chart: any, options?: any) => voidA 1.x plugin: a function that gets the chart object (and its options) and registers listeners with chart.on('draw', …). It runs with the compat plugin from chartist/compat, whose fromLegacyPlugin() also turns it into a v2 plugin.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface Options<TXAxisOptions = AxisOptions, TYAxisOptions = TXAxisOptions>The options all 1.x charts share: size, value range, padding, axes, class names and plugins. LineChartOptions, BarChartOptions and PieChartOptions build on them.
Deprecated. The base options of the 1.x chart classes. Use the options type of the chart function. Removed in 3.0.
Properties
width?string | numberThe chart's width: px as a number, or a CSS length such as
'100%'. Without it, the chart takes the width of its container.height?string | numberThe chart's height: px as a number, or a CSS length such as
'300px'. Without it, the chart takes the height of its container.low?numberThe lowest value the value axis shows, instead of the data's lowest. Values below it are drawn outside the drawing area.
high?numberThe highest value the value axis shows, instead of the data's highest. Values above it are drawn outside the drawing area.
referenceValue?numberA value the value axis always includes, such as 0, so it shows even when all values are above or below it. Bar charts use 0.
chartPadding?number | Partial<ChartPadding>Space in px between the chart's edges and its drawing area (labels sit in it): one number for every side, or an object with some sides.
axisX?TXAxisOptionsOptions of the X axis.
axisY?TYAxisOptionsOptions of the Y axis.
classNames?Record<string, string>The class names of the chart's elements, to style a chart with your own classes instead of Chartist's.
interface AxisOptionsThe options of one axis of a line or bar chart.
Properties
type?AxisTypeThe axis type:
StepAxis(one step per label),AutoScaleAxis(a scale fitted to the values) orFixedScaleAxis(fixed ticks).low?numberThe lowest value this axis shows, instead of the data's lowest.
high?numberThe highest value this axis shows, instead of the data's highest.
referenceValue?numberA value this axis always includes, such as 0.
offset?numberRoom in px for the axis labels, between the drawing area and the chart's edge.
position?'end' | 'start'Where the labels go:
start(left or top) orend(right or bottom).labelOffset?{ x: number; y: number }Moves the labels by
xandypx from where they'd go.showLabel?booleanDraws the axis labels.
showGrid?booleanDraws the grid lines of the axis.
labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each label (and its index) into the text to show. Return
nullorundefinedto leave a label out.scaleMinSpace?numberThe minimum space in px between two grid lines of a scale: the scale takes fewer, larger steps to keep it.
onlyInteger?booleanOnly whole numbers on the scale.
stretch?booleanStep axis: spreads the ticks over the whole axis, so the last one lands on its end (line charts with
fullWidthset it).divisor?numberFixed scale axis without
ticks: the number of equal steps between its low and high, with a tick at each end.highLow?{ high: number; low: number }The value range of a scale as
{ high, low }, instead of the one computed from the data.
type OptionsWithDefaults = RequiredKeys<Options<RequiredKeys<AxisOptions, 'offset' | 'labelOffset' | 'labelInterpolationFnc'>, RequiredKeys<AxisOptions, 'offset' | 'labelOffset' | 'labelInterpolationFnc'>>, 'axisX' | 'axisY' | 'classNames'>Options after the defaults are applied: the axes and class names are set.
Deprecated. The resolved options of the 1.x chart classes. Removed in 3.0.
type ResponsiveOptions<T = Options> = [string, T][]The 1.x responsive options: [mediaQuery, options] pairs, applied over the chart's options while the media query matches.
Deprecated. For the chart functions, the type is PresetResponsiveOptions. Removed in 3.0.
interface CreatedEvent<TOptions = Options>The payload of the 1.x created event, emitted once a chart is drawn: its SVG, drawing area, axes and options.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface DrawEventThe fields every 1.x draw event shares. A draw listener gets one per element drawn; check type to tell them apart.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
typestringWhat was drawn:
'point','line','bar','grid', …metaanyThe
metaof the value (or of the series, for lines and areas).indexnumberThe index of the value in its series (of the series, for lines and areas).
seriesSeriesObject<SeriesPrimitiveValue> | FlatSeriesValue<FlatSeriesPrimitiveValue> | Series<SeriesPrimitiveValue>The series as given in the data: an array or a series object.
seriesIndexnumberThe index of the series in the data.
interface DataEventThe payload of the 1.x data event, emitted before a chart draws new data. Listeners may change data in place to transform it.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface OptionsChangedEvent<T = Options>The payload of the 1.x optionsChanged event, emitted when a responsive option starts or stops applying.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
previousOptionsTThe options before the change.
currentOptionsTThe options now in effect.
interface GridDrawEvent extends Omit<DrawEvent, 'chartRect' | 'axisX' | 'axisY' | 'meta' | 'series' | 'seriesIndex'>The 1.x draw event of a grid line, one per tick of each axis. x1, y1, x2, y2 are the line's ends in px.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
interface GridBackgroundDrawEventThe 1.x draw event of the grid background, the rect behind the drawing area (with showGridBackground).
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
interface LabelDrawEvent extends Omit<DrawEvent, 'chartRect' | 'axisX' | 'axisY' | 'meta' | 'series' | 'seriesIndex'>The 1.x draw event of an axis label, one per tick. The label is a foreignObject with a span, placed at x, y with the given size.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
Properties
type AxesDrawEvent = GridDrawEvent | GridBackgroundDrawEvent | LabelDrawEventThe 1.x draw events of the axes: grid lines, the grid background and labels.
Deprecated. Import it from chartist/compat, which turns on the 1.x events and plugins. Removed in 3.0.
type EventListener<T = any> = (data: T) => voidA listener of one event: gets the event's payload.
Deprecated. Use the chart handle's on() and off(). Removed in 3.0.
type AllEventsListener<T = any> = (event: string, data: T) => voidA listener of every event ('*'): gets the event's name and payload.
Deprecated. Use the chart handle's on() and off(). Removed in 3.0.