Scatter and heatmaps
These examples use the chart exports on main. Start with the
Charts overview for installation and release compatibility.
Scatter chart
Section titled “Scatter chart”Use numeric x values when the distance between observations matters. Each
series key names a numeric y value, and name identifies the observation
in the tooltip and data table.
import { ScatterChart } from '@hozo/charts'const samples = [ { town: 'Bay', elevation: 80, temperature: 22 }, { town: 'Ridge', elevation: 620, temperature: 18 }, { town: 'Summit', elevation: 1400, temperature: 12 },]export function ElevationAndTemperature() { return ( <ScatterChart accessibilityLabel="Temperature by elevation" data={samples} name={{ key: 'town', label: 'Town' }} x={{ key: 'elevation', label: 'Elevation', format: (value) => `${value} m` }} y={{ label: 'Temperature', format: (value) => `${value} °C` }} series={[{ key: 'temperature', label: 'Temperature' }]} height={240} /> )}Heatmap chart
Section titled “Heatmap chart”Use a heatmap when observations occupy a grid. The colour scale represents magnitude, while both the active cell and the data table expose the value with its row and column.
If heatmap data arrives as one record per cell, pivotRows produces the
table it needs. Rows and columns keep first-seen order; omitted cells stay
empty.
import { HeatmapChart, pivotRows } from '@hozo/charts'const { data, columns } = pivotRows( [ { day: 'Mon', hour: '09:00', visits: 18 }, { day: 'Mon', hour: '15:00', visits: 42 }, { day: 'Tue', hour: '09:00', visits: 25 }, ], { row: 'day', column: 'hour', value: 'visits' },)export function VisitsByHour() { return ( <HeatmapChart accessibilityLabel="Visits by day and hour" data={data} x={{ key: 'day', label: 'Day' }} columns={columns} value={{ label: 'Visits' }} height={220} /> )}Pass columns directly when the source is already one object per row.
Each column names a field through key and a display heading through label.