ModaChart — Chart Library
Headless charting — drill-down, sync, candlestick, choropleth.
A headless chart library that draws 35 chart types identically in React, Vue, Svelte, and plain JS.
All logic — scales, interaction, events — lives in a pure TypeScript core; each framework adapter is just a thin reactive binding. Every renderer emits the same DOM contract, so output is identical.
Includes paid-tier features like zoom, navigator, drilldown, drawing annotations, and chart sync — plus a built-in world map and sparklines — in ~250KB.
Live demo
Runs on the real core loaded from CDN. Switch between every chart type — line, bar, pie, candlestick, sankey, sunburst, world map — and try legend, tooltip, zoom, brush, navigator, point select, context menu, drilldown, and drawing annotations (trendline/Fibonacci/range). The panel below shows code reproducing your settings in real time.
Packages by environment
| Environment | Package | Notes |
|---|---|---|
| React | @moda-chart/react | ChartView component + useChartCore hook (useSyncExternalStore) |
| Vue 3 | @moda-chart/vue | useChart + ChartView, shallowRef-based reactivity |
| Vue 2.7 | @moda-chart/vue2 | Same Composition API as Vue 3 |
| Svelte 5 | @moda-chart/svelte | readable store binding + ChartView |
| Vanilla JS / CDN | moda-chart.js | One <script>, no build — window.ModaChart |
| No framework | @moda-chart/core | Use headless ChartCore + mountChart directly |
Install via npm
npm i @moda-chart/react # Reactnpm i @moda-chart/vue # Vue 3npm i @moda-chart/vue2 # Vue 2.7npm i @moda-chart/svelte # Svelte 5npm i @moda-chart/core # Headless core onlyUse via CDN
https://chart.modaolive.com/moda-chart.jshttps://chart.modaolive.com/style.cssGet started in 3 steps
- 1
Install package
Install an adapter like npm i @moda-chart/react, or load the core with a single CDN <script>.
- 2
Type + data
Just pass type with series·categories. Per-type data fields like points·ohlc·tree·links are added when needed.
- 3
Render & control
Adapters need one <ChartView>. Vanilla's mountChart(el, options) wires up the DOM and all interactions.
// npm i @moda-chart/react
import { ChartView, useChartCore } from "@moda-chart/react";
import "@moda-chart/react/styles.css";
function App() {
const { chart, snapshot } = useChartCore({
type: "line",
series: [
{ name: "Sales", values: [12, 24, 16, 30] },
{ name: "Cost", values: [8, 14, 12, 20] },
],
categories: ["Jan", "Feb", "Mar", "Apr"],
legend: { position: "top" },
tooltip: { mode: "shared" },
zoom: true,
});
return <ChartView chart={chart} />;
}
// later changes via core methods like chart.setData / chart.setTypeUsage by feature
Chart types (35)
| Feature | How to enable | API |
|---|---|---|
| Cartesian | type: "line"|"step"|"spline"|"area"|"bar"|"stacked-bar"|"percent-stacked-bar"|"waterfall"|"histogram"|"range-bar"|"range-area"|"population-pyramid" | chart.setType(type) runtime switch |
| Circular · polar | "pie"|"donut"|"nightingale"|"radial-bar"|"radial-column"|"radar"|"radar-area" | categories = angle, values = radius |
| Distribution · finance | "scatter"|"bubble"|"heatmap"|"candlestick"|"ohlc"|"boxplot" | points {x,y,z} / ohlc / box / series matrix |
| Flow · hierarchy | "funnel"|"cone-funnel"|"pyramid"|"sankey"|"chord"|"sunburst"|"treemap"|"organization"|"wordcloud" | series.tree / links / chord.matrix |
| Gauge · map | "gauge"|"linear-gauge"|"pictogram"|"map" | gauge:{min,max,target} / map:{topology} + built-in WORLD_TOPOLOGY |
| Mixed series | series[].type set per series | line + bar combo chart |
| Horizontal | direction: "horizontal" (bar types) | value axis moves to x-axis |
Data
| Feature | How to enable | API |
|---|---|---|
| Category axis | categories: string[] / number[] / Date[] | string=band, number=linear, Date=time auto |
| Replace data | — | chart.setData(series, categories) |
| Update point | — | chart.updatePoint(...) — realtime updates (gauge, etc.) |
| Per-point style | series[].itemStyle: (ctx) => ({color?, name?}) | equivalent to AG Charts itemStyler |
| Error bars · trendlines | series[].errors / series[].trend | trend: { type: "linear"|"movingAverage" } |
| Grouped categories | categories: [[group, leaf], …] tuples | renders a second tick row |
Interactions
| Feature | How to enable | API |
|---|---|---|
| Legend | legend: true | { position } | click toggle + hover dimming / toggleLegend / hoverLegend |
| Legend checkboxes | legend: { checkboxes: true } | legendCheck event { id, checked } |
| Tooltip | tooltip: "point"|"shared"|{ mode, format, render } | shared includes crosshair; render for custom HTML |
| Zoom · pan | zoom: true | { wheel, pan, axes, select } | setZoomWindow / resetZoom — x/y/xy axis selection |
| Brush selection | brush: true — drag to select range | selectionChange event / setSelection |
| Navigator · scrollbar | navigator: true | scrollbar: true | control window via minimap or thin zoom strip |
| Drill-down | drilldown: { "label": childLevel } | drillDown/drillUp/drillUpAll + ‹Back button |
| Point select | allowPointSelect: true | selectPoint / clearSelected, .mc-selected |
| Context menu | contextMenu: true | { items } | built-in zoom reset/SVG·PNG export + custom items menuAction |
| Chart sync | sync: "groupKey" | same-key charts share hover·zoom |
| Touch pinch zoom | automatic (when zoom on) | focal-anchor zoom from finger spacing |
| OS theme sync | automatic | tracks prefers-color-scheme — syncs chart vars when OS goes dark |
Annotations · export · a11y
| Feature | How to enable | API |
|---|---|---|
| Draw annotations | drawing: true + chart.setDrawMode(tool) | line/hline/vline/rect/channel/fibonacci/measure + getDrawings |
| Save SVG·PNG | built into contextMenu or call directly | downloadSVG / downloadPNG export |
| Sparkline | — | mountSparkline — axis-free mini chart |
| State save/restore | — | getState / setState — round-trips zoom·hidden·annotations |
| Keyboard nav | auto — moves point focus | includes a11y attrs like aria-pressed |
| Theme | --chart-* CSS vars + palette cycling | customize via .mc-* class DOM contract |
| Print events | automatic | beforePrint / afterPrint events |
Recipes by use case
Drill-down
Click a point to descend into child data — ‹Back auto-provided
new ChartCore({
type: "bar",
series: [{ name: "Monthly", values: [12, 24, 16] }],
categories: ["Jan", "Feb", "Mar"],
drilldown: {
"Jan": {
series: [{ name: "Jan weekly", values: [3, 4, 2, 3] }],
categories: ["Wk 1", "Wk 2", "Wk 3", "Wk 4"],
title: "Jan weekly sales",
},
},
});
chart.drillUp(); // back one levelAnnotations
Trendlines·Fibonacci retracement·region measurement — AG Charts premium-level features
chart.setDrawMode("fibonacci"); // drag → 0~100% retracement levels
chart.setDrawMode("channel"); // parallel channel + shaded band
chart.setDrawMode("measure"); // auto Δx/Δy labels
chart.getDrawings(); // DrawingInput[] (data coords)
chart.clearDrawings();
chart.setDrawMode(null); // release (Esc works too)Real-time data
setData is idempotent — same-ref calls ignored, reactive-loop safe
setInterval(() => {
series[0].values.push(rand()); series[0].values.shift();
chart.setData(series, categories); // re-renders when the ref is a new array
}, 1000);
// to change a single point, like a gauge
chart.updatePoint(seriesId, 0, nextValue);Chart sync
Charts with the same group key share hover·zoom — for multi-chart dashboards
mountChart(elA, { type: "line", series, categories, sync: "dash" });
mountChart(elB, { type: "bar", series, categories, sync: "dash" });
// zoom/hover on one propagates to the other on the same domain
// (propagated changes are not re-propagated — no loop)Candlestick (stock)
Up/down candles from ohlc — colors via --chart-up/down-color
new ChartCore({
type: "candlestick",
categories: ["10/1", "10/2", "10/3"],
series: [{
name: "Price",
ohlc: [
[100, 108, 97, 105], // [open, high, low, close]
[105, 110, 101, 103],
[103, 112, 102, 111],
],
}],
});World map (choropleth)
Built-in Natural Earth 110m topo — join by code, axis-free region chart
import { WORLD_TOPOLOGY } from "@moda-chart/core"; // on CDN: window.ModaChart.WORLD_TOPOLOGY
new ChartCore({
type: "map",
series: [{
name: "Users by country",
mapData: { KOR: 92, JPN: 64, USA: 88, DEU: 40 },
}],
map: { topology: WORLD_TOPOLOGY, projection: "mercator" },
});
// unjoined regions get .mc-map-no-data; gradient legend bottom-rightSource & docs
Guides (full chart-type table, interactions, theme vars, migration mapping) live in the public release repo.
park-taejoon/moda-chart-releasesHow to use
Headless charting — drill-down, sync, candlestick, choropleth.