Recipe: an event log
A day of service events, fetched window by window from a server as the view moves, in lanes by severity, and merged into counted markers where they crowd. Zoom with ctrl + wheel (or + and -) and pan: the line below the timeline counts the requests.
Live example: An event log, fetched by window and clustered
Loading…
Run “An event log, fetched by window and clustered” on your own machine
Make an empty folder and put this example’s two files in it:
index.html— the page the code runs in, its markup and styles:<style> #timeline .level-warn { --tl-item-fill: #ffe08a; } #timeline .level-error { --tl-item-fill: #ffc9c4; } </style> <div id="timeline" style="height: 300px"></div> <p class="log" id="requests" aria-live="polite">Waiting for the first window…</p>main.js— the code, as it is in the editor now, your edits included:In a terminal in that folder, install the library and Vite (it lets the browser follow the
imports), then start it:npm init -y npm install @temporeum/timeline-element npm install --save-dev vite npx viteOpen the address it prints,
http://localhost:5173/.
How it is made
itemsis a function. The timeline calls it with the window it needs and anAbortSignal, and aborts the request when the view moves on. Zoom in and nothing is asked: the window already held covers it. See async data.- Clusters (
cluster: true) merge events too close to tell apart into one marker with their count; tap it, or focus it and pressEnter, and it opens. See clustering. - Severity is a lane and a class. The error lane is
pinned, so it comes first, at the top, with the pinned lanes' fill; each event's class (level-…) sets its colour. - Limits keep the view between a minute and two days, so the server is never asked for a year.
- No editing: a log is read, so
editingis left off and a drag only pans.
domain: [T0, T0 + 2 * HOUR],
// A log is read, not edited; keep the zoom between a minute and two days.
limits: { minSpanMs: 60 * SECOND, maxSpanMs: 48 * HOUR },From the running example example/recipe-log
Each event is an instant with granularity: "second": it covers its second, so two events in the same second take two rows instead of drawing over each other.