Charts (@hozo/charts)
Use @hozo/charts when you have data rather than drawing instructions.
It handles scales, axes, interaction, and what assistive technology reads.
For custom vector artwork use SVG; for a custom drawing scene use
2D Canvas. Charts use SVG on both platforms and do not require Skia.
@hozo/charts@0.5.1 exports BarChart and LineChart. The bar example below
and the basic line example work with that release.
The wider chart selection and the newer large-data behavior documented here
are from main; check your installed version before using those APIs.
Install and draw a chart
Section titled “Install and draw a chart”The previews run in your browser. On the plot, use a pointer or touch to explore the data. With a keyboard, Tab to the plot and use the arrow keys. The code beneath each preview is the source used to render it.
pnpm add @hozo/charts# In the React Native app only (Expo):npx expo install react-native-svgThe Native app must declare react-native-svg itself (15.9.0 or later), so
the app’s build can link it. Web needs no native dependency.
| Month | Online | In store |
|---|---|---|
| Jan | $120 | $80 |
| Feb | $200 | No value |
| Mar | $90 | $60 |
import { BarChart } from '@hozo/charts'const revenue = [ { month: 'Jan', online: 120, store: 80 }, { month: 'Feb', online: 200, store: null }, { month: 'Mar', online: 90, store: 60 },]const series = [ { key: 'online', label: 'Online' }, { key: 'store', label: 'In store' },]export function MonthlyRevenue() { return ( <BarChart accessibilityLabel="Monthly revenue by channel" data={revenue} x={{ key: 'month', label: 'Month' }} y={{ label: 'Revenue', format: (value) => `$${value}` }} series={series} height={240} showTable /> )}The x.key names the category in each row; each series names a value field.
height is required, and the chart measures its container unless you supply
width. A missing or null value is a gap, not zero. In this example,
February has no store bar and the table says “No value”.
Pick a chart for the question (main)
Section titled “Pick a chart for the question (main)”- Compare categories: use
BarChart. Usehorizontalfor long labels, orstackedwhen the sum and its parts both matter. - See a trend: use
LineChartorAreaChart. Usex.type: 'time'and chronological rows to show real time intervals.ComposedChartoverlays lines and bars when they need to be read together. - Find a relationship or a dense spot: use
ScatterChartfor two numeric axes, orHeatmapChartfor values indexed by row and column. - Show parts, stages, or flows: use
PieChartorDonutChartfor shares,TreemapChartfor nested parts,FunnelChartfor stages, andSankeyChartfor flows.RadarChartandRadialBarChartoffer radial layouts. - Summarize in a small space: use
Sparkline. It exposes one image description, without a keyboard stop or table.
Recipes
Section titled “Recipes”- Comparisons and trends: bar layouts, Line, Area, Composed, and Sparkline.
- Scatter and heatmaps: numeric points and pivoted cells.
- Parts, stages, and flows: Pie, Donut, Funnel, Treemap, Sankey, Radar, and RadialBar.
- Theme, sync, and range: shared styles, linked charts, and a selectable row window.
Accessibility and larger datasets
Section titled “Accessibility and larger datasets”Give the plot a specific accessibilityLabel. On Web, Tab reaches the plot
as a single stop; use the arrow keys to explore its values. On Native, the
plot exposes adjustable actions to VoiceOver and TalkBack. A pointer or
touch can also pick a value. The summary and data table describe the data
without requiring the reader to interpret the SVG marks.
Use showTable when readers should see the values as well as the plot.
Without it, tables are visually hidden. On main, Native mounts the hidden
table when a screen reader is detected. The default limit on main is
TABLE_ROW_LIMIT (1,000 categories, or cells for a heatmap); above it the
chart keeps the summary and value exploration, but omits the table unless
you request it explicitly. For a large dataset, offer a filtered view or
separate data download rather than forcing a very large table onto the screen.
See the package reference for full props, theming, synchronized charts, and range selection, and the scale measurements for tested device configurations and results.