High Command
LibraryTemplatesGet startedPricing
Get Pro · $79

Guide

Browse everythingGetting startedThemingYour data

Site

HomeTemplatesPricingChangelog

Templates 4

Command centerProFleetProCustomer trackingProField servicePro

Ops and shell 9

App shellProOps modelProAttention queueProMorning briefProShift handoverProLane panelProOwn-fleet partsProAgent action barProCustomizable dashboardPro

Map 17

PMTiles basemapPMTiles routeTrip hologramProBasemap styleMap geometryMapLand texture and dot lensProException heatmap and risk contoursProLane arcsProShipment layerOwn fleet layerProFleet map layersCurated place labels and sitesRoute traceEdge chipsProMap key, filters and paddingMap kitPro

Time and trips 11

Time and trip modelsEvent fieldProIn-transit rowsProImpact lineProActivity barProReplay clockTime controlPlayback overlayProTrip timetableProStage rowWeek cursorPro

Figures, charts and tables 14

Sourced valueKey-figure tileFigure groupPart barBand sparklineKPI stripProChart kitPop barWaterfall cascadeMargin chartsPro13-week cash ladderProWork tableProField railProHorizon gridPro

Zones and dispatch 10

Zones modelDispatch modelProGeofence layerGeofence eventsGeofence drawProService ringsDensity heatmapJob queueProAssign dialogProStop listPro

Design system 3

ThemeShared helpersUI primitives

Routing 3

Offline road routerAustin road graphAustin areas

Libraries 2

Fleet coreRoute core
High Command

Map, fleet and ops-console components for React. Built in-house, copied into your app with the shadcn CLI.

Product

  • Library
  • Templates
  • Pricing
  • Changelog

Build

  • Get started
  • Accessibility
  • Trip hologram

Templates

  • Command center
  • Fleet
  • Field service

New pieces by email. A short note when a release lands.

One email per release. Unsubscribe any time.

© 2026 High Command Pro licenseTermsPrivacyRefundsMap data © OpenStreetMap contributors · OpenFreeMap
Library/Time and trips

Time and trip models

