ml-time-graph 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -19,6 +19,89 @@ release notes, and every change is in `git log` in full.
19
19
 
20
20
  ---
21
21
 
22
+ ## [1.17.0] - 2026-10-07
23
+
24
+ ### Added
25
+ - **`ml-time-graph-svelte`** — new package, same version: `<TimeGraph>` (container width,
26
+ `autoMargin`, tooltip over `pointsAt` and by keyboard, hiding, zoom, `syncTime` for
27
+ dashboards, dark mode and `--mtg-*` CSS variables, light print, SVG/PNG export, loading and
28
+ empty states, value table for screen readers, SSR) and `<Legend>` (buttons, swatches in the
29
+ line's dash, width and marker). App-wide defaults (`setTimeGraphDefaults`: locale, time zone,
30
+ formats, texts, scheme), translatable `labels`, `formatValue`, `followEnd` for live data,
31
+ `printHidden`. Manual: the package README and handbook chapter 7.
32
+ - **`gaps.atEnd`** (TS and Go) — a device that went quiet gets a hatched region from its last
33
+ reading to now (`now` or the end of the time axis), when that is longer than `afterMs`.
34
+ Label with `{since}` / `{duration}` placeholders (TS also a function); per series
35
+ `gaps: { atEnd: false | { afterMs } }`.
36
+ - **`where` on a fill region** (TS and Go) — fill only where the two edges are more than
37
+ `exceeds` apart (`side`, `maxAgeMs`). Decided on the readings (straight / held), drawn
38
+ between the drawn curves; `warnings()` flags catmull-rom and akima, which can overshoot.
39
+ - **`axisGroups(items)`** (TS) — suggests which series share a value axis: same unit and
40
+ nearby ranges together, distant ranges apart. Returns `yAxisIndex` per series and `axes.y`.
41
+ - **`analyze.ComputeLimitExcursions` (Go)** — the Go counterpart of `computeLimitExcursions`:
42
+ episodes outside `[low, high]` and the time above/below, so screen and PDF report the same
43
+ duration. One shared fixture tests both.
44
+
45
+ ### Changed
46
+ - **Go rejects unknown and missing fields in options JSON** (server, CLI, `LoadOptions`, PDF) —
47
+ an error with the JSON path and the nearest correct name (`thresholds[0].lnie: unknown field
48
+ (did you mean "line"?)`), and `name`/`data` are required. TypeScript-only theme fields
49
+ (tooltip, minimap) are accepted. Before, a typo was silently ignored. Three test templates
50
+ carried such dead fields; the `thresholds_demo` label positions now actually apply.
51
+ - **Handbook** — demos appear as preview images that open the live demo instead of iframes;
52
+ new sections for the features of 1.13–1.17 and a chapter on the Svelte package.
53
+
54
+ ### Fixed
55
+ - **Several charts on one page wrote the same ids** (`series-pump` five times) — invalid HTML,
56
+ and `getElementById` found the wrong chart. New `idPrefix` option (TS and Go) prefixes every
57
+ id, and `SVGRenderer({ idPrefix })` / `SetIDPrefix` the `<defs>` ids; the Svelte component
58
+ sets one per instance.
59
+ - **Value axes around 1000 labelled several ticks "1.0k"** (a pressure axis 995–1030 hPa) —
60
+ the default format shortens to k/M only when the tick step allows it (k from a step of 100);
61
+ otherwise the number is written out: 1000, 1010, 1030.
62
+ - **The type declarations carried two different `SeriesStyle` interfaces** — go-to-definition
63
+ could land on the internal, flat one. It is now `FlatSeriesStyle` (as in Go); the public
64
+ `SeriesStyle` is unchanged.
65
+ - **Markers of a series with gaps repeated their ids** (TS) — numbered per run, so every gap
66
+ restarted at `-marker-0` and the ids differed from Go's. Now one marker group per series,
67
+ numbered across all runs, as in Go.
68
+ - **A gap/highlight label with `rotate: 'auto'` that fits neither across nor upright is left
69
+ out** (TS and Go) — in a small chart it stuck out over the axes, and `autoMargin` made room
70
+ for it until the plot area was gone.
71
+ - **Go measured range labels at the legend font size** for `rotate: 'auto'` — a 10 px gap label
72
+ near the limit turned in Go but not in TS.
73
+
74
+ ## [1.16.0] - 2026-10-07
75
+
76
+ ### Added
77
+ - **`theme` per chart** (TS and Go JSON options) — this chart's colours over the global defaults,
78
+ without `setDefaultTheme`.
79
+ - **`legendItems()`: `seriesId` and `width`** — the key for `hidden`/`pointsAt` (the existing `id`
80
+ is its CSS slug) and the drawn line width, so `resolveDash(line, width)` matches the curve.
81
+ - **`zeigerImSvg(svg, clientX, clientY)`** — pointer to SVG coordinates at any scaling; used by
82
+ the built-in tooltip.
83
+ - **`includeThresholds` on a y axis** (TS and Go) — the automatic domain also covers the
84
+ thresholds drawn on that axis; `line: 'none'` ones do not count, an explicit `domain` wins.
85
+
86
+ ### Changed
87
+ - **`Theme` has ordinary field types** (`string`, `number`) instead of literal types —
88
+ `setDefaultTheme({ textColor: '#94a3b8' })` needs no cast.
89
+
90
+ ### Fixed
91
+ - **The built-in tooltip (`attachTooltip`, `tooltip: { show: true }`) showed the wrong value on
92
+ step lines.** It searched the nearest sample by itself; it now goes through `pointsAt` — a step
93
+ line holds its value, enum series show their state. Samples carry `held`, `label` and the full
94
+ `point`; `points` passes options on; the header shows the cursor's time.
95
+ - **Fill region between series on different y axes** — the other series' edge was mapped with
96
+ this series' scale and missed its line; each edge now uses the scale of its own line.
97
+ - **Fill region to a step series** ramped into each jump instead of following the vertical;
98
+ the area now takes both values at the jump.
99
+ - **`legend: { position: 'below' }` covered the x-axis title** — both sat at the bottom edge;
100
+ the title now sits above the legend.
101
+ - **A grid line covered a threshold line at the same height** (in PDF completely) — the grid is
102
+ drawn after the series, thresholds before. The grid now leaves out lines under drawn thresholds.
103
+ - **Go wrote a tick at zero as `-0`** when the domain was padded below zero; now `0`, as in TS.
104
+
22
105
  ## [1.15.0] - 2026-10-07
