Kumo Charts

Modules

The core holds what every chart needs: the bars and the basic series types, scales, panes, crosshair, legend, zoom and pan, timeframes, and saving and restoring. Every other feature is a module, loaded when you use it; what you do not load stays out of your bundle.

Loading modules

Put the modules in modules when you create the chart:

import { createChart } from '@kumo-charts/core';
import { indicators, allIndicators } from '@kumo-charts/core/indicators';
import { drawings, allDrawings } from '@kumo-charts/core/drawings';
import { alerts } from '@kumo-charts/core/alerts';

const chart = createChart(container, {
  modules: [indicators(allIndicators), drawings(allDrawings), alerts()]
});

chart.indicators.add({ type: 'RSI' });
chart.drawings.startTool('fib-retracement');
chart.alerts.add({ id: 'btc-100k', trigger: 'cross-up', value: 100000 });

A module adds its API to the chart (such as chart.indicators), along with its options and events. Modules are given when the chart is created; they cannot be added or removed later.

The modules

Module Entry Loading Adds to the chart
Indicators @kumo-charts/core/indicators indicators(allIndicators) chart.indicators
Drawings @kumo-charts/core/drawings drawings(allDrawings) chart.drawings
Chart types @kumo-charts/core/chart-types chartTypes(allChartTypes) the main series can show these types
Alerts @kumo-charts/core/alerts alerts() chart.alerts
Orders @kumo-charts/core/trading orders() chart.orders
Markers @kumo-charts/core/trading markers() chart.markers
Replay @kumo-charts/core/replay replay() chart.replay
Volume profiles @kumo-charts/core/volume-profile volumeProfiles() chart.volumeProfiles
Watermark @kumo-charts/core/watermark watermark() the watermark option
Everything @kumo-charts/core/all allModules() all of the above

The entry of volume profiles has a drawing type too, the fixed range volume profile fixedRangeVolumeProfile(), given to the drawings module; see Volume profile.

Whole, or the parts you pick

Indicators, drawings and chart types hold many types each. Load them all, or give only those you use:

import { indicators, MA, MACD, RSI } from '@kumo-charts/core/indicators';
import { drawings, trendLine, horizontalLine, fibRetracement } from '@kumo-charts/core/drawings';
import { chartTypes, heikinAshi, renko } from '@kumo-charts/core/chart-types';

const chart = createChart(container, {
  modules: [
    indicators([MA, MACD, RSI]),
    drawings([trendLine, horizontalLine, fibRetracement]),
    chartTypes([heikinAshi, renko])
  ]
});

Only those end up in your bundle. What each module holds: Indicators, Drawings, Chart types.

Sizes

Minified and gzipped, the core included:

Loaded Size
The core alone ~44 kB
The core + MA, MACD, RSI ~54 kB
The core + every indicator ~63 kB
The core + trend and horizontal lines ~57 kB
The core + every drawing ~69 kB
The core + every chart type ~49 kB
The core + alerts ~49 kB
The core + orders and markers ~47 kB
The core + replay ~45 kB
The core + volume profiles ~47 kB
Everything ~103 kB

The modules share the core's code, so together they weigh less than the differences above added up.

Adding types later

Modules are given at creation, but the types in them can come and go at any time, such as an indicator of your own:

chart.indicators.register(myIndicator);
chart.indicators.add({ type: myIndicator.type });

chart.indicators.types(); // the indicator types the chart has now
chart.indicators.unregister(myIndicator.type);

Drawings (chart.drawings), bar transforms (chart.transforms) and series types (chart.series) have the same register(), unregister() and types(). A type still in use on the chart cannot be removed: the error says what uses it.

To bring your own types along when the chart is created, or to add a whole feature of your own, see Custom modules.

Loading everything

When size does not matter, or to try things out, load everything:

import { createChart } from '@kumo-charts/core';
import { allModules } from '@kumo-charts/core/all';

const chart = createChart(container, { modules: allModules() });

kumo-charts.iife.js, the script for pages without a bundler, holds everything too; see Getting started.

In TypeScript

The chart's type follows its modules: chart.indicators is typed only on a chart with the indicators module, and using it on one without fails to compile.

To name the type of such a chart elsewhere, give Chart the types of its modules:

import { createChart, type Chart } from '@kumo-charts/core';
import { indicators, allIndicators } from '@kumo-charts/core/indicators';
import { drawings, allDrawings } from '@kumo-charts/core/drawings';

const modules = [indicators(allIndicators), drawings(allDrawings)] as const;

export type MyChart = Chart<typeof modules>;

export function mountChart(container: HTMLElement): MyChart {
  return createChart(container, { modules });
}

A chart with every module is a Chart<AllModules> (AllModules comes from @kumo-charts/core/all). Chart alone is a chart without modules, which every chart is.

Saved states and modules

chart.saveState() keeps a part for each module, such as the indicators and the drawings. Restoring needs the same modules: a state with drawings on a chart without the drawings module makes loadState() throw, and the chart stays as it was. See Save and restore.

↑↓ to select · Enter to open · Esc to close