Docs › Reference
API
createChart, chart instance methods and other exports.
import { createChart } from '@82chart/core';
const chart = createChart(target, options); // target: an element or a selectorInstance methods
| Method | What it does |
|---|---|
update(data) | Replace the data and redraw |
setOptions(partial) | Change some options (a new type or data resets the zoom) |
getOptions() | A copy of the current options |
setTheme(theme) | 'light' | 'dark' | 'auto' |
resize() | Measure and redraw (usually automatic) |
toggleSeries(index, visible?) | Show or hide a series (a slice for pies) |
resetZoom() | Undo the zoom |
setLoading(bool) | Loading placeholder |
setError(message | null, retry?) | Error message with a retry button |
showTooltip(index | null, seriesIndex?) | Show or hide the tooltip from code |
toSVG() | An SVG string |
toPNG(scale = 2) | Promise<Blob> |
toCSV() | A CSV string |
download('png' | 'svg' | 'csv', filename?) | Save a file |
on(event, fn) / off(event, fn) | Events |
destroy() | Remove the chart and its listeners |
root / svg | The outer element / the current SVG element |
Other exports
| Name | What it is |
|---|---|
renderToSVG(options, { width, height, theme, header, idPrefix }) | An SVG string without a DOM (SSR) |
defineChartElement(tag = 'chart-82') | Register the web component |
korean(v) / koreanLong(v) | '1.2억' / '1억 2,345만 6,789' |
compact(v) / comma(v) | '123.5M' / '123,456,789' |
formatTick(v, style) / formatValue(v, style) / formatDate(d, pattern, locale) | Text by the same rules as the axis and tooltip |
niceStep / linearTicks | Round tick steps |
PALETTE_LIGHT / PALETTE_DARK | The eight default colors |
LIGHT_THEME / DARK_THEME | Default theme colors |
LOCALES / registerLocale(lang, strings) | Interface strings / add a language |
VERSION | The version string, e.g. '0.1.0' |
All types (ChartOptions, ChartData, Series, ChartPoint, Chart …) are exported too.