← All components

Timeline

Play, scrub and speed up events over time, with markers and sparklines.

Previews run on MapScale's public Thailand archive.

Install

npx shadcn@latest add https://mapscale.io/r/timeline.json

Usage

import { Timeline } from "@/components/mapscale/timeline"

const [value, setValue] = useState(start)
const [playing, setPlaying] = useState(false)

<Timeline
	start={start}
	end={end}
	value={value}
	onChange={setValue}
	playing={playing}
	onPlayingChange={setPlaying}
	events={[{ time: start + 3 * DAY, label: "First report", color: "#e11d48" }]}
/>

Props

PropTypeDefaultDescription
startnumber-First timestamp (ms).
endnumber-Last timestamp (ms).
valuenumber-Current timestamp (ms). Controlled.
onChange(value) => void-Called while scrubbing or playing.
playingboolean-Whether playback is running. Controlled.
onPlayingChange(playing) => void-Called when play, pause or the end of the range is reached.
speed1 | 2 | 5 | 101Playback multiplier: 1, 2, 5 or 10.
eventsTimelineEvent[]-Ticks on the scrubber: { time, label, color }.
seriesTimelineSeries[]-Optional sparklines: { label, points: [t, v][] }.

Keys

Maps, autocomplete and place details use a publishable pk_ key that is safe in the browser. Routing and isochrones need a secret sk_ key, so they go through the proxy route your app serves.