23
106
 
24
107
  ### Added
package/README.de.md CHANGED
@@ -158,32 +158,6 @@ Sowohl die TypeScript- als auch die Go-Bibliothek:
158
158
 
159
159
  ---
160
160
 
161
- ## 🔭 Ausblick: kleinere SVGs
162
-
163
- Ein Diagramm trägt mehr Bytes mit sich, als es müsste. Gemessen an allen 41
164
- Vergleichsdiagrammen (234 KB): **36 % der Ausgabe sind Darstellungsattribute** — `stroke` an
165
- 1282 Elementen, `stroke-width` an 1256, `fill` an 973, jedes an jedem Kind wiederholt.
166
-
167
- SVG vererbt die meisten davon. Einmal an der `<g>` statt an jedem Kind, und dieselben Bilder
168
- werden **15,9 % kleiner — 37,2 KB**.
169
-
170
- Zwei Dinge, die naheliegen und nicht stimmen:
171
-
172
- - **Es ist keine CSS-Sache.** Kein `<style>`-Block, keine Klassenregeln, kein Präfix. Ein
173
- `<style>`-Block spräche etwa dieselbe Ersparnis, brächte aber drei Probleme mit: zwei Diagramme
174
- auf einer Seite gerieten sich über dieselben Regeln in die Quere, unsere Regeln konkurrierten
175
- mit dem Stilblatt des Aufrufers (heute schlägt jede seiner Regeln ein Darstellungsattribut),
176
- und erst dadurch bräuchten ids und Klassen einen Namensraum. Reine Vererbung hat nichts davon.
177
- - **Es sind keine 23 %.** Alles hochzuziehen ergäbe das, änderte aber das Bild: 579
178
- `<text>`-Elemente stehen in Gruppen mit Linien, und ein `stroke` an der Gruppe gäbe den
179
- Achsenbeschriftungen eine Kontur — Text ist gefüllt, nicht umrandet. Ein Attribut darf nur
180
- hoch, wenn jedes Kind ohne dieses Attribut davon wirklich unberührt bleibt. Diese Regel lässt
181
- 15,9 % übrig.
182
-
183
- Es greift in die Ausgabe jedes Diagramms ein, ist also nichts für eine Patch-Fassung.
184
-
185
- ---
186
-
187
161
  ## 🐞 Fehler gefunden?
