Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

chart-wc

SVG chart component with progressive enhancement: semantic table → CSS chart → SVG chart. Supports bar, column, line, area, pie, ring, scatter, and bubble types.

Overview

An SVG chart web component with built-in charting engine. Supports eight chart types with five data source options. Progressive enhancement means a semantic <table> is visible without JavaScript — with JS, the SVG chart renders and the table becomes the screen-reader (and print) version. Every chart has a data table: data supplied as JSON gets one generated. See Accessibility.

Chart Types

Set data-type to one of: bar, column, line, area, pie, ring, scatter, or bubble.

Line Chart

Pie Chart

Pie charts accept a flat object (label → value) as data.

Ring Chart

A ring (donut) chart is a pie with a transparent center hole. Same data shape as pie: a flat object of label → value. Slices below an angular threshold render with external leader-line labels; the percentage labels inside the slices are suppressed in ring mode to keep the chart readable at small sizes.

Tunables specific to ring (and pie) charts — pass via data-config:

PathDefaultPurpose
center.size"40%"Hole diameter as a percent of the chart's viewBox. Larger values produce a thinner ring.
center.style.fillvar(--color-surface, #fff)Hole fill. Follows the active VB theme by default; override with a custom --color-surface or an explicit fill value.
plot.node.label.placement"auto"auto uses external labels for small slices and hides internal labels in ring mode. Force with "outside".
plot.node.label.threshold12Slice angle (degrees) below which auto-placement switches to an external leader-line label.

Legend and tooltip

Every chart except a sparkline has a legend and hover tooltips unless you turn them off. data-legend="false" hides the legend, which a single-series chart rarely needs, and data-tooltip="false" turns the tooltips off. The bare attribute or ="true" states the default. On a table source the same attributes can go on the <table>. An attribute on <chart-wc> wins over data-config and over the table.

The legend sits beside the plot. When the chart is 400px wide or less it moves under the plot as a wrapping row, so the plot keeps the full width.

Sparkline mode

Add data-size="sparkline" to render a minimal trend chart with no axes, gridlines, tick labels, axis labels, title, legend, or tooltip. The chart becomes a pure inline shape sized by its container — ideal for dashboard tiles, data tables, and the sparkline slot of <score-card>.

Sparkline mode is a deterministic opt-in: shrinking the container alone won't strip chrome. Add the attribute when you want a sparkline, omit it for the full chart.

A sparkline gets a generated data table like any other chart; data-title becomes its caption, so screen-reader users hear "Revenue, last 7 days" plus the values.

The line, area, and column/bar chart types are the recommended sparkline shapes. pie and ring still render but ignore the chrome-strip (their chrome is the chart). Pair with a CSS custom property override on --chart-series-1 to colour the trend by tone:

Data Sources

The component resolves data using this priority chain:

PrioritySourceDescription
1JS property (.data)Set data programmatically
2data-valuesInline JSON attribute
3<script type="application/json">JSON script block child
4<template data-chart-data>Template child with JSON
5<table>Child table (progressive enhancement)

Table Source (Progressive Enhancement)

Wrap a semantic <table> inside <chart-wc>. The chart extracts data from the table and renders SVG. Without JavaScript, the table remains visible. The class="vb-chart" CSS-only chart styling (the no-JS layer) comes from the charts CSS bundle, vanilla-breeze-charts.css — it is not part of the core stylesheet.

Script Block

Template

Table Column Control

Use data-chart-label, data-chart-series, and data-chart-ignore on <th> elements to control how table columns are extracted.

Attributes

AttributeValuesDefaultDescription
data-type"bar", "column", "line", "area", "pie", "ring", "scatter", "bubble"—Chart type to render
data-valuesstring—Chart data as JSON string
data-configstring—Chart config overrides as JSON string
data-titlestring—Chart title text; also the caption of the generated data table
data-subtitlestring—Subtitle shown under data-title (requires data-title)
data-label-xstring—X / category axis label; also the category column header of the generated data table
data-label-ystring—Y / value axis label
data-legend"", "true", "false"trueSeries legend with show/hide checkboxes. On by default; "false" hides it (bare or "true" keeps it on). Wins over data-config. Moves under the plot when the chart is 400px wide or less.
data-tooltip"", "true", "false"trueHover tooltips. On by default; "false" turns them off (bare or "true" keeps them on). Wins over data-config.
data-palettestring—Custom color palette as JSON array
data-chart"replace", "enhance"—How to handle an authored source table: replace (default) visually hides it after the chart mounts but keeps it in the accessibility tree; enhance keeps it visible. Also readable from the table's own data-chart.
data-size"sparkline"—Render mode. sparkline strips all chrome (axes, ticks, gridlines, labels, title, legend, tooltip) for use as an inline trend chart sized by its container.

Structure

ElementRequiredDescription
<table>noOptional source table — data is extracted; the table stays the screen-reader (and print) version of the chart. Without one, chart-wc generates a table[data-chart-generated] from the data.
<script type='application/json'>noOptional inline JSON data source
<template data-chart-data>noOptional template-based JSON data source

Events

EventDetailDescription
chart-wc:render{ type, seriesCount }Fired after SVG chart renders successfully
chart-wc:error{ message }Fired when no data is found or chart rendering fails (the data table is then left visible)
chart-wc:config-resolved{ type, config }Fired before each render with the merged engine config (mutable, for last-minute tweaks)
chart-wc:data-changed{ data, config, source: 'property' }Fired when .data or .config is assigned
chart-wc:upgraded—Fired once after the component upgrades; safe signal for the first .data assignment

Accessibility

The rendered SVG is decorative to assistive technology (aria-hidden="true"); the chart's text alternative is always a real data table:

  • Table source: once the chart has mounted, the authored table gets class="visually-hidden". It stays in the accessibility tree — caption, headers and cells are all announced. With data-chart="enhance" it stays visible.
  • JSON sources (.data, data-values, <script>, <template>): chart-wc generates a visually hidden <table data-chart-generated> from the data and keeps it in sync on every render. Its caption is data-title (plus data-subtitle); data-label-x / data-label-y name the category and value columns. Pie/ring data becomes label/value rows, scatter/bubble data one row per point.
  • If the data can't be tabulated, the SVG is exposed instead as role="img" named by data-title.
  • Keyboard: the engine's own keyboard navigation (arrow keys between data points when tooltips are on, focusable pie slices) lives inside the aria-hidden SVG, so chart-wc removes those elements from the tab order (tabindex="-1") — a focusable element inside aria-hidden would be a silent tab stop for screen-reader users. Mouse tooltips still work; keyboard and screen-reader users get the same values from the table. Use data-chart="enhance" when sighted keyboard users need the numbers on screen.
  • Failure: the table is only hidden after the chart mounts successfully. If rendering throws, chart-wc:error fires and the table stays visible.
  • Print: the data table prints and the SVG is hidden (sparklines are the exception: they print the trend shape).

The table-hiding and print rules live in the charts CSS bundle. Without vanilla-breeze-charts.css a long hidden table can still extend the page's scroll height.

JavaScript API

Property / MethodTypeDescription
.dataArray|ObjectGet/set chart data. Triggers re-render on set.
.configObjectGet/set chart config overrides. Triggers re-render on set.
.refresh()voidRe-extract table data and re-render the chart.
.toSVG()string|nullGet the current SVG markup for export.

Reactive updates (JS-first)

For frameworks pushing live data, wait for chart-wc:upgraded before the first assignment, then react to changes via chart-wc:data-changed. The source field lets consumers ignore echoes from their own assignments.

See the Data API concepts guide for the dual HTML-first / JS-first contract that <chart-wc> shares with <kanban-board>, <work-item>, and <user-story>.

EventDetailWhen
chart-wc:upgraded—After each connect (again after the element is moved); safe signal for the first .data assignment.
chart-wc:data-changed{ data, config, source: 'property' }Fires when .data or .config is assigned via the property API.

Theme Integration

Charts read VB design tokens via CSS custom properties. The theme bridge converts these into palette and axis configuration automatically. Each chart property falls back to the theme token beside it, so charts follow light and dark mode without any set-up; set a property on <chart-wc> or an ancestor to override it.

Custom PropertyFalls back toPurpose
--chart-series-1 … --chart-series-6--color-primary, --color-accent, …Chart color palette per series
--chart-title-color--color-textTitle color
--chart-label-color--color-text-mutedAxis, legend and tooltip label color; subtitle color unless --chart-subtitle-color is set
--chart-axis-color--color-border-strongAxis line color
--chart-grid-color--color-borderGrid line color
--chart-tick-color--color-borderTick mark color
--chart-baseline-color--color-text-mutedZero line color when the data goes negative

Progressive Enhancement

LayerEnvironmentExperience
1No CSS, no JSPlain semantic table
2CSS onlyCSS chart via .vb-chart class (needs vanilla-breeze-charts.css)
3CSS + JSFull SVG chart with interactivity

Loading

<chart-wc> is part of the optional charts bundle (main-charts.js), not the core bundle. Include both its script and its stylesheet — the CSS carries the .vb-chart CSS-only charts, the chart sizing, and the accessible table-hiding and print rules:

↑