Skip to main content

Interface: TimeUnitWidth

Defined in: time/scale.ts:204

What a caller states when they want one unit of time to paint at a fixed width: "a day tile is 14 pixels wide". The Gantt/TimeScaleModel fit key takes this directly.

It exists because the pixels-per-millisecond form of fit cannot be written by hand safely. An author reaching for it computes 14 / 86_400_000, which asserts that every day is 24 hours — false in every zone that observes DST, and false for a month or a year in every zone at all. The zone and the anchor instant that settle the real length are the library's (plans/02: core fills zone math), so the author states the unit and the width, and pxPerMsForUnitWidth resolves it.

A TimeScale carries one pxPerMs for its whole span, so the width lands exactly on the unit at range.start and every other unit follows its own calendar length from there — a 23-hour day paints narrower than its neighbours, which is what a reader of a DST week expects to see. This is the anchor fit: 'preset' already resolves against.

Properties​

increment?​

readonly optional increment?: number

Defined in: time/scale.ts:208

How many units share widthPx. Defaults to 1 — { unit: 'week', increment: 2, widthPx: 90 } reads "a fortnight is 90 pixels".


unit​

readonly unit: TimeUnit

Defined in: time/scale.ts:205


widthPx​

readonly widthPx: number

Defined in: time/scale.ts:210

Pixels one increment of unit occupies.