188
162
 
189
163
  Issues liegen unter
@@ -304,11 +278,13 @@ ein Bildschirm oder ein Drucker auflöst — 0,001 px sind bei 300 dpi drei Taus
304
278
  Punktes — und es ist der Grund für die kleinen Dateien: ungekürzt brauchte dasselbe Diagramm
305
279
  921 KB.
306
280
 
307
- ## Ausblick / in Überlegung
281
+ ## Früher in Überlegung
308
282
 
309
- - svelte wrapper
283
+ Offen ist gerade nichts. Drei Punkte von hier sind erledigt und stehen jetzt woanders:
310
284
 
311
- Zwei Punkte von hier sind erledigt und stehen jetzt woanders:
285
+ - **Svelte-Wrapper** → [`ml-time-graph-svelte`](https://www.npmjs.com/package/ml-time-graph-svelte),
286
+ dieselbe Fassung wie dieses Paket; Anleitung in Kapitel 7 des
287
+ [Handbuchs](https://mlcgo.eu/books/mlctimegraph/).
312
288
 
313
289
  - **Woher kommen meine Daten?** → `toSeries` / `toDataPoints`, siehe oben beim Quickstart.
314
290
  - **„Live"-Darstellung** → `setData()` auf einer bestehenden Instanz, neu zeichnen, fertig.
package/README.md CHANGED
@@ -158,31 +158,6 @@ Both the TypeScript and Go libraries:
158
158
 
159
159
  ---
160
160
 
161
- ## 🔭 Outlook: smaller SVGs
162
-
163
- A chart's SVG carries more bytes than it needs to. Measured across all 41 reference charts
164
- (234 KB): **36 % of the output is presentation attributes** — `stroke` on 1282 elements,
165
- `stroke-width` on 1256, `fill` on 973, and so on, each one repeated on every child.
166
-
167
- SVG inherits most of them. Written once on the `<g>` instead of on every child, the same
168
- pictures come out **15.9 % smaller — 37.2 KB**.
169
-
170
- Two things that sound right and are not:
171
-
172
- - **It is not a CSS feature.** No `<style>` block, no class rules, no prefix. A `<style>` block
173
- would save about as much and bring three problems with it: two charts on one page would fight
174
- over the same rules, our rules would start competing with the caller's stylesheet (today every
175
- caller rule wins over a presentation attribute), and only then would ids and classes need
176
- namespacing. Plain inheritance has none of that.
177
- - **It is not 23 %.** Lifting everything would be, but it would change the picture: 579 `<text>`
178
- elements sit in groups with lines, and moving `stroke` up would give axis labels an outline —
179
- text is filled, not stroked. An attribute may only move up when every child without it is
180
- genuinely unaffected. That rule is what leaves 15.9 %.
181
-
182
- It touches the output of every chart, so it is not a patch release.
183
-
184
- ---
185
-
186
161
  ## 🐞 Found a bug?
187
162
 
188
163
  Issues live at
@@ -298,11 +273,13 @@ Coordinates are written with three decimals. That is far beyond what any screen
298
273
  resolves — 0.001 px is three thousandths of a point at 300 dpi — and it is what keeps the
299
274
  files small: written in full, that same chart took 921 KB.
300
275
 
301
- ## Outlook / under consideration
276
+ ## Formerly under consideration
302
277
 
303
- - Svelte wrapper
278
+ Nothing is open right now. Three items that used to sit here are done, and live elsewhere now:
304
279
 
305
- Two items that used to sit here are done, and live elsewhere now:
280
+ - **Svelte wrapper** → [`ml-time-graph-svelte`](https://www.npmjs.com/package/ml-time-graph-svelte),
281
+ same version as this package; manual in chapter 7 of the
282
+ [handbook](https://mlcgo.eu/books/mlctimegraph/).
306
283
 
307
284
  - **Where does my data come from?** → `toSeries` / `toDataPoints`, see the Quickstart above.
308
285
  - **"Live" rendering** → `setData()` on an existing instance, then re-render. No second chart,
package/USAGE.md CHANGED
@@ -346,6 +346,33 @@ style: { fill: { regions: [
346
346
  ] } }
347
347
  ```
348
348
 
349
+ #### Only where two lines disagree — `where`
350
+
351
+ Two sensors that should read the same — top and bottom of a fridge — are two lines. The
352
+ stretch where they drift apart is the actual message, and `where` marks exactly that:
353
+
354
+ ```ts
355
+ { name: 'Top', data: top, style: { fill: { regions: [{
356
+ from: 'series', to: { series: 'Bottom' },
357
+ where: { exceeds: 2, maxAgeMs: 30 * 60_000 }, // |Bottom − Top| > 2, readings ≤ 30 min old
358
+ fill: { color: '#ef444433', hatch: 'classic-diagonal' },
359
+ }] } } },
360
+ { name: 'Bottom', data: bottom, style: { line: { shape: 'step' } } }, // reports on change only
361
+ ```
362
+
363
+ - **Strictly greater:** exactly `exceeds` apart counts as agreeing.
364
+ - `side: 'above'` / `'below'` — only where `to` lies more than `exceeds` above / below
365
+ `from`; default `'both'`.
366
+ - `maxAgeMs` — where one side's last reading is older, there is no statement and no area
367
+ (as `holdAlign` does). A gap ends the area.
368
+ - **Decided on the readings, drawn on the lines.** The windows are found on the readings
369
+ joined by straight lines — a step holds its value and jumps at the timestamp, the same
370
+ basis as `divergenceExcursions`. The area itself is the usual one between the *drawn*
371
+ curves, clipped to those windows with vertical edges. A sensor that reports on change
372
+ should therefore be drawn as a step: then line and decision agree exactly.
373
+ - Smoothed lines work. `monotone` stays within the readings, so the edges sit on the line;
374
+ `catmull-rom` and `akima` can overshoot, and `warnings()` says so.
375
+
349
376
  ## Legend
350
377
 
351
378
  ```ts
@@ -462,6 +489,26 @@ and it is the default: a filled area down to the baseline would otherwise swallo
462
489
  Set `grid: { ..., layer: 'back' }` when you want exactly that — the grid behind the data, covered
463
490
  by an opaque fill. Markers, annotations and labels come after the grid in both cases.
464
491
 
492
+ ### Which series share an axis — `axisGroups`
493
+
494
+ Grouping by unit alone is wrong for multi-channel devices: −75 °C, 5 °C and 23 °C on one
495
+ 80 K scale flatten the two warmer curves into lines. One axis per series is the opposite
496
+ mistake: three fridges at 2–8 °C on three scales. `axisGroups` suggests the middle — same
497
+ unit **and** nearby ranges share an axis; a gap larger than the larger range gets its own:
498
+
499
+ ```ts
500
+ import { axisGroups } from 'ml-time-graph';
501
+
502
+ const { indices, axes } = axisGroups(probes.map((p) => ({ unit: p.unit, data: p.data })));
503
+ new MLTimeGraph({
504
+ series: probes.map((p, i) => ({ name: p.name, data: p.data, yAxisIndex: indices[i] })),
505
+ axes: { y: axes }, // [{ position: 'left', label: '°C' }, { position: 'right', … }]
506
+ });
507
+ ```
508
+
509
+ A pure function — nothing is applied for you, and the input order is kept so axes do not jump
510
+ when a series is added. Pass `min`/`max` instead of `data` when you know them.
511
+
465
512
  ### Room at the edge — `padding`
466
513
 
467
514
  The computed domain ends exactly at the smallest and largest reading, and the plot
@@ -480,6 +527,42 @@ widest stroke plus a little is a good rule of thumb. An explicit `domain` is lef
480
527
  alone, and padding that does not fit the chart height is ignored rather than
481
528
  producing an inverted scale.
482
529
 
530
+ ### Thresholds in view — `includeThresholds`
531
+
532
+ The automatic domain follows the readings only. A limit at 10 °C next to readings of 2..7 °C
533
+ lies outside the chart and is clipped away — exactly the line the chart should show.
534
+ `includeThresholds` widens the domain to the thresholds drawn on that axis:
535
+
536
+ ```ts
537
+ axes: { left: { includeThresholds: true, padding: 8 } }
538
+ thresholds: [
539
+ { name: 'max', value: 10 }, // counts
540
+ { name: 'min', value: 0, line: 'solid' }, // counts
541
+ { name: 'ref', value: 20, line: 'none' }, // label/band only -- does not count
542
+ ]
543
+ ```
544
+
545
+ Only thresholds with `axisIndex` of that axis count, and only those that draw a line.
546
+ `padding` applies on top. An explicit `domain` is left alone. Off by default.
547
+
548
+ ### Colours per chart — `theme`
549
+
550
+ `theme` in the options sets this chart's colours and sizes over the global defaults — a dark
551
+ chart next to a light one, or a light redraw for printing, without touching global state:
552
+
553
+ ```ts
554
+ const dark = { textColor: '#94a3b8', axisColor: '#475569', gridStroke: '#334155', legendText: '#cbd5e1' };
555
+ new MLTimeGraph({ ...options, theme: isDark ? dark : undefined });
556
+ ```
557
+
558
+ `setDefaultTheme(partial)` still changes the default for every chart (avoid it in a server
559
+ rendering several requests at once). The field names are the same as in the Go port's JSON
560
+ options; fields only the browser knows (`tooltip*`, `minimap*`) are ignored there.
561
+
562
+ To turn a pointer event into the SVG pixels that `pointsAt`, `invertTime` and `plotRect` speak,
563
+ use `zeigerImSvg(svg, e.clientX, e.clientY)` — correct at any scaling, `viewBox` or CSS
564
+ transform.
565
+
483
566
  ### Margins that fit — `autoMargin`
484
567
 
485
568
  The chart draws into fixed margins. When they are too narrow, labels are cut, and a cut number
@@ -725,6 +808,38 @@ band. And a gap band's default fill is white at 15% opacity, which is
725
808
  invisible on a white chart; `style: 'dashed_border'` draws the edges you can
726
809
  actually see, or give the region its own `fill`.
727
810
 
811
+ ### A device that went quiet — `gaps.atEnd`
812
+
813
+ A line that simply ends says nothing; in monitoring, a sensor that stopped reporting is the
814
+ most important news on the screen. `gaps.atEnd` marks it: when a series' last reading lies
815
+ more than `afterMs` before *now*, a hatched region runs from that reading to now.
816
+
817
+ ```ts
818
+ gaps: {
819
+ atEnd: {
820
+ afterMs: 30 * 60_000, // the device's "no data" threshold
821
+ label: 'keine Daten seit {since} ({duration})', // -> "keine Daten seit 14:32 (38 min)"
822
+ // now: Date.now(), // default: end of the time axis
823
+ },
824
+ },
825
+ series: [
826
+ { name: 'Fridge', data },
827
+ { name: 'Door', data: door, gaps: { atEnd: false } }, // reports on change only
828
+ { name: 'Freezer', data: freezer, gaps: { atEnd: { afterMs: 3_600_000 } } }, // own threshold
829
+ ]
830
+ ```
831
+
832
+ - **Now** is passed in or is the end of the time axis — the library reads no clock, so
833
+ screen, PDF and tests agree.
834
+ - **Strictly greater:** exactly `afterMs` old is not an outage yet. A series with no reading
835
+ in the window gets no region; series that went quiet at the same moment share one.
836
+ - **Text:** none unless you give one. `{since}` is the time in the chart's format (`locale`,
837
+ `timeZone`), with the date when it was another day than now; `{duration}` is
838
+ language-neutral (`45 min`, `3 h 12 min`, `2 d 4 h`). In TypeScript `label` can also be
839
+ `(sinceMs, durationMs) => string`; JSON (Go) takes the placeholder string.
840
+ - **Look:** hatched with dashed edges, the label turns when it does not fit. `atEnd.style`
841
+ changes it; the chart-wide `gaps.style` does not apply here (its `band` does).
842
+
728
843
  ## Statistic overlays
729
844
 
730
845
  Computed at render time from the series' raw data; each overlay has its own
@@ -884,9 +999,10 @@ const { x, y } = chart.project(time, value, axis); // data → pixel
884
999
 
885
1000
  ### Tooltips — `attachTooltip` (built-in)
886
1001
 
887
- One line wires a DOM tooltip that snaps to the nearest sample per series, draws a
888
- "pick" ring on each matched point, and **flips across the cursor to stay inside
889
- the chart** (right/below in the left/top half, left/above past 50%):
1002
+ One line wires a DOM tooltip that shows, per series, the value its line shows at the
1003
+ cursor — found by [`pointsAt`](#points-under-the-pointer--pointsat-your-own-tooltip), so a
1004
+ step line holds its value — draws a "pick" ring on each matched point, and **flips across
1005
+ the cursor to stay inside the chart** (right/below in the left/top half, left/above past 50%):
890
1006
 
891
1007
  ```ts
892
1008
  import { mount, attachTooltip } from 'ml-time-graph';
@@ -903,10 +1019,14 @@ detach(); // removes the listeners + pick markers
903
1019
 
904
1020
  `attachTooltip(target, chart, options?)` returns a cleanup function. The `target`
905
1021
  must already contain the rendered `<svg>` (mount / render first). Each hover
906
- yields one `TooltipSample` per series — `{ seriesIndex, series, time, value, x, y }`.
907
-
908
- Options: `format` (HTML; default = time header + `name: value` rows),
909
- `snapRadius` (px, default ∞), `className` (default `mlc-tooltip`), and
1022
+ yields one `TooltipSample` per series — `{ seriesIndex, series, time, value, x, y, held?,
1023
+ label?, point }` (`point` is the full `pointsAt` hit) — and the cursor's time:
1024
+ `format(samples, { time })`.
1025
+
1026
+ Options: `format` (HTML; default = the cursor's time as header + `name: value` rows, the
1027
+ value as the axis writes it, a held value with its measuring time), `snapRadius` (px,
1028
+ default ∞), `points` (passed on to `pointsAt`: `mode`, `modes`, `maxAgeMs`, `overlays`,
1029
+ `hidden`), `className` (default `mlc-tooltip`), and
910
1030
  `showPicks` / `pickRadius` / `picksClassName` for the markers. Style the box via
911
1031
  the `.mlc-tooltip` CSS class — **don't set `transform`**; placement (incl. the
912
1032
  flip) is computed in JS.
@@ -962,6 +1082,26 @@ interaction in your app, or pull the optional `Zoom` / `Minimap` helpers from th
962
1082
  [`ml-time-graph/interaction`](#package-exports) subpath. See the demo gallery's
963
1083
  "Fridge" (range slider) and "Interaction" pages.
964
1084
 
1085
+ ### In Svelte — `ml-time-graph-svelte`
1086
+
1087
+ Everything in this section — width from the container, `autoMargin`, a tooltip over
1088
+ `pointsAt`, `zeigerImSvg`, a clickable legend, dark mode through `theme`, print, export —
1089
+ comes ready-made as a Svelte 5 component:
1090
+
1091
+ ```svelte
1092
+ <script lang="ts">
1093
+ import { TimeGraph, Legend } from "ml-time-graph-svelte";
1094
+ let hidden = $state(new Set<string>());
1095
+ let legend = $state([]);
1096
+ </script>
1097
+
1098
+ <Legend items={legend} bind:hidden />
1099
+ <TimeGraph {options} height={260} zoomable bind:hidden bind:legend />
1100
+ ```
1101
+
1102
+ `options` are exactly the options described here. The component's README is its manual;
1103
+ the demo pages `svelte.html` and `svelte_dashboard.html` show every feature with source.
1104
+
965
1105
  ## Server-side rendering (Node)
966
1106
 
967
1107
  `SVGRenderer` needs no DOM, so the same code runs in Node — set explicit
@@ -1086,6 +1226,20 @@ build `.series--${slugify(name)}` from a name you hold.
1086
1226
  Reach for the `id` when there is one chart in the document, or when you have scoped the
1087
1227
  lookup yourself (`container.querySelector('#…')` rather than `document.getElementById`).
1088
1228
 
1229
+ **`idPrefix` removes the collision.** Give each chart on a page its own prefix, and pass the
1230
+ same one to the renderer so the `<defs>` (clip paths, hatch patterns, shadows) are covered
1231
+ too:
1232
+
1233
+ ```ts
1234
+ const chart = new MLTimeGraph({ ...options, idPrefix: 'fridge-2' });
1235
+ const svg = new SVGRenderer({ idPrefix: 'fridge-2' }).render(chart.renderCommands()).content;
1236
+ // → id="fridge-2-series-temperature", id="fridge-2-clip-plot-…"; classes unchanged
1237
+ ```
1238
+
1239
+ The prefix is stable as long as you pass the same one — do not generate it per render. The
1240
+ Go port takes the same `idPrefix` in its JSON options (server and CLI apply it to the defs
1241
+ as well). `ml-time-graph-svelte` gives every `<TimeGraph>` its own prefix automatically.
1242
+
1089
1243
  ### Provenance
1090
1244
 
1091
1245
  Every SVG names the library and version that drew it, as the first child of the root: