Charts
Labelled SVG marks Arrow Key Navigation Data table

VdChart renders bar, line, area, scatter, donut, and pie charts. Supply data and field names. Each chart includes labelled marks, keyboard navigation, tooltips, and an optional data table.

Keyboard navigation and data table
Tab into the chart or click a bar to focus it.
Use → / ← or ↓ / ↑ to cycle between bars with roving focus and live tooltip.
Use Home / End to jump to first/last bar; press Enter or Space to select.

Show the data table with data-table="visible". Production default is true (sr-only, for assistive tech only); false suppresses it.

No bar selected yet — press Enter on a focused bar.

Core Chart Types

Bar, line, area, scatter, donut, and pie — automatic dimension measurement and responsive resize. Click a donut or pie slice to see @slice-click.

Bar Chart
Line Chart
Area Chart
Donut Chart

Custom centerLabel string

centerLabel: true shows the computed total

Click a slice to emit @slice-click.
Pie Chart

Data Accuracy & Advanced Features

Handles mixed positive and negative values from zero baseline, multi-series grouped bars with legends, reference line annotations, and 2D scatter plots.

Profit & Loss (Negative Y-values)
Multi-Series Grouped Bar (right legend)
Annotations & Pinned Range
Scatter Plot (2D Coordinates)
Click a scatter point to inspect coordinates.
Data Labels & Stage Colors
Top conversion stages highlighted in green via per-row color callback.
Accessibility

Give the chart a title and a description of the takeaway. Marks expose value labels; the generated table exposes the data through standard table navigation. Test your labels, colors, and interactions with your users’ assistive technology.

Graphics roles and a data table are features, not a claim of WCAG conformance for the finished page.

API & Keyboard Reference

Installation

Accessible Chart Usage

<!-- WAI-ARIA Graphics, keyboard navigation, and data table fallback -->
<script setup lang="ts">
import { VdChart, type ClickEvent } from '@vanduo-oss/vd3-charts';
import '@vanduo-oss/vd3-charts/css';

const data = [
  { quarter: 'Q1', revenue: 145 },
  { quarter: 'Q2', revenue: 210 },
  { quarter: 'Q3', revenue: 185 },
  { quarter: 'Q4', revenue: 290 },
];

const onClick = (e: ClickEvent) => console.log('Clicked:', e.datum);
</script>

<template>
  <!-- data-table default is true (sr-only). Use "visible" to show the
       data table in layout, or false to suppress it. -->
  <VdChart
    type="bar"
    :data="data"
    x="quarter"
    y="revenue"
    title="Quarterly Revenue"
    data-table="visible"
    @bar-click="onClick"
  />
</template>

Advanced Features Usage

Keyboard Navigation Shortcuts

KeyBehavior
Tab / Shift+TabEnter or leave the interactive chart mark group.
ArrowRight / ArrowDownMove focus to the next data mark (cycles with wraparound) and displays its tooltip.
ArrowLeft / ArrowUpMove focus to the previous data mark (cycles with wraparound) and displays its tooltip.
HomeJump keyboard focus directly to the first data mark.
EndJump keyboard focus directly to the last data mark.
Enter / SpaceTrigger the mark's click callback (e.g. @bar-click, @point-click, @slice-click).
EscapeBlur the focused mark and dismiss the active tooltip.

Chart Types

TypeDescription
type="bar" / VdBarChartCategory bars with band scale, axes, grid lines, negative y handling, keyboard arrow navigation, and data table fallback.
type="line" / VdLineChartLine path with interactive circle marks over category, numeric, or date-like x values.
type="area" / VdAreaChartFilled area path closing to zero baseline plus line path, sharing the cartesian scale engine.
type="scatter" / VdScatterChartCircle marks over 2D numeric, date-like, or categorical scales with point click handling.
type="donut" / VdDonutChartArc slices with inner-radius ratio (default 0.62), percentage tooltips, center total summary (or custom centerLabel / centerSubLabel), and legend.
type="pie" / VdPieChartSolid pie wedges. Both VdChart type="pie" and VdPieChart default to an inner-radius ratio of 0.

Component API (Props & Events)

Prop / EventDescription
:type'bar' | 'line' | 'area' | 'scatter' | 'donut' | 'pie' (default 'bar'). Or import typed VdBarChart, VdLineChart, VdAreaChart, VdScatterChart, VdDonutChart, VdPieChart.
:dataArray of row objects.
x / yCartesian accessors — field key string or (datum) => value function.
label / valuePie / donut accessors.
refresh() (template ref)Charts observe data-theme, data-primary, data-palette, data-neutral, class, and style mutations automatically. Call refresh() for imperative redraws.
title / description / :aria-labelRendered into SVG accessibility metadata (<title>, <desc>, and aria-label).
:data-tabletrue (sr-only, default) | 'visible' | false. Generates an HTML data table.
:inner-radius-ratioHole size (0–0.9): donut defaults to 0.62; pie defaults to 0.
:center-label / :center-sub-labelCustom center text and subtitle inside a donut hole (or :center-label="false" to hide).
:aria-role-descriptionCustom ARIA role description override for the SVG shell (defaults to `${type} chart`).
:svg-roleOverride the inner SVG graphics role. The standard role attribute still falls through to the wrapper root; core factories use the role option directly.
:width / :height / :marginExplicit SVG width, container min-height in px (default 300), and plot margin override ({ top, right, bottom, left } or number).
:theme / :tooltip / :responsiveTheme overrides, custom/disabled tooltip, responsive resize observer.
:seriesMultiple series — grouped bars, or one line/area path each (Series[]).
:colorA CSS color string ('#40c057', 'rgb(...)', 'var(...)'), category-field name, or per-datum (row) => color callback across Cartesian and polar charts.
:stroke / :stroke-width / :fill / :fill-opacityLine and area mark styling overrides (stroke color, stroke width, area fill color/boolean, and area opacity).
:points / :point-radius / :point-fill / :point-opacityPoint mark visibility (false hides line/area points), radius in px, fill color, and scatter point opacity.
:bar-padding / :x-scaleBar band padding (0–0.8, default 0.18) and horizontal scale type ('band' | 'point' | 'linear' | 'time').
:data-labelstrue or { format, color } — draw value labels on each mark.
:annotationsReference lines: [{ y?, x?, label?, color?, dash? }].
:x-min / :x-max / :y-min / :y-max / :y-tick-count / :y-include-zeroPin axis bounds and tick density (supports negative floors and clamped baselines).
:x-format / :y-format / :x-axis / :y-axisCustom tick formatters and axis titles ({ label }).
:legendtrue, false, or { position: 'top' | 'right' } — shown by default for multi-series and polar charts.
@bar-click / @point-click / @slice-clickMark-click events — each carries ClickEvent { event, datum, index }.