ml-time-graph 1.7.2 → 1.9.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
@@ -7,6 +7,245 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  Both libraries are released in lockstep on the same version number.
9
9
 
10
+ Note: references like `B-20260922-07` or `I-20260922-03` point into this project's own
11
+ backlog, which is not public — `B-` is a reported defect, `I-` an idea, and the digits are
12
+ the date it was filed plus a counter. They are kept here so that whoever works on the code
13
+ can find the discussion a change came out of. If you are reading from outside, ignore them:
14
+ every entry says on its own what changed and why.
15
+
16
+ Entries here are deliberately short — what changed, whether it affects you. The long form
17
+ of each one, with the measurements and the reasoning, lives in the project's internal
18
+ release notes, and every change is in `git log` in full.
19
+
20
+ ---
21
+
22
+ ## [1.9.0] - 2026-09-23
23
+
24
+ ### Added
25
+ - **`fontFamily`.** Every text now carries an explicit `font-family`; the default stack is
26
+ metric-compatible across Linux, Windows and macOS. Layout is unchanged.
27
+ - **Draw commands over HTTP and from the CLI (Go).** `POST /api/v1/chart/commands` and
28
+ `graph-cli -emit commands` / `-from-commands` hand out the command list both renderers
29
+ work from, so a consumer producing another format need not parse SVG.
30
+
31
+ ### Changed
32
+ - **`autoDetect` breaks the line at the gap it marks, and now sees `value: null`.** Charts
33
+ using `gaps.autoDetect` will look different: the curve no longer runs through the gap.
34
+
35
+ ### Fixed
36
+ - **A series name with an umlaut produced a different chart in Go than in TypeScript** —
37
+ the plot area was offset, and Go turned accented characters into dashes where TypeScript
38
+ folded them. **Check your stylesheets:** `Büro` now yields the class `…--buro`, not
39
+ `…--b-ro`. Pin a name you depend on with `series.id`.
40
+
41
+ ### Removed
42
+ - **The `gradient` draw command**, which neither library ever produced and no option could
43
+ reach. Gone from TypeScript (`DrawGradient`, via `ml-time-graph/internals`) and Go
44
+ (`DrawCommandGradient`, `GradientStop`, `Stops`).
45
+
46
+ ## [1.8.3] - 2026-09-22
47
+
48
+ ### Added
49
+ - **A parity template that combines ten features in one picture.** Of the other 40 templates
50
+ exactly one combines two; the rest test a single feature in isolation, which leaves their
51
+ *interaction* unchecked — the status band reserves height, the outside legend reserves
52
+ width, markers need margin. `combined_report` is an incident report: two series with the
53
+ area between them, a sensor dropout, thresholds, a status band, a marker, an annotation, an
54
+ overlay, a legend and an explicit time zone. Useful as a comparison case for the PDF port,
55
+ which walks the same draw commands.
56
+
57
+ - **`timeZone` — the time axis in a zone you name, not the machine's.** `locale` said *how* a
58
+ time is written, nothing said **which**: both libraries formatted in the machine's zone, so
59
+ a browser and a UTC server labelled the same reading differently. Omitting it keeps the old
60
+ behaviour. Handled by `Intl` / `time.Location`, so DST and half-hour zones are right; the Go
61
+ port embeds `time/tzdata` (+0.4 MB). Unknown names are reported, not ignored. Labels only —
62
+ tick positions never move.
63
+
64
+ - **A fill region can reach another series: `{ series: '<id or name>' }`.** Previously a bound
65
+ could only be its own line, `chartTop` / `chartBottom`, a threshold or a fixed value — so
66
+ "the area between two curves" (tolerance corridor, target vs. actual) had no expression. The
67
+ reference curve is interpolated onto this series' timestamps; where it has a gap, the area
68
+ stops rather than bridging it. Unknown names raise an error.
69
+
70
+ - **Statistic overlays in the Go port, from a public maths package.** `series.overlays` existed
71
+ only in TypeScript. `go-time-graph/pkg/analyze` now exports `RollingMean`, `RollingEma`,
72
+ `RollingStdDev`, `RollingMkt`, `StdDev`, `SampleStdDev` and `Mkt` — public on purpose, so a
73
+ caller who only wants the numbers does not have to draw a chart. Bit-identical to the
74
+ TypeScript originals, verified at 17 significant digits.
75
+
76
+ - **`rollingMean` and `rollingEma` are public (`ml-time-graph/analyze`).** The rolling mean sat
77
+ as a private helper inside the overlay renderer, so an overlay could not be reproduced from
78
+ outside. It can now, and `tests/series/overlay_extern.test.ts` proves the geometry is
79
+ identical — the overlay is a convenience, not a second implementation.
80
+
81
+ - **`movingAverage` with `type: 'exponential'` now computes one.** It was accepted and quietly
82
+ drew the *simple* mean. `rollingEma` weights by elapsed time (`alpha = 1 - exp(-Δt/window)`),
83
+ not by a point count, which is what irregularly sampled sensor data needs. The older
84
+ count-based `MovingAvg.exponential()` is untouched.
85
+
86
+ - **`MovingAvg` is exported** from `ml-time-graph/internals`. It was in the source, in the
87
+ docs, and exported from nowhere — the documented import threw. Note it counts **points**
88
+ while `rollingMean` / `rollingEma` take a window in **milliseconds**.
89
+
90
+ - **`axes.<axis>.padding` — room for a thick line at the edge.** The domain ends exactly at the
91
+ extreme reading and the plot is clipped, so a 10 px line at the maximum lost half its stroke.
92
+ `padding` adds room in **pixels** (a number, or `{ top, bottom }`); an explicit `domain` is
93
+ left alone. Both libraries share the formula, held by `edge_axis_padding`.
94
+
95
+ - **Layered options — `-with` on both CLIs, `mergeOptions` in TypeScript.** Put the repeating
96
+ part of a chart (size, axes, legend, colours) in one file and lay it over the data:
97
+
98
+ ```bash
99
+ graph-cli -in readings.json -with house-theme.json -out chart.svg
100
+ ```
101
+
102
+ One rule: **objects merge, everything else is replaced**, later layer wins. Arrays are
103
+ replaced deliberately — an appending theme would silently turn one curve into two. Both CLIs
104
+ warn when an overlay sets `series`.
105
+
106
+ - **Line and fill paths carry a class, not only an id** — `series-line` and `series-fill`. An
107
+ id is unique per *document*, so two charts on one page collide and `getElementById` returns
108
+ the wrong one. A class can be scoped (`#chart-2 .series--temperature .series-line`) and,
109
+ unlike the crc32 in the id, written down by hand.
110
+
111
+ - **Every SVG says what drew it:** `<!-- MLTimeGraph x.y.z -->` as the first child of the root.
112
+ Identical in both libraries, so the output stays byte-identical, and stripped by the golden
113
+ and parity tests so a release does not churn the comparison files. `VERSION` is exported from
114
+ the package root.
115
+
116
+ - **The SVG's CSS classes and `showAs` are documented.** The classes had been emitted for a
117
+ long time and written down nowhere; `showAs` appeared once, inside a code example.
118
+ `USAGE.md` now carries the full class table with the slug rule, and a section on aggregated
119
+ series. `slugify` is exported so you can build `.series--${slugify(name)}` yourself.
120
+
121
+ - **New demo cards.** *Two sensors compared* and *Tolerance corridor* on the Thresholds page
122
+ show the fill between two curves, each with an `annotationBands` strip naming the incident —
123
+ a sensor dropout, a corridor exit. Under *Main Demos*, the same aggregated data appears three
124
+ ways (`minmaxavg`, three plain series, `band`) with an outside legend, which is where the
125
+ difference shows: one entry against three.
126
+
127
+ - **The marker style block is documented, and the Style Editor exposes it.** `markers.strokeWidth`,
128
+ `stroke`, `fill` and `threshold` have always existed and never inherited `line.width`, but the
129
+ docs showed only `{ type, size }`. Nothing in the library changed.
130
+
131
+ - **The demo gallery uses `padding`** so cards stop showing the defect it fixes. Deliberately
132
+ not a library default: the library draws what the data gives, the air is a presentation
133
+ decision.
134
+
135
+ - **The package describes what it is for.** The npm description and README opened on sensors
136
+ and incident analysis — the origin, not the range. Both now name the data it draws and lead
137
+ with contextual annotation; `keywords` widened to match. No code changed.
138
+
139
+ ### Changed
140
+ - **`display` on a gap means the same thing everywhere.** The four words were read differently
141
+ depending on where they were written — `filled` did not fill, `empty` was not empty, and
142
+ `filled` and `dashed_border` were indistinguishable. From now on, identically on both routes:
143
+
144
+ | `display` | draws |
145
+ | --- | --- |
146
+ | `filled` | the area, no edges |
147
+ | `dashed_border` | the area plus two vertical dashed edges (default) |
148
+ | `empty` | nothing — the label stays |
149
+ | `bridge_line` | the connecting line (per-series only) |
150
+
151
+ **This changes existing charts that set `display`.**
152
+
153
+ - **A gap's label sits where a highlight's does**, from one shared function. `top` / `center` /
154
+ `bottom` sit inside the plot, `above` / `below` in the image margin. The gap's own rule had
155
+ two of three values wrong: `below` sat on the x-axis, `above` ended 1 px outside the SVG.
156
+ `middle` remains valid as the old name for `center`.
157
+
158
+ - **`display: 'dashed_border'` draws the two vertical edges, not a frame.** The top and bottom
159
+ edge of a gap lie on the plot boundary and say nothing; the vertical ones mark where the
160
+ readings stop and start again.
161
+
162
+ - **The Go renderer is five times faster than before this release**, and the SVG files are half
163
+ the size. Coordinates are written with three decimals — far beyond what any output resolves —
164
+ and formatted with integer arithmetic instead of `strconv.AppendFloat`'s shortest-form search,
165
+ which was 54 % of render time.
166
+
167
+ | points | before | after |
168
+ | -----: | -----: | ----: |
169
+ | 5,000 | 10.6 ms | 1.9 ms |
170
+ | 25,000 | 67.7 ms | 13 ms |
171
+ | 50,000 | 149.7 ms | 24 ms |
172
+
173
+ Allocations at 25,000 points fell from 175,796 to ~700: `pathD` fills one pre-sized buffer,
174
+ and `GetRuns` returns windows instead of copies. Output stayed byte-identical throughout —
175
+ that was the condition, and no golden changed. `pkg/chart/bench_test.go` keeps the measurement.
176
+
177
+ Both libraries now funnel every number through one `fnum`; Go replicates JavaScript's
178
+ rounding on purpose, including `-0` and half-away-from-zero, pinned by `runde_test.go`.
179
+
180
+ ### Fixed
181
+ - **Two charts on one page clipped each other.** Every chart wrote `<clipPath id="clip-plot">`,
182
+ and an SVG id is valid across the whole document — so every chart after the first was clipped
183
+ to the first one's rectangle, cutting the top off taller curves. Hatch patterns, shadow
184
+ filters and gradients collided the same way. Every generated `<defs>` id now carries a key
185
+ derived from its content, identically in both libraries. Example images and all 48 handbook
186
+ figures regenerated.
187
+
188
+ - **The same `id` appeared several times in one chart.** TypeScript restarted the line-segment
189
+ counter at every data run; Go gave every piece of a split fill region the same id. The parity
190
+ test could not see it because a normalisation rule **stripped every `id` before comparing** —
191
+ a rule whose reason had disappeared long before. That rule is gone, ids are part of the
192
+ comparison now, and a new test counts duplicates in both libraries (with `xmllint` as an
193
+ independent second opinion where installed).
194
+
195
+ - **The Go port drew no free annotations at all.** `annotations` was read, stored and never
196
+ rendered — a chart that showed an arrow in the browser came back from the server without it.
197
+ It survived because no parity template used `annotations`; the fix therefore started with
198
+ `test_data/annotations_demo.json`, which made the gap visible as 30 missing elements.
199
+
200
+ - **The Go port ignored `series.style.gap`.** Parsed, never read, while TypeScript drew the
201
+ region. Same blind spot: no template used it. `series_gap_style` now puts all four `display`
202
+ values side by side. Per-series gaps also stopped having a drawing path of their own — they
203
+ go through the same `renderGaps` as chart-wide ones.
204
+
205
+ - **The parity suite depended on the developer's timezone.** Both libraries format labels in
206
+ the machine's zone, so the goldens only matched where they were written — the first CI run
207
+ failed all 38 templates. Tests are pinned to UTC now (`vitest.config.ts`, `TestMain`) and the
208
+ goldens regenerated; checked under three zones. The underlying gap is fixed by `timeZone`
209
+ above (B-20260922-07).
210
+
211
+ - **A fill region with two unresolvable bounds killed the Go process.** A nil-pointer panic,
212
+ reachable from `cmd/server` with a plain misconfiguration (`to: { threshold: '<unknown>' }`).
213
+ Such a region is now simply not drawn. The divergence underneath stays open: TypeScript
214
+ throws where Go carries on, and `RenderCommands()` has no error channel (B-20260922-06).
215
+
216
+ - **A threshold's CSS class differed between the libraries.** TypeScript slugified the name,
217
+ Go took it raw, so `Warning Low` became `.threshold--warning-low` in one and three classes in
218
+ the other. Hidden by another normalisation rule that slugified *both* sides before comparing.
219
+ Rule gone, Go slugifies, divergences now fail the test.
220
+
221
+ - **Six marker shapes were drawn with one side open.** `diamond`, `triangle`, `triangle-down`,
222
+ `star`, `hexagon` and `hourglass` never closed their path, so the fill looked right and the
223
+ stroke was missing its last edge — since the shapes were added in May. Both libraries made the
224
+ identical mistake, which is why the comparison could not see it. `arrow` stays open on
225
+ purpose.
226
+
227
+ - **A `rect` annotation's `hatch` was accepted and dropped.** The type offered it, neither
228
+ renderer passed it on. Both do now, and `annotations_demo` carries a hatched rect.
229
+
230
+ - **An aggregated series had no colour in the legend.** The legend read only `style.line.color`,
231
+ so two bands stood side by side with identical grey swatches. Both libraries now fall back to
232
+ the band's `avgColor`.
233
+
234
+ - **The Go library printed debug output on almost every render.** `FillSpec.UnmarshalJSON`
235
+ carried a `fmt.Printf("DEBUG …")` in its *expected* fallback branch, so any config using the
236
+ `fill: '#colour'` shorthand wrote to the caller's stdout — noise in someone else's log when
237
+ running as a server.
238
+
239
+ - **German strings where a user can see them, in Go.** Four error messages and six parity
240
+ templates whose labels are rendered into the SVG. Comments and commit messages stay German;
241
+ the rule is about what the reader sees.
242
+
243
+ - **The dev server showed the last build, not the work in progress.** `pnpm dev` ran
244
+ `vite demos`, which makes vite look for its config *in* `demos/` — so the repository's
245
+ `vite.config.ts` and its aliases were never loaded and `ml-time-graph` resolved to whatever
246
+ `dist` was lying around. The production build always used `src`, so the two could disagree.
247
+ `pnpm dev` is plain `vite` now; the config sets the root itself.
248
+
10
249
  ---
