function lineChart(target: string | Element, data: LineChartData, options?: LineChartPresetOptions, responsiveOptions?: PresetResponsiveOptions<LineChartPresetOptions>): PresetHandle<LineChartPresetOptions>Creates a line chart with the 1.x options and output, rendered synchronously. Plugins must be v2 plugins; convert 1.x plugins with fromLegacyPlugin from chartist/compat.
Parameters
targetstring | ElementdataLineChartDataoptions?LineChartPresetOptions={}responsiveOptions?PresetResponsiveOptions<LineChartPresetOptions>
function barChart(target: string | Element, data: BarChartData, options?: BarChartPresetOptions, responsiveOptions?: PresetResponsiveOptions<BarChartPresetOptions>): PresetHandle<BarChartPresetOptions>Creates a bar chart with the 1.x options and output, rendered synchronously. Plugins must be v2 plugins; convert 1.x plugins with fromLegacyPlugin from chartist/compat.
Parameters
targetstring | ElementdataBarChartDataoptions?BarChartPresetOptions={}responsiveOptions?PresetResponsiveOptions<BarChartPresetOptions>
function pieChart(target: string | Element, data: PieChartData, options?: PieChartPresetOptions, responsiveOptions?: PresetResponsiveOptions<PieChartPresetOptions>): PresetHandle<PieChartPresetOptions>Creates a pie or donut chart with the 1.x options and output, rendered synchronously. Plugins must be v2 plugins; convert 1.x plugins with fromLegacyPlugin from chartist/compat.
Parameters
targetstring | ElementdataPieChartDataoptions?PieChartPresetOptions={}responsiveOptions?PresetResponsiveOptions<PieChartPresetOptions>
type LineChartData = Data<(Series | SeriesObject)[]>The data of a line chart: series of values, and labels for the X axis.
type LineChartPresetOptions = Omit<LineChartOptions, 'axisX' | 'axisY' | 'plugins' | 'series'> & { … }Options of lineChart: the 1.x LineChart options; axis types may also be v2 axis factories.
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.
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.
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.
readonly plugins?readonly PluginEntry[]v2 plugins; convert 1.x plugins with
fromLegacyPlugin.readonly on?PhaseListenersPhase listeners by phase name (or
'*'for all phases), asonin the config ofchart(). They're registered before the first render, so they see it too.on.*?AllPhasesListenerListens to every phase, with the phase name as first argument.
readonly series?Readonly<Record<string, LineSeriesOptions>>Options per series name: only these five apply per series.
readonly axisX?PresetAxisOptions & Omit<NonNullable<LineChartOptions['axisX']>, 'type'>Options of the X axis; its
typemay also be a v2 axis factory.axisX.low?numberThe lowest value this axis shows, instead of the data's lowest.
axisX.high?numberThe highest value this axis shows, instead of the data's highest.
axisX.referenceValue?numberA value this axis always includes, such as 0.
axisX.offset?numberdefault30Room in px for the axis labels, between the drawing area and the chart's edge.
axisX.position?'end' | 'start'default'end'Where the labels go:
start(left or top) orend(right or bottom).axisX.labelOffset?{ x: number; y: number }default{ x: 0, y: 0 }Moves the labels by
xandypx from where they'd go.axisX.showLabel?booleandefaulttrueDraws the axis labels.
axisX.showGrid?booleandefaulttrueDraws the grid lines of the axis.
axisX.labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each label (and its index) into the text to show. Return
nullorundefinedto leave a label out.axisX.scaleMinSpace?numberThe minimum space in px between two grid lines of a scale: the scale takes fewer, larger steps to keep it.
axisX.onlyInteger?booleanOnly whole numbers on the scale.
axisX.ticks?Label[]The ticks: the labels of a step axis, or the values of a fixed scale axis.
axisX.stretch?booleanStep axis: spreads the ticks over the whole axis, so the last one lands on its end (line charts with
fullWidthset it).axisX.divisor?numberFixed scale axis without
ticks: the number of equal steps between its low and high, with a tick at each end.axisX.highLow?{ high: number; low: number }The value range of a scale as
{ high, low }, instead of the one computed from the data.axisX.type?AxisSetup['type']A v2 axis factory or a 1.x axis class.
readonly axisY?PresetAxisOptions & Omit<NonNullable<LineChartOptions['axisY']>, 'type'>Options of the Y axis; its
typemay also be a v2 axis factory.axisY.low?numberThe lowest value this axis shows, instead of the data's lowest.
axisY.high?numberThe highest value this axis shows, instead of the data's highest.
axisY.referenceValue?numberA value this axis always includes, such as 0.
axisY.offset?numberdefault40Room in px for the axis labels, between the drawing area and the chart's edge.
axisY.position?'end' | 'start'default'start'Where the labels go:
start(left or top) orend(right or bottom).axisY.labelOffset?{ x: number; y: number }default{ x: 0, y: 0 }Moves the labels by
xandypx from where they'd go.axisY.showLabel?booleandefaulttrueDraws the axis labels.
axisY.showGrid?booleandefaulttrueDraws the grid lines of the axis.
axisY.labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each label (and its index) into the text to show. Return
nullorundefinedto leave a label out.axisY.scaleMinSpace?numberdefault20The minimum space in px between two grid lines of a scale: the scale takes fewer, larger steps to keep it.
axisY.onlyInteger?booleandefaultfalseOnly whole numbers on the scale.
axisY.ticks?Label[]The ticks: the labels of a step axis, or the values of a fixed scale axis.
axisY.stretch?booleanStep axis: spreads the ticks over the whole axis, so the last one lands on its end (line charts with
fullWidthset it).axisY.divisor?numberFixed scale axis without
ticks: the number of equal steps between its low and high, with a tick at each end.axisY.highLow?{ high: number; low: number }The value range of a scale as
{ high, low }, instead of the one computed from the data.axisY.type?AxisSetup['type']A v2 axis factory or a 1.x axis class.
readonly labels?LabelModeHTML (1.x) or SVG text labels; default: the renderer's mode.
type BarChartData = DataThe data of a bar chart: series of values, and labels for the bar groups.
type BarChartPresetOptions = Omit<BarChartOptions, 'axisX' | 'axisY' | 'plugins' | 'stackMode'> & { … }Options of barChart: the 1.x BarChart options; axis types may also be v2 axis factories.
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.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.
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.
readonly plugins?readonly PluginEntry[]v2 plugins; convert 1.x plugins with
fromLegacyPlugin.readonly on?PhaseListenersPhase listeners by phase name (or
'*'for all phases), asonin the config ofchart(). They're registered before the first render, so they see it too.on.*?AllPhasesListenerListens to every phase, with the phase name as first argument.
readonly stackMode?'accumulate' | 'accumulate-relative' | 'overlap' | booleandefault'accumulate'How stacked bars stack:
accumulate(default),accumulate-relative(positives up, negatives down), oroverlap(alsotrue): every bar from zero.readonly axisX?PresetAxisOptions & Omit<NonNullable<BarChartOptions['axisX']>, 'type'>Options of the X axis; its
typemay also be a v2 axis factory.axisX.low?numberThe lowest value this axis shows, instead of the data's lowest.
axisX.high?numberThe highest value this axis shows, instead of the data's highest.
axisX.referenceValue?numberA value this axis always includes, such as 0.
axisX.offset?numberdefault30Room in px for the axis labels, between the drawing area and the chart's edge.
axisX.position?'end' | 'start'default'end'Where the labels go:
start(left or top) orend(right or bottom).axisX.labelOffset?{ x: number; y: number }default{ x: 0, y: 0 }Moves the labels by
xandypx from where they'd go.axisX.showLabel?booleandefaulttrueDraws the axis labels.
axisX.showGrid?booleandefaulttrueDraws the grid lines of the axis.
axisX.labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each label (and its index) into the text to show. Return
nullorundefinedto leave a label out.axisX.scaleMinSpace?numberdefault30The minimum space in px between two grid lines of a scale: the scale takes fewer, larger steps to keep it.
axisX.onlyInteger?booleandefaultfalseOnly whole numbers on the scale.
axisX.ticks?Label[]The ticks: the labels of a step axis, or the values of a fixed scale axis.
axisX.stretch?booleanStep axis: spreads the ticks over the whole axis, so the last one lands on its end (line charts with
fullWidthset it).axisX.divisor?numberFixed scale axis without
ticks: the number of equal steps between its low and high, with a tick at each end.axisX.highLow?{ high: number; low: number }The value range of a scale as
{ high, low }, instead of the one computed from the data.axisX.type?AxisSetup['type']A v2 axis factory or a 1.x axis class.
readonly axisY?PresetAxisOptions & Omit<NonNullable<BarChartOptions['axisY']>, 'type'>Options of the Y axis; its
typemay also be a v2 axis factory.axisY.low?numberThe lowest value this axis shows, instead of the data's lowest.
axisY.high?numberThe highest value this axis shows, instead of the data's highest.
axisY.referenceValue?numberA value this axis always includes, such as 0.
axisY.offset?numberdefault40Room in px for the axis labels, between the drawing area and the chart's edge.
axisY.position?'end' | 'start'default'start'Where the labels go:
start(left or top) orend(right or bottom).axisY.labelOffset?{ x: number; y: number }default{ x: 0, y: 0 }Moves the labels by
xandypx from where they'd go.axisY.showLabel?booleandefaulttrueDraws the axis labels.
axisY.showGrid?booleandefaulttrueDraws the grid lines of the axis.
axisY.labelInterpolationFnc?(value: Label, index: number) => Label | null | undefinedTurns each label (and its index) into the text to show. Return
nullorundefinedto leave a label out.axisY.scaleMinSpace?numberdefault20The minimum space in px between two grid lines of a scale: the scale takes fewer, larger steps to keep it.
axisY.onlyInteger?booleandefaultfalseOnly whole numbers on the scale.
axisY.ticks?Label[]The ticks: the labels of a step axis, or the values of a fixed scale axis.
axisY.stretch?booleanStep axis: spreads the ticks over the whole axis, so the last one lands on its end (line charts with
fullWidthset it).axisY.divisor?numberFixed scale axis without
ticks: the number of equal steps between its low and high, with a tick at each end.axisY.highLow?{ high: number; low: number }The value range of a scale as
{ high, low }, instead of the one computed from the data.axisY.type?AxisSetup['type']A v2 axis factory or a 1.x axis class.
readonly labels?LabelModeHTML (1.x) or SVG text labels; default: the renderer's mode.
type PieChartData = Data<FlatSeries>The data of a pie chart: one value per slice, and labels for the slices.
type PieChartPresetOptions = Omit<PieChartOptions, 'plugins'> & { … }Options of pieChart: the 1.x PieChart options, with v2 plugins and phase listeners.
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.
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.
readonly plugins?readonly PluginEntry[]v2 plugins; convert 1.x plugins with
fromLegacyPlugin.readonly on?PhaseListenersPhase listeners by phase name (or
'*'for all phases), asonin the config ofchart(). They're registered before the first render, so they see it too.on.*?AllPhasesListenerListens to every phase, with the phase name as first argument.
function barChartConfig(data: BarChartData, options?: BarChartPresetOptions): ChartConfigBuilds the chart config that barChart() renders for the data and options, without a container: the bar layer with its axes, grid and labels, horizontal or stacked as the options say. Pass it to toScene() to render the preset chart with another renderer. Responsive options and the inline size style of the root svg are left out; both need a container.
Parameters
dataBarChartDataoptions?BarChartPresetOptions={}
function lineChartConfig(data: LineChartData, options?: LineChartPresetOptions): ChartConfigBuilds the chart config that lineChart() renders for the data and options, without a container: the line layer with its axes, grid and labels. Pass it to toScene() to render the preset chart with another renderer. Responsive options and the inline size style of the root svg are left out; both need a container.
Parameters
dataLineChartDataoptions?LineChartPresetOptions={}
Example
import { lineChartConfig, renderToString, toScene } from 'chartist';
const config = lineChartConfig(
{ labels: ['Mon', 'Tue', 'Wed'], series: [[5, 2, 4]] },
{ showArea: true }
);
export const svg = renderToString(
toScene(config, { width: 600, height: 300 })
);function pieChartConfig(data: PieChartData, options?: PieChartPresetOptions): ChartConfigBuilds the chart config that pieChart() renders for the data and options, without a container: the pie layer with its labels. Pass it to toScene() to render the preset chart with another renderer. Responsive options and the inline size style of the root svg are left out; both need a container.
Parameters
dataPieChartDataoptions?PieChartPresetOptions={}
type BarPresetState = PresetState<BarChartData, BarChartPresetOptions, 'bar'>What the bar preset passes to plugins as ResolvedConfig.preset.
Properties
readonly kindTKindWhich preset:
line,barorpie.readonly optionsTOptionsThe current options: the given ones over the defaults, with the matching responsive options applied.
readonly dataTDataThe current data.
update(data?: TData, options?: TOptions, override?: boolean) => voidChanges the data, the options or both and redraws, as 1.x
update(): the options extend the current ones, or withoverride, the defaults.detach() => voidStops the chart's responsive updates, as 1.x
detach().
type LinePresetState = PresetState<LineChartData, LineChartPresetOptions, 'line'>What the line preset passes to plugins as ResolvedConfig.preset.
Properties
readonly kindTKindWhich preset:
line,barorpie.readonly optionsTOptionsThe current options: the given ones over the defaults, with the matching responsive options applied.
readonly dataTDataThe current data.
update(data?: TData, options?: TOptions, override?: boolean) => voidChanges the data, the options or both and redraws, as 1.x
update(): the options extend the current ones, or withoverride, the defaults.detach() => voidStops the chart's responsive updates, as 1.x
detach().
type PiePresetState = PresetState<PieChartData, PieChartPresetOptions, 'pie'>What the pie preset passes to plugins as ResolvedConfig.preset.
Properties
readonly kindTKindWhich preset:
line,barorpie.readonly optionsTOptionsThe current options: the given ones over the defaults, with the matching responsive options applied.
readonly dataTDataThe current data.
update(data?: TData, options?: TOptions, override?: boolean) => voidChanges the data, the options or both and redraws, as 1.x
update(): the options extend the current ones, or withoverride, the defaults.detach() => voidStops the chart's responsive updates, as 1.x
detach().
interface PresetState<TData = unknown, TOptions = unknown, TKind extends string = string>What a preset passes to plugins as ResolvedConfig.preset: its kind, the current 1.x options and 1.x-style updates.
Properties
readonly kindTKindWhich preset:
line,barorpie.readonly optionsTOptionsThe current options: the given ones over the defaults, with the matching responsive options applied.
readonly dataTDataThe current data.
update(data?: TData, options?: TOptions, override?: boolean) => voidChanges the data, the options or both and redraws, as 1.x
update(): the options extend the current ones, or withoverride, the defaults.detach() => voidStops the chart's responsive updates, as 1.x
detach().
interface PresetHandle<TOptions> extends ChartHandleThe handle lineChart, barChart and pieChart return: a ChartHandle that also changes the chart's options. update({ data }) changes the preset's data too, so responsive changes redraw with it.
Properties
readonly container?ElementThe element the chart renders into (undefined in
toScene).update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>) => thisShallow-merges the changes into the config and renders again. Plugins and listeners stay;
pluginsandoncan't change.detach() => thisStops reacting to container size changes (and media queries in presets). The output and the listeners stay.
destroy() => voidDetaches, removes the output and clears all listeners.
emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]) => voidEmits a custom event (declared in
ChartEvents), e.g. from a plugin. Phase names are reserved: emitting one throws.on<K extends keyof PhaseEvents>(name: K, listener: PhaseListener<K>) => thisListens to a phase event, which fires on every render. Listeners of
resolvetoscenemay return a new payload to change what's drawn;composelisteners may returnnullto drop a node.off<K extends keyof PhaseEvents>(name: K, listener?: PhaseListener<K>) => thisRemoves a phase listener, whoever added it. Without a listener, removes the listeners of the phase added through
onand the config'son; plugins keep theirs.setOptions(options: Omit<TOptions, 'plugins' | 'on'>, how?: { readonly replace?: boolean }) => thisChanges the options and redraws: they extend the current options, or with
{ replace: true }, the defaults, dropping the options given before. Matching responsive options still apply on top.pluginsandoncan't change. Coming from 1.x,setOptions(options)isupdate(undefined, options, true)andsetOptions(options, { replace: true })isupdate(undefined, options).
Example
import { lineChart } from 'chartist';
const chart = lineChart('#chart', { series: [[1, 3, 2, 5]] });
// Areas from now on; the other options stay.
chart.setOptions({ showArea: true });type PresetAxisOptions = Omit<AxisOptions, 'type'> & { … }1.x axis options whose type may also be a v2 axis factory.
Properties
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.readonly type?AxisSetup['type']A v2 axis factory or a 1.x axis class.
type PresetResponsiveOptions<T> = readonly ResponsiveEntry<T>[]Responsive options of presets: the 1.x media query pairs, plus container conditions (container()). Matching entries extend the options in order.