Examples

A responsive SVG line chart for visualizing trends over continuous data. Supports multiple series, five curve interpolations, gradient fill, categorical x-axis labels, filled area with custom gradient, and an imperative highlight API for external orchestration.

Single Series

Multi-Series with Legend

Product A
Product B
Product C

Linear Curve (no smoothing)

Step Curve

xAxisCategories — month labels

Pass string category labels via xAxisCategories. The labels are mapped by index to the numeric x values used in the data (x=1 → index 0, x=2 → index 1, …).

xAxisCategories — weekday labels

showArea — default gradient (series colour)

Set showArea to fill the area under the line with a vertical gradient derived from the series colour.

showArea + areaGradient — custom colours

Provide areaGradient with from and to colour stops to use a fully custom vertical gradient fill.

showArea + xAxisCategories

Narration sync — createNarrationHighlighter

The orchestrator the hook above exists for. processText receives the transcript as it grows and highlights the month being named — Feb, then Jun, then Nov — clearing itself after a pause.

nothing highlighted

Highlight Hook — onChartReady + imperative API

Use onChartReady to receive a ChartHighlightAPI with a highlight(index) method. The buttons below drive the chart externally, simulating a voice-narration or step-through orchestrator.

highlightedIndex — declarative prop

Use the highlightedIndex prop to highlight a point declaratively (no callback needed). The chart dims all other points and draws the crosshair at the highlighted index.

Jun: 61

Legacy gradientFill (backward-compatible)

Shared Tooltip + Interactive Legend (3 series × 8 points)

Hovering any point shows one shared tooltip listing every series at that x. Legend items are click/keyboard toggles for series visibility.

Dense Values (40 points, no dots)

A single series with 40 points and value labels shown at every point, with point dots disabled to keep the dense line readable.

Cross-Series Alignment — mismatched x coverage

"This week" has no sample at x=3; "Last week" has none at x=6. Series are joined by their x value, not by array position, so hovering anywhere reports each series' own value at that x (or omits it entirely) — never a value borrowed from the other series' array index. See docs/CHART_INPUT_POLICY.md for the full input-shape table.

This week
Last week

Sparse Series — Gap Points

A non-finite y (NaN) marks a gap: the line breaks around x=4 and x=8 below and resumes at the next finite point, instead of one poisoned path or a misleading value drawn at 0.

minHeight / maxHeight bounds

minHeight/maxHeight clamp the chart's rendered height regardless of the computed aspect-ratio height — this one is forced to exactly 260px despite a wide aspect ratio that would otherwise render much shorter.

Legend aggregates (aggregate + aggregateFormat)

Product A 213 units
Product B 18.5

Documentation

A responsive SVG line chart for visualizing trends over continuous data. Supports multiple series, five curve interpolations (linear, monotone, spline, step, natural), gradient fill under the line, a showArea mode with per-gradient custom colours, an xAxisCategories prop that replaces numeric x indices with string labels, an imperative highlight API exposed via onchartready for external orchestration (e.g. voice narration sync), a declarative highlightedIndex prop, an overlay hover tracker that finds the nearest point even when dots are hidden, crosshair vertical line, data point labels, legend, and custom tooltips. Zero external dependencies — built from pure SVG with CSS custom property theming.

Usage

<script>
  import { LineChart } from '@juspay/svelte-ui-components';

  const series = [
    {
      name: 'Revenue',
      data: [
        { x: 1, y: 30 },
        { x: 2, y: 45 },
        { x: 3, y: 38 },
        { x: 4, y: 52 },
        { x: 5, y: 48 }
      ]
    }
  ];
</script>

<LineChart {series} />

Multi-Series with Legend

<script>
  const series = [
    {
      name: 'Product A',
      data: [
        /* ... */
      ]
    },
    {
      name: 'Product B',
      data: [
        /* ... */
      ]
    }
  ];
</script>

<LineChart {series} showLegend />

Curve Types