11
250
 
12
251
  ## [1.7.2] - 2026-09-21
@@ -314,7 +553,7 @@ Both libraries are released in lockstep on the same version number.
314
553
  goldens gained the clip and nothing else. Two new fixtures (`series_clip`,
315
554
  `series_clip_off`) pin both switch positions — until now no fixture had data
316
555
  outside its range, which is why nobody noticed. A demo card shows both side by
317
- side (Styles → “Clip an der festen Zeitachse”).
556
+ side (Styles → “Clipping against a fixed time axis”).
318
557
  - **A threshold is no longer labelled with its own name.** Leaving `label` out used
319
558
  to mean “paint the name”. But `name` is an IDENTIFIER — it wires
320
559
  `colorByThresholds`, fill regions and CSS classes — so an invisible anchor
@@ -383,13 +622,12 @@ Both libraries are released in lockstep on the same version number.
383
622
 
384
623
  ## [1.3.3] - 2026-09-04
385
624
 
386
- > **1.3.2 wurde uebersprungen.** Die Tags `v1.3.2` und `go-time-graph/v1.3.2`
387
- > wurden versehentlich auf den Commit *vor* der Versionsanhebung gesetzt und
388
- > gepusht; `proxy.golang.org` hatte sie bereits geholt, und sein Inhalt ist
389
- > unveraenderlich. Sie zu verschieben haette Pruefsummenfehler bei jedem
390
- > ausgeloest, der das Modul schon gezogen hat. Der Go-Tag `v1.3.2` existiert
391
- > also und traegt alle Aenderungen dieser Fassung — nur meldet
392
- > `pkg/version.Version` dort noch 1.3.1. Auf npm gibt es keine 1.3.2.
625
+ > **1.3.2 was skipped.** The tags `v1.3.2` and `go-time-graph/v1.3.2` were pushed by
626
+ > mistake onto the commit *before* the version bump. `proxy.golang.org` had already
627
+ > fetched them, and its content is immutable — moving them would have caused checksum
628
+ > errors for everyone who had pulled the module. So the Go tag `v1.3.2` exists and
629
+ > carries every change of this release; only `pkg/version.Version` still reports 1.3.1
630
+ > there. There is no 1.3.2 on npm.
393
631
 
