Chapter 5: Time Series Without Manual Labor
Populating a grid by hand is feasible for eight by eight cells. For a full year with 371 cells, mapping timestamps onto matrix coordinates is precisely the type of arithmetic where daylight saving time and start-of-week offsets cause silent errors that nobody catches.
Presets take that work away: you don't deal with columns and rows at all. You say when something happened and how much, and the preset works out where it belongs.
From Dates to a Calendar
Presets reside in a dedicated submodule so they are not loaded unless explicitly imported:
import { presets } from 'mlc-isometric-heatmap/presets';
const days = [
{ date: '2026-09-01', value: 12 },
{ date: '2026-09-02', value: 7 },
{ date: '2026-09-02', value: 3 },
{ date: '2026-09-14', value: 18 },
];
const svg = presets
.aggregateCalendarMonth(days, { year: 2026, month: 8 }) // months count from 0: September
.render({ colorScheme: 'emerald' });There is not a single coordinate in this code. The preset takes care of the rest:
- Position: Every event lands on its weekday and week, including the offset of the first day of the month.
- Summing: Events on the same day add up, so 2 September shows 10 here.
- Filtering: Events outside the requested period are ignored, so one long list can feed several charts.
- Labels: Axes and tooltips are filled in, and
localeandweekLabeladapt them to your language.
Dates can arrive in whatever form your data has:
| Form | Example | Meaning |
|---|---|---|
| Plain date | '2026-09-01' |
That calendar day, in every time zone |
| Timestamp with time zone | '2026-09-01T22:30:00Z' |
Converted to local time, so it can land on another hour or day |
Date object |
new Date(2026, 8, 1) |
As it is |
| Milliseconds | 1788220800000 |
Since 1970, as many APIs deliver them |
Cells always follow the local time of whoever runs the code. An unreadable date is skipped without an error.
Without 3D: the Flat View
Not every page needs a landscape. In a dense table or a small dashboard, a standard heatmap is often the better choice. One switch is enough, and your data and preset stay the same:
const flat = presets
.aggregateCalendarMonth(days, { year: 2026, month: 8 })
.render({ view: 'flat', colorScheme: 'emerald' });aggregateYear and view: 'flat'.What changes compared to the 3D view:
- Only color carries the value: Height is gone, and with it the readability in grayscale and for colorblind readers.
interpolateColorsand a tooltip help, and a single-hue scheme likeemeraldusually reads better than a two-hue one. - Labels: Rows sit on the left and columns on top.
labelPosition: 'front'moves the columns below the grid. - No effect:
shape,maxHeight,projectionAngle,labelMode,labelLift,showAxisWallsandheightGridare ignored.
Colors, negative values, null, valueDomain and tooltips work as usual.
24 Hours Against Weekdays
This preset reads timestamp instead of date, because the hour matters:
const events = [
{ timestamp: '2026-06-09T10:15:00', value: 5 },
{ timestamp: '2026-06-09T15:30:00', value: 20 },
];
const grid = presets.aggregate24h(events, { startOfWeek: 1 });24 columns, 7 rows. Weeks begin on Monday by default; startOfWeek: 0 begins them on Sunday, as is common in US calendars.
This is the ideal view for diurnal rhythms: when machinery runs, when periods of quiet occur, and how weekends differ from working hours.
One Month
const grid = presets.aggregateMonth(days, { year: 2026, month: 8 });Weeks as columns, weekdays as rows. The monthly view is the granularity at which a human viewer can still easily inspect any individual day.
Half a Year
A gap exists between a single month and an entire year: 26 weeks is too wide for a single monthly chart, yet too compact to form long-term seasonal textures in an annual grid. The six-month preset bridges this gap, optionally with monthly divider gaps.
One Year
const grid = presets.aggregateYear(days, { year: 2026 });53 weeks against 7 weekdays — the geometry familiar from contribution graphs, elevated here with 3D height. At this density, row text can become visual clutter; showRowLabels: false turns them off cleanly.
Multiple Groups Side by Side
When comparing quarters, semesters, or different facility locations, multiple grids can be merged into a single visualization rather than laid out in separate figures. The critical benefit is a unified vertical scale — independent graphs scale to their own local maxima, distorting comparative analysis.