<LineChart {series} curve="monotone" />
<!-- default, smooth monotone cubic -->
<LineChart {series} curve="linear" />
<!-- straight line segments -->
<LineChart {series} curve="spline" />
<!-- alias for monotone -->
<LineChart {series} curve="step" />
<!-- horizontal-then-vertical steps -->
<LineChart {series} curve="natural" />
<!-- smooth natural cubic spline -->

xAxisCategories — String Category Labels

Replace the raw numeric x values on the X axis with human-readable category names. The array is parallel to the x indices (index 0 maps to x=1, index 1 maps to x=2, and so on).

<script>
  const monthSeries = [
    {
      name: 'Revenue',
      data: [
        { x: 1, y: 30 },
        { x: 2, y: 45 },
        { x: 3, y: 38 }
      ]
    }
  ];
  const months = ['Jan', 'Feb', 'Mar'];
</script>

<LineChart series={monthSeries} xAxisCategories={months} />

Category labels also appear in the default tooltip title instead of the raw numeric x value.

showArea — Filled Area Under the Line

Fill the area below each line with a vertical gradient. By default the gradient is derived from the series colour (opaque at the top, transparent at the bottom). Supply areaGradient to use fully custom from/to colour stops.

<!-- Default: uses series colour -->
<LineChart {series} showArea />

<!-- Custom gradient colours -->
<LineChart
  {series}
  showArea
  areaGradient={{ from: 'rgba(99,102,241,0.5)', to: 'rgba(99,102,241,0)' }}
/>

Highlight Hook — onChartReady

Receive a ChartHighlightAPI after mount to drive point highlighting from an external orchestrator (e.g. animated step-through, voice narration sync, keyboard navigation):

<script>
  import type { ChartHighlightAPI } from '@juspay/svelte-ui-components';

  let api;

  const onChartReady = (chartApi) => {
    api = chartApi;
  };

  // Later, to highlight the 3rd point:
  api?.highlight(2);

  // To clear:
  api?.highlight(null);

  // To read back the category labels:
  const labels = api?.getCategories(); // e.g. ['Jan', 'Feb', 'Mar', ...]
</script>

<LineChart {series} xAxisCategories={months} onchartready={onChartReady} />

Narration sync — createNarrationHighlighter

The orchestrator the hook above was built for, so it does not have to be written per app. Feed it the transcript as an assistant speaks and it highlights the slice being named, clearing itself after a pause.

<script lang="ts">
  import { createNarrationHighlighter } from '@juspay/svelte-ui-components';
  import type { NarrationHighlighter } from '@juspay/svelte-ui-components';

  let highlighter: NarrationHighlighter | null = null;

  const onChartReady = (api) => {
    highlighter = createNarrationHighlighter({ chart: api });
  };

  // as each transcript chunk arrives — pass the transcript SO FAR, not the delta
  const onTranscript = (textSoFar: string) => highlighter?.processText(textSoFar);

  // when the assistant begins a new answer
  const onTurnStart = () => highlighter?.reset();

  $effect(() => () => highlighter?.destroy());
</script>

<LineChart {series} xAxisCategories={months} onchartready={onChartReady} />

createNarrationHighlighter itself is SSR-safe, but the highlighter it returns schedules a setTimeout for its auto-clear, so instantiate it where the browser exists -- inside onchartready (as above) or onMount, never at module scope.

It takes the ChartHighlightAPI directly — no registry of charts, because getCategories() is already the label list and highlight(null) is already the clear path. processText returns the index it highlighted, or null when the narration named nothing new; a category fires at most once per turn, until reset().

Option Default What it does
chart — The ChartHighlightAPI from onchartready.
autoClearMs 2000 How long a highlight stays up. An unusable value falls back to the default.
caseSensitive false Match labels case-sensitively.
match whole-word Replaces the matching rule entirely.