394
632
 
395
633
  ### Added
package/README.de.md CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  *[English](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/README.md) · Deutsch*
4
4
 
5
- **TypeScript-Library für die grafische Darstellung von Messwerten** — Zeitreihen
6
- schnell und unkompliziert aufbereiten, mit Fokus auf Reporting und Incident-Analyse.
5
+ **TypeScript-Library für die Darstellung beliebiger Zeitreihen** — Telemetrie, Sensoren,
6
+ Systemmetriken, Logs, Finanzdaten, Labor- oder Prozessmesswerte. Ihre auffälligste Fähigkeit
7
+ ist die **erklärende Beschriftung**: freie Annotationen in Datenkoordinaten (Pfeile, Labels,
8
+ Sprechblasen), Zeitbereichs-Markierungen, Status- und Phasenbänder und Schwellenwert-Zonen
9
+ machen aus einer rohen Kurve einen Nachweis. Dazu eine bestimmende Eigenschaft der Architektur:
10
+ Sie erzeugt SVG als reinen String, ohne das DOM je anzufassen — derselbe Aufruf läuft im
11
+ Browser und im Backend.
7
12
 
8
13
  > Voll typisiert · i18n-aware · DOM-freier SVG-Renderer (Browser & serverseitig) · keine Laufzeit-Abhängigkeiten · ESM-only