Pure logistics models: trips (a shipment's legs, hubs and stops, or an own-fleet route) placed along the road with fix age and dead reckoning; the event field's binning and typical band; the bar's zoom and pan window; split rows; in-transit Gantt rows; the impact line's layout; week stepping.

Free · MITLibrary@highcommand/time-lib12 files
See it in context
Route AUS-14 · V-11215:00 CST
D1234567R
Along11.0 of 34.9 kmLast fix0 s agoPositionat the stopSpeedstopped
  • 2201 Speedway · Summit Auto PartsAt the stopplan 14:35 · expected 14:47 · window 14:05–15:35
  • 2100 Barton Springs Rd · Bluestem PackagingLateplan 15:16 · expected 15:30 · window 14:46–16:16
  • 1500 S Congress Ave · Orion Retail GroupOn timeplan 15:46 · expected 16:07 · window 15:16–16:46

routeTrip() builds the stations and the line; estimateOn() moves the van on from its last fix at its last speed, never past the next stop. Drop the tracker to watch the estimate take over.

Installation

$ npx shadcn@latest add @highcommand/time-lib

Copies the source into your project and pulls in what it needs (3 other items). First time? Add the registry to components.json.

API

75 functions
  • pathOf(line: readonly LngLat[]): RoadPath

    The line with its distances, made once per line (the same array is the same road).

  • estimateM(fixM: number, fixAt: number, speedKmh: number | null | undefined, nowMs: number, capM: number): number

    Metres along the line at `nowMs` for a thing fixed at `fixM` at `fixAt`, moving at `speedKmh`: on at that speed, never past `capM`.

  • fixAge(fixAt: number, nowMs: number, gapS: number): FixAge

    How stale a position fix is: seconds since `fixAt` at `nowMs` (ms), and, once that passes twice `gapS` (the usual seconds between fixes), whether to treat the position as an estimate and how wide to draw the doubt ring.

  • capAhead(stopsM: readonly number[], m: number, total: number): number

    The first of the stops' distances ahead of `m` (more than 1 m on), else the end of the line.

  • locate(line: readonly LngLat[], fix: { lng: number; lat: number; at: number; speedKmh?: number | null | undefined; }, nowMs: number, opts?: { stopsM?: readonly number[] | undefined; fromM?: number | undefined; toM?: number | …

    Where a thing is now on its line: its fix snapped onto the line (searched between `fromM` and `toM`, so a road that passes the same place twice snaps to the right pass), then moved on. A fix farther than `offM` from the line is drawn where it was reported and not moved.

  • glide(from: LngLat, to: LngLat, t0: number, t: number, durMs?: number): LngLat

    A marker easing from where it was drawn to where it is now, over `durMs` of wall time from `t0` (ease out).

  • freightGapS(mode: string): number

    A carrier's fixes when a load has too few to tell (the simulator's and typical ELD cadence; ocean hourly).

  • nearestPlace(places: readonly { name: string; lat: number; lng: number; }[], lat: number, lng: number, maxKm?: number): string | null

    "Memphis": the place nearest to a point among `places`, within `maxKm` (pass it as `nameOf` to name hubs and stops on the way).

  • shipmentTrip(d: ShipmentDetail, opts?: { roads?: Roads | null | undefined; positions?: LoadPositions | null | undefined; live?: TripFix | null | undefined; nameOf?: ((lat: number, lng: number) => string | null) | undefined; }): Trip

    A shipment's trip: each leg on its stored road (else its arc), the origin, the hubs it was seen arriving at and leaving on the way (the tracking events), the stops its positions show (standing still half an hour or more), the transfers between legs and the destination.

  • routeTrip(d: FleetRouteDetail, live?: { lat: number; lng: number; at: string; speed_kmh: number | null; } | null | undefined, opts?: { missed?: ((s: FleetStop) => boolean) | undefined; }): Trip

    An own-fleet route's trip: the depot, every stop in order on the route's planned path, the return; the vehicle's last fix.

  • estimateOn(t: Trip, nowMs: number | null): { m: number; p: LngLat; age: FixAge; } | null

    Where the thing is now along its trip: moved on from its last fix at its last speed, never past the next station, still while it is at one; the point on the line, and how old the fix is. Null without a fix.

  • legLine(a: LngLat, b: LngLat, roads?: Roads | null | undefined): LngLat[]

    One leg as drawn: on its stored road when there is one, else straight between its ends.

  • stopsM(t: Trip): number[]

    The stations' distances, for the estimate's cap: the next one is as far as a thing under way is ever drawn.

  • describeEvent(e: DomainMessage): { text: string; tone: StatusColor; }

    Plain-language one-liner for a domain event, and the status tone its tick takes. Never invents facts: it only rewords the type and quotes the payload's reason.

  • subjectLabel(e: DomainMessage): string

    A human name for an event's first subject, never its internal id: the finding class of an exception, the action of a decision, a number the payload carries, else the record type.

  • eventTimeTitle(e: Pick<DomainMessage, "occurred_at" | "recorded_at">, timeZone?: string | undefined): string

    An activity row's tooltip: the event's simulated time to the second and when it was actually recorded (real time). Events recorded while the simulated clock is paused all carry the paused instant (every row read "19:00 CDT"); the real time tells them apart.

  • binField(opts: { start: number; end: number; step?: number | undefined; density: Density | null; live: readonly { at: number; id: string; type: string; }[]; marked: readonly { at: number; id: string; tone: string; type: string;…

    The field for [start, end): the server's counts where they reach, then every live event after the server's window. `marked` are the events that need a person (the timeline's ticks): they add their status to their bin, never their count (the count already holds them when the server counted the minute; live ones are counted from `live`).

  • ceilingOf(bins: Bin[]): number

    The ceiling bars are drawn against: the 98th percentile, so one spike never flattens the rest (it is clipped, with a break mark).

  • typicalBand(bins: readonly Bin[], window?: number): Band

    Rolling typical range of the events-a-minute counts: for each bin the lower quartile, median and upper quartile of the `window` bins around it (default 60).

  • focusSpan(binPx: number, minPx?: number): number

    How many bins one focus column spans: at least `minPx` wide on screen, in whole 1, 5, 15 or 60 minute steps.

  • readout(bins: Bin[], first: number, span: number, band: Band, step?: number): FocusReadout | null

    What a focused column says: its minutes, every event in them, the ones that need a person by status, and what is typical there (the band's interquartile range over the column's minutes: the lowest lower quartile to the highest upper one).

  • recentRate(bins: readonly { t: number; n: number; }[], now: number, step: number, windowMs?: number): number

    Events a minute over the last `windowMs` before `now`, on bins of `step`: every bin that overlaps the window counts whole, over the minutes those bins cover up to now (a 30- or 60-minute bin is never cut to 15 minutes, nor read as empty because it started earlier).

  • dueTrackOf(kind: string, status: string, by: string): string | null

    The track a due item belongs to (each track's future side holds only its own items): by area, delivery windows and pickup cutoffs are Freight's, routes due back Fleet's, payments and invoices Money's (Exceptions has none); by status, late ones the Late track's, at-risk ones the At risk track's, the rest Everything else; by source (or all together) one shared lane: null.

  • dueByTrack(items: readonly { at: string; kind: string; status: string; }[], keys: readonly string[], by: string, now: number, slots: number): Map<string, TrackDue>

    Each track's due items in `slots` slots of DUE_STEP from `now`: over every track of the grouping, so a track with no event in the window still has its due items; the bar keeps such a track (tracksShown). Items whose track is not one of `keys` are left out (there is none: every due kind maps to a track).

  • dueReadout(items: readonly Due[], now: number, slot: number, step?: number): DueReadout

    What falls due in one slot [now + slot × step, + step): the items in time order, how many are late, and how many of each kind.

  • dueText(r: DueReadout, hhmm: (ms: number) => string): string

    "19:20–19:25 · 3 due · 2 routes due back, 1 delivery window closes · 1 late": a due slot in words (the readout's screen-reader line).

  • rateText(events: number, minutes: number): string | null

    "14.7": events a minute over a column, one decimal, a whole number without it; null for a one-minute or an empty column (its count says it).

  • typicalText(lo: number, hi: number): string

    "3–8", "3", or "quiet" when the typical minute there has no events at all (never "0–0").

  • typicalPhrase(lo: number, hi: number): string

    "typical 3–8 a minute", "typical: quiet".

  • liveOf(evs: DomainMessage[]): { at: number; id: string; type: string; }[]

    The live feed and the marked events in the shape binField takes.

  • tracksShown<R extends { key: string; total: number; }>(rows: readonly R[], due: ReadonlyMap<string, TrackDue> | null): R[]

    The tracks the bar draws: those with events in the window, and those with something due ahead.

  • dueKindText(kind: string, n: number): string

    "2 routes due back", "1 delivery window closes" (the readout's words, mid-sentence).

  • dueKindLabel(kind: string, n?: number): string

    Display name of a due kind ("Delivery window"); plural when n is not 1 (default 1), and unknown kinds are made readable.

  • ticks(evs: DomainMessage[], start: number, span: number, width: number): Tick[]

    One tick per event: its x in px on a window starting at `start` (ms) and `span` ms long across `width` px, with its status, sorted left to right.

  • moments(ts: Tick[], { gapPx, max, charPx, minScore }?: { gapPx?: number | undefined; max?: number | undefined; charPx?: number | undefined; minScore?: number | undefined; }): Moment[]

    The few moments that matter on the bar: events closer than `gapPx` form a burst; a burst earns a headline when it holds a late or exception event or enough at-risk ones. At most `max` headlines, the most serious first, and never two that would overlap.

  • placeLabels(labels: AxisLabel[], width: number, { charPx, gap }?: { charPx?: number | undefined; gap?: number | undefined; }): PlacedLabel[]

    The time row without collisions: labels are placed most important first ("now", then "since you left", then the hours), each kept inside the bar (a centred label slides in from an edge) and dropped, after trying its shorter text, when it would touch one already placed. `x` comes back where the label should be drawn with its own anchor.

  • placeHeadlines(boxes: readonly HeadBox[], width: number, measure: (t: string) => number, { gap, inset }?: { gap?: number | undefined; inset?: number | undefined; }): { placed: Map<string, PlacedHead>; dropped: HeadBox[]; }

    Places headline flags along a row without overlap, most serious first: each shortens to its next text when it collides and is dropped (returned in `dropped`) when no room is left; `gap` and `inset` are in px (8 and 5).

  • tickTimes(start: number, end: number, step: number): number[]

    The time row's instants from `start` to `end` on its step (whole minutes), all on the viewer's local clock: under half a day, every multiple of the step from local midnight (hours read 00:00 06:00 12:00, never UTC's 01:00 07:00, and keep to it across a DST change; a skipped hour's tick lands once on the hour after it); half a day and more, local midnight (and noon).

  • clampWindow(w: TimeWindow, b: TimeBounds): TimeWindow

    The window kept inside its bounds: its length first, then its place (the right edge pulled in, then the left edge out).

  • readStored(raw: string | null, presets: readonly number[]): { span: number; rel: number; } | "shift" | null

    A stored window, read back: "shift" (the fit), a length in ms (the old form, and a live window: it ends at now), or JSON {span, rel}.

  • maxSpan(b: TimeBounds): number

    The longest window the bounds allow.

  • holdsNow(span: number, end: number, now: number): boolean

    Now is inside the window (a pixel's grace either side is the caller's: this is exact).

  • panWindow(w: TimeWindow, b: TimeBounds, dt: number): TimeWindow

    Pan by `dt` ms (positive: later).

  • trackOfSubjects(types: readonly string[]): "money" | "freight" | "exceptions" | "fleet" | null

    The track of the records an event names (their object types): any fleet record makes it Fleet (an own-fleet delivery is the fleet's), else an invoice or a payment makes it Money (a carrier's bill names its load), else any other business record Freight; an account alone is Money (credit, health). Null when it names none of them.

  • hintOf(type: string, payload: unknown): string | null

    What an event says beyond its type that its track needs: a policy change's key, an import's kind.

  • areaOf(type: string, subjects?: readonly string[], hint?: string | null): "money" | "freight" | "exceptions" | "fleet" | null

    The track an event is on (null: none, the simulator's own clock). Exceptions: findings, disputes, notes, and a record that came in flagged or was quarantined. Fleet: routes, stops, drivers, vehicles and their upkeep. Money: invoices, matching, payments, accounts (credit and health). Freight: orders, shipments, loads and legs, tracking, receipts, stock. A decision or its action is on the track of what it decided about (its subjects; the server serves an answer with its proposal's), else on Exceptions; a record that came in, a document or an import row on the track of what it carried; a policy change by its key.

  • sourceOf(actorKind: string): "agent" | "people" | "systems"

    Who acted: the agent, a person, or a system (the simulator standing in for the carriers' and the ERP's feeds, an adapter).

  • fleetRowOf(type: string): "routes" | "vehicles" | "drivers" | "findings" | null

    The part of the fleet an event is about (Fleet's rows; a route's stops are the route's); a finding or a decision is a finding; anything else has no fleet row.

  • rowDefs(by: RowsBy, fleet: boolean): RowDef[]

    The rows of a grouping, in their fixed order (Fleet's "area" is its own four).

  • rowOf(by: "source" | "area", fleet: boolean, e: Pick<DomainMessage, "type" | "actor" | "subjects" | "payload">): string | null

    The row an event falls in (area and source rows; status rows come from the marked events).

  • binRows(o: { start: number; end: number; step: number; density: Density | null; live: readonly DomainMessage[]; marked: readonly Marked[]; by: RowsBy; fleet: boolean; }): Row[]

    The rows for [start, end) on a grid of `step`: each row's bins, and how many events it holds there.

  • layoutRows(collapsed: readonly boolean[], avail: number | null): RowLayout

    Where the tracks go in `avail` px (null: their height at rest). With room to spare (a pop-out window) they grow, up to ROW_MAX; short of room they thin to ROW_MIN, then the last ones hide. A collapsed track is always ROW_MIN.

  • inRow(e: DomainMessage, row: string | null, by: RowsBy | null, fleet: boolean): boolean

    The event falls in the row (null row or grouping: every event does): its area or source row, or its status row by its tone.

  • areaOfEvent(e: { type: string; subjects: readonly { type: string; }[]; payload?: unknown; }): "money" | "freight" | "exceptions" | "fleet" | null

    An event's track, from the event itself.

  • transitGroups(d: InTransit | null): TransitGroup[]

    The groups that have rows: Freight first, then Own fleet (Fleet's bar: routes only).

  • rowGeom(r: TransitRow, start: number, end: number, width: number, now: number): RowGeom

    Where a row's bar, window, stops and now fall in a window [start, end] drawn `width` px wide.

  • whenOf(t: number, now: number): string

    "Oct 18 03:50", or "03:50" on the day of `now`, in local time.

  • rowText(r: TransitRow, now: number): string

    The row in words (its tooltip and accessible name).

  • statusText(r: TransitRow): string

    The row's status in words with how late: "late · 2 h 00 m late" (its ETA after its window), "at risk · 5 min behind", "on track".

  • windowText(w: [number, number], now: number): string

    A delivery window in the table and its words: "13:30–14:30" today, "Oct 10 17:16–22:16" on another day.

  • lateSpan(ms: number): string

    "2 h 00 m", "45 min": how late, in the table's words.

  • tripStops(trip: Trip, nowMs: number | null, own?: boolean): LineStop[]

    The trip's stops: a shipment's departure, the hubs and stops it was seen at, the transfers, its arrival with its window; an own-fleet route's depot, stops and return. "Now" sits on the stretch it is on while it is under way, with the distance left to the next stop.

  • extentOf(stops: readonly LineStop[]): [number, number] | null

    The extent of a line: its first and last moment, bands included.

  • fitWindow(ext: [number, number]): { start: number; end: number; }

    The window that frames a line, with a margin either side (never shorter than an hour).

  • layoutLine(stops: readonly LineStop[], start: number, end: number, width: number, measure?: Measure | undefined): LineLayout

    The line in a window `width` px wide over [start, end]: each stop in view at its time, the labels on two rows by priority (none touching, none past the edges or under an edge marker; a stop with no room, or a quiet one, keeps its mark and its name in the tooltip), the nearest stop either side of the window as its edge marker, with how many more lie that way.

  • whenText(ms: number, nowMs: number, tz?: string | undefined): string

    "Nov 15", or "Mon 06:10" within a week of now, or "06:10" today: how an edge marker says when. In `tz` (the company's zone) when given, else the browser's.

  • dayAt(ymd: string | null | undefined): number

    A business day (an invoice date, a due date) is placed at its local noon: inside its day at any zoom.

  • labelW(s: LineStop, measure?: Measure): number

    Width in px of a stop's label (name, record or amount, icon and gaps), at most 260; `measure` defaults to a character-count estimate.

  • absenceWindow(sinceLeft: string | null, nowIso: string): AbsenceWindow

    The window "since you left" shows and plays back: from the previous visit to `nowIso`, but never longer than the last 24 simulated hours. At 60x a 25-minute break is already longer than that, so the strip says when the window was cut (`clamped`).

  • sinceLabel(basis: "default" | "last_visit" | "clamped", clock: string): string

    The label at the strip's left edge: how its window was chosen, and where it starts (`clock`, in the viewer's zone).

  • cursorBanner(w: number, weeks: readonly { week_start: string; iso_week: number; }[]): string | null

    The persistent banner when the cursor is not on this week: the view is a projection, not what the records hold now. Null on today.

  • clampWeek(w: number, n: number): number

    The week cursor: one "as of" week (1 = this week, the horizon's last = 12) that every view reads; stepping or playing it recomputes the views in memory and fetches nothing. Pure.

  • stepWeek(w: number, d: number, n: number): number

    Moves week w by d weeks, kept within 1 to n.

  • playNext(w: number, n: number): number | null

    The next week while playing; null at the end (playing stops there).

  • isToday(w: number): boolean

    True when the cursor is on this week (week 1).

Dependencies

npm
None beyond React
Builds on
ThemeUI primitivesShared helpers
Used by
Time control
Pro pieces built on this
Event field ProIn-transit rows ProImpact line ProActivity bar ProPlayback overlay ProTrip timetable ProWeek cursor ProCommand center ProFleet ProCustomer tracking Pro

Install this free piece now; the Pro pieces drop in on top of it, in the same app. Pro is $79 once.

PreviousMap kitNext Event field

On this page

PreviewInstallationAPIDependencies