On the matching rule, because the default is a deliberate choice. A label matches only as a whole word. Substring matching is available — match: (narration, category) => narration.includes(category) — but makes a poor default: labels are often ordinary words like Other, All or None, especially when they come from a model's tool output rather than a curated list, and a substring rule fires Other on otherwise and others.

Whole-word matching narrows that surface without closing it. In "on the other hand", other is genuinely a standalone word, so the label still matches — no lexical rule could decide otherwise without reading the sentence. If your labels are not yours to curate, pass a stricter match, and call reset() between turns so a mis-fire cannot outlive one answer.

highlightedIndex — Declarative Prop

Highlight a point without a callback. Set highlightedIndex to a zero-based point index. The chart enlarges that dot, draws the crosshair, and dims all other dots. Set to null to clear.

<!-- Highlight the 6th point (index 5) -->
<LineChart {series} highlightedIndex={5} />

Data Labels

<LineChart {series} showValues />

Dashed Comparison Series

Set dash on a series to render it with a dashed stroke — the standard treatment for a comparison/previous-period line. true uses the default '6 4' pattern; pass a string for a custom SVG stroke-dasharray.

<LineChart
  series={[
    { name: 'This week', data: current },
    { name: 'Last week', data: previous, color: '#A4CEFF', dash: true }
  ]}
/>

Single Data Point

A series whose data resolves to a single finite point renders as a flat horizontal line at that y across the full plot width (design-system contract — a lone dot reads as a glitch). The point marker still renders at its true x, and hover/tooltip behave normally.

Without Dots (Overlay Hover)

<LineChart {series} showDots={false} />

Hovering anywhere over the plot area finds the nearest point and shows a crosshair + tooltip.

Custom Tooltip