9
14
 
@@ -72,6 +77,44 @@ mount('#chart', {
72
77
  });
73
78
  ```
74
79
 
80
+ **Die Daten sehen anders aus?** Dann müssen sie nicht umgebaut werden. `toSeries` nimmt
81
+ Tupel, eine REST-Antwort in Unix-Sekunden, einen CSV-Export aus Zeichenketten oder ein
82
+ verschachteltes Dokument und macht daraus, was das Diagramm erwartet:
83
+
84
+ ```ts
85
+ import { toSeries } from 'ml-time-graph';
86
+
87
+ // [[1700000000000, 18.2], …] → time/value
88
+ toSeries('Temperatur', tupel)
89
+
90
+ // [{ ts: 1700000000, val: '18.2' }, …] → eigene Feldnamen, Sekunden, Zeichenketten
91
+ toSeries('Temperatur', zeilen, { time: 'ts', value: 'val', timeUnit: 's' })
92
+ ```
93
+
94
+ Fehlende Messwerte (`null`, `undefined`, `NaN`, `''`) werden zu Lücken; eine Zeichenkette,
95
+ die keine Zahl ist, wirft und nennt die Zeilennummer. Zum Ausprobieren: **[Input Adapters](https://mlcgo.eu/books/mlctimegraph/demo/adapters.html)**
96
+ — vier Eingabeformen, ein Diagramm.
97
+
98
+ ### Der wiederkehrende Teil in eine eigene Ebene
99
+
100
+ Sobald mehrere Berichte entstehen, wiederholt sich ein Teil der Beschreibung: Maße, Achsen,
101
+ Legende, Farben. In jede Datei kopiert heißt das, ihn irgendwann an zwölf Stellen zu ändern
102
+ und an einer zu vergessen. `mergeOptions` legt ihn stattdessen darüber:
103
+
104
+ ```ts
105
+ import { mergeOptions, MLTimeGraph } from 'ml-time-graph';
106
+
107
+ new MLTimeGraph(mergeOptions(hausTheme, messwerte)); // die spätere Ebene gewinnt
108
+ ```
109
+
110
+ Die Regel ist ein Satz: **Objekte verschmelzen, alles andere wird ersetzt** — auch Arrays,
111
+ damit ein Theme mit einem einzigen Linienstil nicht aus einer Kurve zwei macht. Nicht zu
112
+ verwechseln mit `{ ...hausTheme, ...messwerte }`: Der Spread ist **flach**, ein `axes` im
113
+ zweiten Objekt ersetzt damit das komplette `axes` des ersten, samt Gitter und Ticks.
114
+
115
+ Serverseitig gilt dieselbe Regel — `graph-cli -with haus-theme.json`, beliebig oft
116
+ gestapelt. Ausführlich im Handbuch, [Kapitel 5](https://mlcgo.eu/books/mlctimegraph/de/05/).
117
+
75
118
  📖 **Nutzung & API → [USAGE.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/USAGE.md)** *(englisch)*
76
119
 
77
120
  ## Galerie
@@ -87,8 +130,10 @@ Typische Sensor-Darstellung, Min/Max/Avg mit Schraffuren für
87
130
  Incident-Reports, ein Sensorstrom mit Statistik-Overlays (±2σ-Band +
88
131
  12-h-MKT) und Annotationsbänder, die Betriebszustände und Ereignisse
89
132
  *unterhalb* des Diagramms markieren — dort verdecken sie nichts, und man
90
- liest in einer Zeile ab, **wann** etwas galt. Alles dieselbe Library, alles
91
- in der Demo-Galerie zu sehen (`pnpm dev`); die Bilder selbst entstehen mit
133
+ liest in einer Zeile ab, **wann** etwas galt. Alles dieselbe Library. **Die Galerie läuft
134
+ online: [mlcgo.eu/books/mlctimegraph/demo](https://mlcgo.eu/books/mlctimegraph/demo/)** —
135
+ fünfzehn Seiten zum Anfassen, jede Karte mit Code- und Werte-Reiter, nichts zu installieren.
136
+ Lokal geht es mit `pnpm dev`; die Bilder oben entstehen mit
92
137
  `node scripts/make-examples.mjs`.
93
138
 
94
139
  ---
@@ -97,6 +142,10 @@ in der Demo-Galerie zu sehen (`pnpm dev`); die Bilder selbst entstehen mit
97
142
 
98
143
  Benötigst du serverseitiges Rendering der exakt gleichen Charts? Es gibt einen 1:1 Go-Port dieser Engine unter **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/-/tree/main/go-time-graph)**.
99
144
 
145
+ **Einstieg:** [BUILDER.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/go-time-graph/docs/BUILDER.md)
146
+ beginnt mit einem vollständigen Quickstart — ein lauffähiges `main.go`, das eine Reihe
147
+ aufbaut, Schwellenwerte setzt und die SVG-Datei schreibt.
148
+
100
149
  Sowohl die TypeScript- als auch die Go-Bibliothek:
101
150
  - Verarbeiten das **exakt gleiche JSON-Konfigurationsschema**.
102
151
  - Generieren **identische SVG-Strukturen und Layoutberechnungen**.
@@ -122,6 +171,37 @@ deshalb gibt es **ein** Changelog für beide: [CHANGELOG.md](https://gitlab.com/
122
171
  Es liegt auch dem Paket bei — die Historie genau der Version, die du installiert hast, liegt
123
172
  damit neben dem Code.
124
173
 
174
+ ### Warum schon 1.8, und warum so viele Minor-Versionen?
175
+
176
+ Weil die Bibliothek täglich im Einsatz ist, und der Einsatz findet, was ein sauberer Entwurf
177
+ nicht findet.
178
+
179
+ Das meiste sind **Randfälle in echten Daten**. Gebaut wurde die Engine für eine Reihe von
180
+ Messwerten; an kommt eine Reihe mit zwei Werten auf demselben Zeitstempel, ein leerer Slot,
181
+ ein einzelner Wert zwischen zwei Ausfällen, eine Stunde, in der sich gar nichts geändert hat.
182
+ Nichts davon war falsch entworfen — es war schlicht nicht bedacht. Jeder dieser Fälle hat
183
+ heute eine eigene Testvorlage: `edge_marker_duplicate_time`, `edge_gaps_autodetect`,
184
+ `edge_minmaxavg_single_point`, `edge_constant_value` und zehn weitere.
185
+
186
+ Einiges sieht man **erst in der Menge**. Der Go-Port zeichnet dieselben Diagramme auf dem
187
+ Server; was er kostet, merkt niemand, bevor zehntausend Berichte durchlaufen. So gemessen und
188
+ behoben: Ein Diagramm mit 25 000 Punkten ging von 68 ms auf 13 ms und von 921 KB auf 403 KB —
189
+ weil der SVG-String Segment für Segment zusammengesetzt wurde und jede Koordinate sechzehn
190
+ Stellen trug, die kein Bildschirm auflöst.
191
+
192
+ Und einiges sind **Fragen**. „Wieso geht das nicht?" ist meistens keine fehlende Fähigkeit,
193
+ sondern ein Satz in der Dokumentation, den man auf zwei Arten lesen kann. Die werden am selben
194
+ Tag korrigiert, und in der Regel kommt ein Test dazu — damit die Lesart festgehalten ist und
195
+ nicht erinnert werden muss.
196
+
197
+ Was sich *nicht* ändert, ist die Schnittstelle. Sie ist seit 1.0 additiv — keine Option
198
+ entfernt, keine Signatur geändert. Wo ein Bild falsch war, wurde es korrigiert, und diese
199
+ Korrekturen stehen im Changelog unter **Changed**, nie versteckt unter Fixed.
200
+
201
+ Dafür sind die Tests da: **574 in TypeScript, 74 in Go und 36 gemeinsame Vorlagen**, die beide
202
+ Bibliotheken auf byte-gleiche Ausgabe festnageln. Sie sind nicht dazu da zu beweisen, dass das
203
+ Neue funktioniert. Sie sind dazu da, dass das Neue das Alte nicht stillschweigend verändert.
204
+
125
205
  ---
126
206
 
127
207
  ## 📄 PDF-Ausgabe
@@ -182,12 +262,30 @@ werden und die nachträgliche Auswertung entscheidend ist.
182
262
  - ❌ **Volle Interaktivität** — Zoom/Pan ja, aber in Grenzen
183
263
  - ❌ GPU-Performance-Optimierungen o. Ä.
184
264
 
265
+ „Keine Performance-Bibliothek" heißt: kein GPU-Pfad, kein virtualisiertes Canvas. Es heißt
266
+ nicht, dass die Sache langsam wäre. Gemessen, damit niemand raten muss: Eine **Linie mit
267
+ 25 000 Punkten steht in rund 20 ms** in Chromium — Diagramm samt fertigem SVG-String, 900×400 —
268
+ und die Datei ist 403 KB groß. Es skaliert linear: 5 000 Punkte ≈ 4 ms, 50 000 ≈ 36 ms.
269
+ Gemessen auf einem Xeon E5-2650 v2 mit 2,6 GHz, einer Server-CPU von 2013; ein heutiger
270
+ Arbeitsplatzrechner ist schneller. Der Go-Port braucht für dieselben 25 000 Punkte rund 13 ms.
271
+
272
+ Koordinaten werden mit drei Nachkommastellen geschrieben. Das ist weit jenseits dessen, was
273
+ ein Bildschirm oder ein Drucker auflöst — 0,001 px sind bei 300 dpi drei Tausendstel eines
274
+ Punktes — und es ist der Grund für die kleinen Dateien: ungekürzt brauchte dasselbe Diagramm
275
+ 921 KB.
276
+
185
277
  ## Ausblick / in Überlegung
186
278
 
187
- - Möglichkeiten der „Live"-Darstellung
188
- - Einfache Anbindung von Backends (woher kommen meine Daten?)
189
279
  - svelte wrapper
190
280
 
281
+ Zwei Punkte von hier sind erledigt und stehen jetzt woanders:
282
+
283
+ - **Woher kommen meine Daten?** → `toSeries` / `toDataPoints`, siehe oben beim Quickstart.
284
+ - **„Live"-Darstellung** → `setData()` auf einer bestehenden Instanz, neu zeichnen, fertig.
285
+ Kein zweites Diagramm, kein Neuaufbau. Vorgeführt in der Demo
286
+ [Interaction](https://mlcgo.eu/books/mlctimegraph/demo/interaction.html), Karte
287
+ `interaction-3`.
288
+
191
289
  ## Demos & Entwicklung
192
290
 
193
291
  ```bash
