Reference

API Reference

The global KatuCharts namespace creates charts and manages defaults; each chart instance exposes methods to update, export, inspect and dispose.

Global — KatuCharts

MethodSignature → returnsDescription
chartchart(containerOrId: string | HTMLElement, options) → ChartCreate a chart in the container (id or DOM node).
setOptionssetOptions(options) → voidSet global defaults inherited by later charts.
getOptionsgetOptions() → Partial<Options>Read the current global defaults.
useuse(module) → voidRegister a plugin/module with an install(KC) method.
dateFormatdateFormat(format: string, timestamp: number) → stringFormat a ms timestamp (tokens below).
numberFormatnumberFormat(value, decimals, decPoint?, thousandsSep?) → stringFormat a number; defaults '.' and ','.
colorcolor(input: string) → KatuChartsColorChainable color object: .brighten(n), .setOpacity(a), .toString().
palettesRecord<string, string[]>Map of palette name → hex colors.
getPalettegetPalette(name: string) → string[]Copy of a named palette (throws if unknown).
setThemesetTheme(name: string) → voidApply 'dark' | 'light' | 'nordic'.
SeriesRegistry.registerTyperegisterType(name, seriesClass) → voidRegister a custom series type.
SeriesRegistry.getTypegetType(name) → class | undefinedLook up a registered series class.

dateFormat tokens

TokenOutputExample
%YFour-digit year2026
%m / %dZero-padded month / day03 / 22
%H / %M / %SHours (24h) / minutes / seconds14 / 05 / 09
%B / %AFull month / weekday nameMarch / Sunday

Palettes & themes

20 built-in palettes: default, tableau10, d3classic, brewer, google, ocean, sunset, earth, forest, berry, corporate, minimal, nordic, darkMode, neon, pastel, soft, classic, tupi, monochrome. 18 themes (9 families, each in light and dark) set a background + palette, for example:

ThemeBackgroundPalette
dark#1a1f24monochrome
light#ffffffmonochrome
nordic#eceff4nordic
import KatuCharts from 'katucharts.js';
import 'katucharts.js/bio'; // modules register their chart types on import

KatuCharts.setTheme('dark');
KatuCharts.setOptions({ colors: KatuCharts.getPalette('sunset') });

const chart = KatuCharts.chart('container', {
  series: [{ type: 'volcano', data: [/* … */] }]
});

Instance — data & layout

MethodSignature → returnsDescription
addSeriesaddSeries(options, redraw=true) → BaseSeriesAppend a series; redraw=false to batch.
getget(id) → BaseSeries | Axis | undefinedFind a series or axis by id.
updateupdate(options, redraw=true) → voidMerge partial options (title, axes, series…).
addAxisaddAxis(options, isX=false, redraw=true) → AxisAdd an axis at runtime.
redrawredraw() → voidApply pending changes immediately.
animatedRedrawanimatedRedraw(duration=500) → voidRedraw with a transition.
reflowreflow() → voidRecalculate layout for the current container size.
setSizesetSize(width, height) → voidSet pixel dimensions and redraw.
setTitlesetTitle(titleOptions?, subtitleOptions?) → voidUpdate title/subtitle; null removes.

Instance — export, data & UI

MethodSignature → returnsDescription
getSVGgetSVG() → stringStandalone SVG markup.
getCSVgetCSV() → stringData as CSV.
getTablegetTable() → stringData as an HTML <table> string.
getDataRowsgetDataRows() → array[][]2-D array; first row is headers.
exportChartexportChart({ type, filename, width, scale })Download PNG/JPEG/SVG/PDF.
showLoadingshowLoading(text='Loading...') → voidShow the loading overlay.
hideLoadinghideLoading() → voidHide the loading overlay.
getSeriesInstancesgetSeriesInstances() → BaseSeries[]All series instances.
getXAxes / getYAxes→ Axis[]X / Y axis instances (multi-axis returns many).
destroydestroy() → voidRemove from DOM and unbind listeners — call before removing the container.
chart.showLoading('Fetching data…');
fetch('/api/data').then(r => r.json()).then(data => {
  chart.addSeries({ data });
  chart.hideLoading();
});

chart.exportChart({ type: 'image/svg+xml', filename: 'report', width: 1200 });

// on teardown
chart.destroy();

Plot renderer

chart.plotRenderer exposes low-level primitives for custom shapes and annotations in the plot area.

MethodSignatureDraws
rectrect(x, y, width, height, attrs?)Rectangle
circle / ellipsecircle(cx, cy, r, attrs?) / ellipse(cx, cy, rx, ry, attrs?)Circle / ellipse
pathpath(d, attrs?)SVG path from a d string
lineline(x1, y1, x2, y2, attrs?)Straight line
texttext(str, x, y, attrs?)Text label
groupgroup(attrs?)<g> group for nesting

Coordinate helpers: plotRenderer.plotArea → { x, y, width, height }; xAxis.toPixels(value) and yAxis.toPixels(value) convert data to pixels.

const [xAxis] = chart.getXAxes();
const [yAxis] = chart.getYAxes();
const plot = chart.plotRenderer.plotArea;

const yPx = yAxis.toPixels(6);
chart.plotRenderer.line(plot.x, yPx, plot.x + plot.width, yPx, {
  stroke: '#d62728', strokeWidth: 2, strokeDasharray: '6 3'
});
chart.plotRenderer.text('Target', plot.x + plot.width + 8, yPx + 4, {
  fill: '#d62728', fontSize: 12, fontWeight: 'bold'
});