<LineChart {series}>
  {#snippet tooltipSnippet(context)}
    <div style="background: #333; color: white; padding: 8px; border-radius: 4px;">
      <strong>X: {context.x}</strong>
      {#each context.points as p}
        <div style="color: {p.color}">{p.name}: {p.y}</div>
      {/each}
    </div>
  {/snippet}
</LineChart>

Empty State

<LineChart series={[]}>
  {#snippet empty()}
    <p>No data available.</p>
  {/snippet}
</LineChart>

Multi-Series Alignment

Series are joined by their x value, not by array position: a shorter, offset, reordered or duplicate-x series never has another series' sample attributed to its column. Hover, the tooltip, and hit-testing all read from this same alignment — there is no separate, position-based path. For the common case where every series already shares one x sequence this reproduces the exact positional pairing you'd expect.

<script>
  const series = [
    {
      name: 'This week',
      data: [
        { x: 1, y: 10 },
        { x: 2, y: 20 }
      ]
    },
    {
      name: 'Last week',
      // Different x coverage -- hovering at x=2 reads THIS series' own
      // sample at x=2 (200), not whatever sits at array index 1.
      data: [
        { x: 2, y: 200 },
        { x: 3, y: 300 }
      ]
    }
  ];
</script>

<LineChart {series} />

Sparse Series — Gap Points

A data point with a non-finite y (NaN) marks a gap: the line breaks around it and resumes at the next finite point, instead of one poisoned SVG path (a single NaN coordinate makes the browser drop everything after it, visually cutting the line mid-chart). Gap points render no marker, no data label, are skipped by hover/crosshair/tooltip, and are excluded from the auto-computed axis domains.

<script>
  const series = [
    {
      name: 'Sales',
      // Jun 3 had no data — the line gaps over x=3 and resumes at x=4.
      data: [
        { x: 1, y: 120 },
        { x: 2, y: 180 },
        { x: 3, y: NaN },
        { x: 4, y: 150 }
      ]
    }
  ];
</script>

<LineChart {series} />

See Chart Input Policy for the full table of input shapes (empty, all-zero, single point, null/NaN/Infinity, negative values, reordered times, and unknown stackNormalize totals — the latter shared with AreaChart) and how each one renders, plus the calendar-axis limitation and why NaN cannot survive a JSON round trip.

X-Axis Tick Density

The x-axis renders at most 6 ticks (per the design-system line-chart spec), thinning further on narrow charts. Y-axis ticks were already capped at 6.

Accessible name and description

Every chart drawing needs a name of its own. ariaLabel names the chart (it lands on the <svg>), and the optional ariaDescription adds the takeaway — trend, range, outliers — which is announced after the name:

<LineChart
  {series}
  ariaLabel="Revenue by month, January to June"
  ariaDescription="Revenue rises from 30 in January to 90 in December, dipping in March."
/>

Omit ariaLabel and a name is derived from the chart itself — "{yAxisLabel} line chart", else the series names ("Line chart: Revenue, Cost"), else "Line chart" — so an unlabelled chart is still identifiable, but a name written for the page is almost always better. A blank string counts as omitted.

How the drawing is exposed depends on whether it holds controls:

  • A chart that draws data points is interactive: those marks are focusable role="button" elements, so the <svg> is exposed as a named role="group" rather than role="img". An image's children are presentational (ARIA), so marks left under one are dropped or announced inconsistently between browsers, and axe reports nested-interactive.
  • A chart with nothing to operate (every series hidden through the legend) is a static, named role="img".
  • The <svg> itself carries the name. A name on some wrapper elsewhere does not name the image inside it.
  • Tick labels and the value labels drawn on the chart are aria-hidden: each mark's own accessible name already says its category and value, so exposing them too would announce everything twice. The axis titles (xAxisLabel, yAxisLabel) stay exposed — they are where a unit or dimension is stated.
  • The description is an SVG <desc> with an instance-scoped id referenced by aria-describedby; every gradient and pattern id is instance-scoped too, so two charts on one page (or in two shadow roots) never resolve each other's references.

Keyboard access

Every rendered data point is a focusable role="button" element (tabindex="0"), labelled via aria-label with its resolved name (label, else the formatted x value) and value — "{name}: {value}" for a single series, "{name} — {series}: {value}" when there is more than one, matching the tooltip's own multi-series disambiguation. Tab/Shift+Tab moves through points in series order, then point order within each series. Enter or Space on a focused point fires onpointclick, the same event a pointer click fires. Focusing a point also activates it exactly as pointer hover does — same tooltip content, same anchor position — through the one activate() function both input paths share, so keyboard and pointer users can never see the two drift apart. This is the same family-wide keyboard/tooltip contract implemented by BarChart, DualAxisBarChart, FunnelChart, PieChart and SankeyChart — see PieChart's "Keyboard access" section for the full contract.

LineChart is a continuous series rather than a fixed set of categories, so "the marks to Tab through" is a deliberate choice rather than a given: each rendered (series, point) pair is its own stop, in the same order pointer hover's nearest-point search already uses — keyboard and pointer users reach the same addressable data, just via different input.

Unlike AreaChart, LineChart also carries a single visually-hidden role="status" aria-live="polite" region announcing the active point's name and value. It exists for the same reason PieChart's does: LineChart exposes two ways to change the highlighted point without a focus event — the declarative highlightedIndex prop and the imperative ChartHighlightAPI from onchartready — and a focus event is the only other route assistive tech has to learn a point changed. Direct interaction (pointer hover or keyboard focus) takes precedence over either of those programmatic paths, matching PieChart's own precedence order. AreaChart has neither prop, so its every state change already goes through a focus event and it relies on aria-label alone — this is not the two new charts disagreeing with each other, it is the same underlying rule (announce what a focus event cannot) applied to two different prop surfaces.

A focused point is spoken once: as its own accessible name ("2 — Product A: 35"). The status region adds only what that name lacks, so it stays empty when it would merely repeat the name (a single series, or sharedTooltip: false), and it carries the other series at that x when the tooltip is shared ("2 — Product A: 35, Product B: 25, Product C: 15"). It always speaks for the paths that have no focus announcement of their own: pointer hover, highlightedIndex and the ChartHighlightAPI. The point buttons are deliberately not aria-describedby the region: that spoke the summary a second time as each point's description, and because one region is shared by every point it described each unfocused point by whichever point was announced last.

Legend Aggregates

The aggregate sits beside the legend control, never inside it. When the legend is interactive (interactiveLegend), each entry is a toggle button, and every bit of text inside a button becomes part of its accessible name. Rendering the figure inside the toggle would make that name change whenever the data does — Revenue $6,500 one load, something else the next. A name that moves breaks voice-control targeting, breaks any consumer test matching it exactly (Testing Library's getByRole matches the whole string by default), and announces a figure as the control's identity rather than as information about the series.

So the button is named by its series alone, the aggregate is its sibling, and clicking the figure does not toggle the series.

Set aggregate on a series to show a computed value beside its legend label. Omitted (or 'none'), the default, shows nothing — the legend renders exactly as before. Matching the gap-point behavior above, every kind, sum included, skips non-finite y values rather than treating them as zero (this only changes the result for 'average', which shrinks its denominator, and 'min'/'max', which an absent point can never set); an aggregate over zero real points renders nothing rather than NaN or a fabricated 0, sum included. aggregateFormat defaults to yTickFormat.

<LineChart
  series={[
    { name: 'Product A', data: [...], aggregate: 'sum', aggregateFormat: (v) => `${v} units` },
    { name: 'Product B', data: [...], aggregate: 'average' }
  ]}
  showLegend
/>

Props

Prop Type Required Default Description
series LineChartSeries[] Yes - Array of {name, data, color?, aggregate?, aggregateFormat?}. Each series renders as a separate line. aggregate ('sum' | 'average' | 'min' | 'max' | 'none', default 'none') shows a computed value beside the legend label; aggregateFormat defaults to yTickFormat. See "Legend Aggregates" below.
curve 'linear' | 'monotone' | 'spline' | 'step' | 'natural' No 'monotone' Interpolation between points. 'spline' is an alias for 'monotone'.
gradientFill boolean No false Legacy gradient fill: renders a per-series gradient using the series colour, from fillOpacity+0.3 at top to transparent. Superseded by showArea + areaGradient for new usage.
fillOpacity number No 0.3 Base opacity of the gradientFill area (0–1). Hovered series gets +0.2 boost.
showArea boolean No false Fill the area under each line. Uses areaGradient colours when provided; otherwise derives a vertical gradient from the series colour (0.35 opacity at top, transparent at bottom).
areaGradient { from: string; to: string } No - Custom CSS colour stops for the showArea fill. from is the colour at the top (near the line), to is the colour at the baseline. Any valid CSS colour string is accepted.
showDots boolean No true Whether to render dots at each data point. Hover still works via overlay when false.
showValues boolean No false Whether to render text labels with the y-value at each data point.
dotRadius number No 4 Radius of data point dots in pixels. Hovered or highlighted dot is 1.5× this.
strokeWidth number No 2 Width of line strokes in pixels.
showGridlines boolean No true Whether to show dashed gridlines across the Y axis.
showXAxis boolean No true Whether to render the X axis.
showYAxis boolean No true Whether to render the Y axis.
showLegend boolean No false Whether to render the legend. Only shown when there are multiple series.
xDomain [number, number] No auto Fixed [min, max] for the X axis.
yDomain [number, number] No auto Fixed [min, max] for the Y axis.
xAxisLabel string No - Text label below the X axis.
yAxisLabel string No - Text label beside the Y axis (rotated).
xAxisCategories string[] No - String category labels, one per x-index (parallel array). Index 0 maps to x=1, index 1 to x=2, and so on. When provided, these labels replace raw numeric x values on tick labels, the tooltip title, and getCategories().
xTickFormat (value: number | string) => string No abbreviated Formatter for X axis tick labels. When provided, overrides the xAxisCategories tick formatter.
yTickFormat (value: number | string) => string No abbreviated Formatter for Y axis tick labels.
yIntegerTicks boolean No false Snap Y-axis ticks to whole numbers. Use for discrete count metrics (orders, sessions) where a small domain would otherwise produce fractional ticks (0, 0.5, 1, 1.5, 2).
aspectRatio number No 16/9 Width-to-height ratio.
minHeight number No - Minimum chart height in pixels, regardless of computed aspect-ratio height.
maxHeight number No - Maximum chart height in pixels, regardless of computed aspect-ratio height.
highlightedIndex number | null No null Zero-based point index to highlight declaratively. Enlarges the dot at that index, draws the crosshair, and dims all other dots. Set null to clear.
tooltipSnippet Snippet<[LineChartTooltipContext]> No - Custom tooltip. Receives {x, points: [{name, y, color, label?}]} with values for all series at the hovered X.
empty Snippet No - Content rendered when all series are empty.
ariaLabel string No derived Accessible name of the chart (aria-label on its <svg>). Say what the chart shows. When omitted a name is derived from yAxisLabel / the series names, else "Line chart". See Accessible name and description.
ariaDescription string No - Optional longer description announced after the name (an SVG <desc> referenced by aria-describedby).
testId string No - Value for the data-pw attribute on the chart container.
classes string No - CSS class string applied to the top-level element.
sharedTooltip boolean No auto One anchored tooltip listing every visible series at the hovered x position. Defaults to true for multi-series charts, false for single-series.
interactiveLegend boolean No false Legend items become click/keyboard toggles for series visibility; hidden series are removed from the plot and the scales rescale to the remaining data.
hideLegendBelow number No 360 Hide the legend when the measured chart width is below this pixel value; 0 disables the behavior.
tooltipPortal boolean No false Render the tooltip into document.body (position: fixed) so scroll/overflow ancestors never clip it.

Events

Event Type Description
onpointclick (event: { seriesIndex: number; pointIndex: number; point: LineChartDataPoint }) => void Fires when the plot area is clicked with a hovered point.
onpointhover (event: { seriesIndex: number; pointIndex: number; point: LineChartDataPoint } | null) => void Fires when hover moves to a new point or leaves the chart. null on leave.
onchartready (api: ChartHighlightAPI) => void Called once after mount. Provides a ChartHighlightAPI for imperative highlight(index|null) and getCategories().

Labels over plotted colors

Printed labels have an opaque backplate measured from their actual SVG glyph bounds, including loaded-font changes. This keeps text readable when it crosses slices, lines, markers or hover guides. The data palette and labels are unchanged. Override the shared --chart-label-background to match a custom chart surface, and pair it with the existing label foreground token (--piechart-label-color or --linechart-value-color). Keep that pair at 4.5:1 for normal-size text; a transparent plate again exposes the plotted colors.

CSS Variables

In addition to the shared --chart-* variables (see BarChart docs), LineChart exposes:

Variable Default CSS Property Description
--linechart-dimmed-opacity 0.2 opacity Opacity of non-hovered / non-highlighted series/points.
--linechart-hover-line-color #ccc stroke Color of the vertical crosshair line (hover and highlight).
--linechart-hover-line-dash 4 4 stroke-dasharray Dash pattern of the crosshair.
--linechart-value-color #333 fill Color of point value labels.
--linechart-value-font-size 11px font-size Font size of point value labels.
--linechart-highlight-ring-color #fff stroke Ring (outline) stroke colour of an actively highlighted dot.
--linechart-highlight-ring-width 2.5 stroke-width Ring stroke width of an actively highlighted dot.

Dark mode

Chart colors resolve through CSS light-dark(). Set color-scheme on the chart's ancestor (or :root) so the correct side is chosen:

:root {
  color-scheme: light;
}
[data-theme='dark'] {
  color-scheme: dark;
}

Every --chart-* / component token can still be overridden per theme; overrides always win over the built-in light-dark() fallbacks.

Type Reference

type LineChartDataPoint = {
  x: number;
  y: number;
  label?: string;
};

type LineChartSeries = {
  name: string;
  data: LineChartDataPoint[];
  color?: string;
  /** Dashed stroke: true = '6 4', string = custom stroke-dasharray. */
  dash?: boolean | string;
};

type LineChartTooltipContext = {
  x: number;
  points: Array<{ name: string; y: number; color: string; label?: string }>;
};

type LineChartAreaGradient = {
  /** Colour at the top of the gradient (closest to the line). */
  from: string;
  /** Colour at the bottom of the gradient (at the baseline). */
  to: string;
};

// From @juspay/svelte-ui-components — also used by BarChart, DonutChart
type ChartHighlightAPI = {
  highlight: (index: number | null) => void;
  getCategories: () => string[];
  type: 'bar-chart' | 'line-chart' | 'donut-chart';
};

Web Component

sui-line-chart is registered by the web-component bundle. Registering it was gated on ChartTooltip's portal target: LineChart can portal its tooltip to document.body (the tooltipPortal prop), and Svelte scopes a custom element's CSS to its shadow root, so a node relocated into the light DOM used to keep its markup and lose every style rule scoped to that root. ChartTooltip now resolves its portal destination from the node's own root (getRootNode()) — landing back inside the shadow root when there is one, and falling through to document.body only when there isn't — so the element ships fully styled whether or not tooltipPortal is set.

<script type="module" src="@juspay/svelte-ui-components/wc"></script>

<sui-line-chart show-legend curve="natural" aspect-ratio="2"></sui-line-chart>

<script>
  const chart = document.querySelector('sui-line-chart');
  chart.series = [
    {
      name: 'Revenue',
      data: [
        { x: 1, y: 30 },
        { x: 2, y: 45 },
        { x: 3, y: 38 },
        { x: 4, y: 52 }
      ]
    }
  ];
  chart.xAxisCategories = ['Jan', 'Feb', 'Mar', 'Apr'];
  chart.yTickFormat = (v) => `$${v}`;
  chart.onchartready = (api) => {
    api.highlight(2);
  };
</script>

Name and describe the chart with chart-aria-label / chart-aria-description (properties chartAriaLabel / chartAriaDescription). They are not aria-label / aria-description, which on a custom element name the host (a role-less element) rather than the drawing inside its shadow root; the host's own ARIA attributes are left alone. See Accessible name and description.

<sui-line-chart
  chart-aria-label="Revenue by month"
  chart-aria-description="Revenue grows all year."
></sui-line-chart>

Arrays, objects and functions — series, areaGradient, xDomain, yDomain, xAxisCategories, xTickFormat, yTickFormat, onchartready, onpointclick and onpointhover — must be assigned as JavaScript properties. They cannot cross the HTML-attribute boundary.

Web Component Events

onchartready, onpointclick, and onpointhover are available as JS properties, and each also dispatches a same-named DOM custom event (bubbles, composed) for a consumer who only calls addEventListener — each carries its own single argument as detail (the ChartHighlightAPI, or the point-hit object, or null on hover-leave):

chart.addEventListener('chartready', (e) => e.detail.highlight(2));
chart.addEventListener('pointclick', (e) => select(e.detail.point));
chart.addEventListener('pointhover', (e) => setHovered(e.detail?.point ?? null));

Slots

Slot Replaces
empty The empty state shown when every series has no data.

Supply it only when you mean to: with no empty slot the component falls through to its own chart frame, and an empty slot would replace that frame with a blank box.

Svelte-only: tooltipSnippet (receives a LineChartTooltipContext) takes an argument, so it cannot be expressed as a named slot: a Web Component <slot> projects markup and does not forward Svelte snippet parameters, so the hover context ({x, points}) would be silently dropped. Use the Svelte component directly when you need a custom tooltip.