@@ -214,8 +312,3 @@ Copyright-Hinweis im Quellcode erhalten bleibt.
214
312
 
215
313
  **Ohne Nennung:** Unternehmen, die die Attribution nicht zeigen möchten, können eine
216
314
  **kommerzielle Lizenz auf Anfrage** erhalten, die diese Pflicht aufhebt — Kontakt: ‹mlcgo.eu@michael-lechner.de›.
217
-
218
- ---
219
-
220
- <sub>Das Projekt diente ursprünglich als Test für Crush-Development mit Ollama +
221
- neuem LLM — bestanden 😉, brauchte aber doch einige Nacharbeit.</sub>
package/README.md CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  *English · [Deutsch](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/README.de.md)*
4
4
 
5
- **A TypeScript library for visualizing measurement data** — turn time series into
6
- clear, readable charts quickly, with a focus on reporting and incident analysis.
5
+ **A TypeScript library for visualizing any time-series data** — telemetry, physical sensors,
6
+ system metrics, logs, finance, laboratory or process measurements. Its standout capability is
7
+ rich **contextual annotation**: free-form annotations in data coordinates (arrows, labels,
8
+ callout rects), time-range highlights, status and phase bands, and threshold zones turn a raw
9
+ curve into an explanatory record. And one defining architectural property: it produces SVG as a
10
+ plain string without ever touching the DOM — the identical call runs in a browser and in a
11
+ backend.
7
12
 
