dssoca docs
GitHub repository

Chart

Multi-series line, area, and bar chart.

A token-driven chart for comparing one or more series as a line, filled area, or grouped bars. Scales and paths are computed from the data; the SVG is rendered as plain markup with `--ss-*`-styled axes, gridlines, and a cycling categorical palette. Every datum is keyboard-focusable and reveals an accessible tooltip; the chart auto-generates a screen-reader summary (or pass `summary`). Empty input shows an em-dash placeholder.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Chart } from 'dssoca';

  const series = [
    { label: 'Requests', data: [{ x: 0, y: 120 }, { x: 1, y: 180 }, { x: 2, y: 150 }] },
    { label: 'Errors', data: [{ x: 0, y: 12 }, { x: 1, y: 22 }, { x: 2, y: 9 }] },
  ];
</script>

<Chart {series} />
<Chart {series} variant="bar" />
<Chart {series} variant="area" fluid />

Props

PropTypeDefaultDescription
seriesChartSeries[]Required. Each series has a `label`, `data: ChartPoint[]` ({ x: number | Date; y: number }), and an optional `color`.
variant'line' | 'area' | 'bar''line'Rendering style. `bar` draws grouped bars per x-category across series.
xType'linear' | 'time' | 'band'X scale kind. Defaults to `band` for bars, `time` for Date x-values, else `linear`.
xFormat(x: number | Date) => stringFormat an x value for axis ticks + tooltip.
yFormat(y: number) => stringFormat a y value for axis ticks + tooltip.
heightnumber240Intrinsic drawing height in px.
widthnumber480Intrinsic drawing width in px.
fluidbooleanfalseStretch to the container width via the viewBox (width:100%).
legendbooleantrueShow the series legend (labels + colour swatches).
tooltipbooleantrueReveal a tooltip on hover/focus of a datum. Each datum is keyboard-focusable.
summarystringScreen-reader summary + accessible name; auto-generated when absent.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.