Skip to content

Quick start (Vanilla JS)

<div id="my-chart" style="height: 320px"></div>
<script type="module">
import { LineChart } from '@arshad-shah/swift-chart';
const chart = new LineChart('#my-chart', {
title: 'Revenue',
theme: 'midnight',
area: true,
});
chart.setData([
{ month: 'Jan', revenue: 420 },
{ month: 'Feb', revenue: 510 },
{ month: 'Mar', revenue: 480 },
{ month: 'Apr', revenue: 620 },
], { x: 'month', y: 'revenue' });
</script>

The result:

What just happened?

  1. new LineChart(selector, config) mounts a chart inside the matched element (or HTMLElement).
  2. chart.setData(data, mapping) accepts any object array; the mapping tells SwiftChart which fields are X and Y.
  3. The chart auto-resizes when its container changes size — no manual resize handling needed.

See Data mapping for the full set of accepted shapes.