8
13
  > Fully typed · i18n-aware · DOM-free SVG output (browser & server) · zero runtime dependencies · ESM-only
9
14
 
@@ -72,6 +77,44 @@ mount('#chart', {
72
77
  });
73
78
  ```
74
79
 
80
+ **Your data looks different?** Then it does not have to be rebuilt. `toSeries` takes tuples,
81
+ a REST payload in Unix seconds, a CSV export of strings or a nested document, and turns it
82
+ into what the chart expects:
83
+
84
+ ```ts
85
+ import { toSeries } from 'ml-time-graph';
86
+
87
+ // [[1700000000000, 18.2], …] → time/value
88
+ toSeries('Temperature', tuples)
89
+
90
+ // [{ ts: 1700000000, val: '18.2' }, …] → your field names, seconds, strings
91
+ toSeries('Temperature', rows, { time: 'ts', value: 'val', timeUnit: 's' })
92
+ ```
93
+
94
+ Missing readings (`null`, `undefined`, `NaN`, `''`) become gaps; a string that is not a number
95
+ throws and names the row. Try it: **[Input Adapters](https://mlcgo.eu/books/mlctimegraph/demo/adapters.html)** — four
96
+ input shapes, one chart.
97
+
98
+ ### The repeating part as a layer of its own
99
+
100
+ As soon as there are several reports, part of the description repeats: dimensions, axes,
101
+ legend, colours. Copied into every file, that means changing it in twelve places one day and
102
+ forgetting one. `mergeOptions` puts it underneath instead:
103
+
104
+ ```ts
105
+ import { mergeOptions, MLTimeGraph } from 'ml-time-graph';
106
+
107
+ new MLTimeGraph(mergeOptions(houseTheme, readings)); // the later layer wins
108
+ ```
109
+
110
+ The rule is one sentence: **objects merge, everything else is replaced** — arrays included, so
111
+ a theme carrying a single line style does not turn one curve into two. Not to be confused with
112
+ `{ ...houseTheme, ...readings }`: the spread is **shallow**, so an `axes` in the second object
113
+ replaces the first one's `axes` entirely, grid and ticks and all.
114
+
115
+ The same rule server-side — `graph-cli -with house-theme.json`, stacked as often as you like.
116
+ In full in the handbook, [chapter 5](https://mlcgo.eu/books/mlctimegraph/en/05/).
117
+
75
118
  📖 **Usage & API → [USAGE.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/USAGE.md)**
76
119
 
77
120
  ## Gallery
@@ -87,8 +130,10 @@ A typical sensor visualisation, min/max/avg with hatched fills for
87
130
  incident-style reports, a sensor stream with statistic overlays (±2σ band +
88
131
  12 h MKT), and annotation bands marking operating states and events *below*
89
132
  the chart — where they cover nothing and you read in one line **when**
90
- something applied. All rendered with the same library, all live in the demo
91
- gallery (`pnpm dev`); the images themselves come from
133
+ something applied. All rendered with the same library. **The gallery runs
134
+ online: [mlcgo.eu/books/mlctimegraph/demo](https://mlcgo.eu/books/mlctimegraph/demo/)** —
135
+ fifteen pages to play with, every card with a Code and a Values tab, nothing to install.
136
+ Locally it is `pnpm dev`; the images above come from
92
137
  `node scripts/make-examples.mjs`.
93
138
 
94
139
  ---
@@ -97,6 +142,10 @@ gallery (`pnpm dev`); the images themselves come from
97
142
 
98
143
  Need server-side rendering of the exact same charts? There is a 1:1 Go port of this engine available at **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/-/tree/main/go-time-graph)**.
99
144
 
145
+ **Where to start:** [BUILDER.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/go-time-graph/docs/BUILDER.md)
146
+ opens with a complete quickstart — a runnable `main.go` that builds a series, sets thresholds
147
+ and writes the SVG file.
148
+
100
149
  Both the TypeScript and Go libraries:
101
150
  - Process the **exact same JSON configuration schema**.
102
151
  - Support **multiple stacked Y-axes** on both left and right sides (with configurable pixel `offset` and automatic step offsets).
@@ -121,6 +170,35 @@ changelog for both: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blo
121
170
  It ships with this package too, so the history of the exact version you installed is right
122
171
  next to the code.
123
172
 
173
+ ### Why already at 1.8, and why so many minor releases?
174
+
175
+ Because the library is in daily professional use, and use finds what a clean design does not.
176
+
177
+ Most of it is **edge cases in real data**. The engine was built for a series of readings; what
178
+ arrives is a series with two readings on the same timestamp, a slot that is empty, a single
179
+ value between two outages, an hour in which nothing changed at all. None of that was wrong in
180
+ the design — it simply had not been thought of. Every one of those now has a test template of
181
+ its own: `edge_marker_duplicate_time`, `edge_gaps_autodetect`, `edge_minmaxavg_single_point`,
182
+ `edge_constant_value` and ten more.
183
+
184
+ Some of it is **things you only see at scale**. The Go port renders the same charts
185
+ server-side; nobody notices what it costs until ten thousand reports go through it. Measured
186
+ and fixed that way: a 25,000-point chart went from 68 ms to 13 ms and from 921 KB to 403 KB,
187
+ because the SVG string was being concatenated one segment at a time and every coordinate
188
+ carried sixteen digits of precision no screen resolves.
189
+
190
+ And some of it is **questions**. "Why doesn't this work?" is usually not a missing feature but
191
+ a sentence in the documentation that could be read two ways. Those get fixed the same day, and
192
+ usually a test comes with them so the reading is pinned rather than remembered.
193
+
194
+ What does *not* change is the interface. It has been additive since 1.0 — no option removed,
195
+ no signature altered. Where a picture was wrong it was corrected, and those corrections are in
196
+ the changelog under **Changed**, never buried under Fixed.
197
+
198
+ That is what the tests are for: **574 in TypeScript, 74 in Go, and 36 shared templates** that
199
+ hold both libraries to byte-identical output. They are not there to prove the new thing works.
200
+ They are there so that the new thing does not quietly change the old one.
201
+
124
202
  ---
125
203
 
126
204
  ## 📄 PDF Output
@@ -180,12 +258,29 @@ after-the-fact evaluation is what matters.
180
258
  - ❌ **Full interactivity** — zoom/pan yes, but within limits
181
259
  - ❌ GPU performance optimizations and the like
182
260
 
261
+ "Not a performance library" means there is no GPU path and no virtualized canvas — it does not
262
+ mean the thing is slow. Measured, so nobody has to guess: a **25,000-point line renders in
263
+ about 20 ms** in Chromium (chart plus the finished SVG string, 900×400) and the file comes to
264
+ 403 KB. It scales linearly — 5,000 points ≈ 4 ms, 50,000 ≈ 36 ms. That is on a Xeon E5-2650 v2
265
+ at 2.6 GHz, a server CPU from 2013; a current desktop does it faster. The Go port does the
266
+ same 25,000 points in about 13 ms.
267
+
268
+ Coordinates are written with three decimals. That is far beyond what any screen or printer
269
+ resolves — 0.001 px is three thousandths of a point at 300 dpi — and it is what keeps the
270
+ files small: written in full, that same chart took 921 KB.
271
+
183
272
  ## Outlook / under consideration
184
273
 
185
- - "Live" rendering options
186
- - Simple backend integration (where does my data come from?)
187
274
  - Svelte wrapper
188
275
 
276
+ Two items that used to sit here are done, and live elsewhere now:
277
+
278
+ - **Where does my data come from?** → `toSeries` / `toDataPoints`, see the Quickstart above.
279
+ - **"Live" rendering** → `setData()` on an existing instance, then re-render. No second chart,
280
+ no rebuild. Shown in the
281
+ [Interaction](https://mlcgo.eu/books/mlctimegraph/demo/interaction.html) demo, card
282
+ `interaction-3`.
283
+
189
284
  ## Demos & development
190
285
 
191
286
  ```bash
@@ -212,8 +307,3 @@ and the copyright notice is retained in the source.
212
307
 
213
308
  **Without attribution:** organizations that prefer not to display the attribution can
214
309
  obtain a **commercial license on request** that waives it — contact: ‹mlcgo.eu@michael-lechner.de›.
215
-
216
- ---
217
-
218
- <sub>Originally a test of Crush development with Ollama + a new LLM — passed 😉, but it
219
- did need some rework.</sub>