ml-time-graph 1.7.0 → 1.7.2

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 ADDED
@@ -0,0 +1,603 @@
1
+ # Changelog
2
+
3
+ All notable changes to `ml-time-graph` (TypeScript) and `go-time-graph` (Go) will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Both libraries are released in lockstep on the same version number.
9
+
10
+ ---
11
+
12
+ ## [1.7.2] - 2026-09-21
13
+
14
+ ### Added
15
+ - **The changelog ships with the npm package.** Until now a consumer got no history at all —
16
+ the file lives in the repository root, and npm does not publish anything outside the package
17
+ directory. A `prepack` step copies it in and `postpack` removes it again, so the copy is a
18
+ build artifact rather than a second document: it cannot drift, which is exactly how the two
19
+ per-package changelogs ended up claiming for five releases that the library had stopped at
20
+ 1.2.0.
21
+ - **The handbook covers the input adapters** (`book/{de,en}/chapters/02_first_curve.md`). The
22
+ chapter already told the reader that `time` is a number in milliseconds and not a `Date` —
23
+ which is exactly the moment they look at their own rows and wonder. It now answers that in
24
+ the same breath, including why the core stays strict while the edge gives.
25
+
26
+ ### Added
27
+ - **`CONTRIBUTING.md` and GitLab issue templates** (Bug, Parity, Feature). The library is
28
+ downloaded and used often enough now that reports arrive from people who cannot be asked
29
+ three follow-up questions. The Bug template asks for the chart options, because with them a
30
+ report becomes a failing test in minutes. **Parity** is a template of its own on purpose:
31
+ "TypeScript and Go draw different pictures from the same options" is the one defect class the
32
+ parity harness cannot find by itself, and it needs exactly the material a parity template is
33
+ built from. Both package READMEs now name the reporting route.
34
+ - **`scripts/make-book-images.mjs` — the handbook figures are a build artifact now.** 48 files
35
+ (24 templates, dark and light) that had been hand-made and inherited ever since. The
36
+ generator renders them from the same `go-time-graph/test_data/*.json` the parity harness
37
+ uses, so the handbook shows exactly the charts that are checked. Proof that the
38
+ reconstruction is faithful: 46 of the 48 come out byte-identical to what was committed. The
39
+ other two are `threshold_no_label`, where the committed image predates the 1.6.0 fix and was
40
+ still missing the axis tick that fix restored — the handbook had been showing the bug.
41
+ - **`scripts/make-examples.mjs` — the gallery images are a build artifact now**, and there is a
42
+ fourth one: `ex4.svg` shows **annotation bands**. A state is not a measurement; it does not
43
+ belong in the plot as a fourth curve but as a strip *below* it, where it covers nothing and
44
+ you read in one line **when** something applied.
45
+
46
+ ### Fixed
47
+ - **`ex1.svg` in the README showed a defect that 1.6.0 had fixed.** The image dated from
48
+ 17 June and was never regenerated: a dip that starts and ends *on* the warning threshold was
49
+ drawn in the colour of the zone above it. Under the heading "zoned colouring", the picture
50
+ advertised the feature and displayed its bug. The series has been recovered from the old SVG
51
+ (the axes carry their scale, so the readings invert cleanly) and re-rendered — same chart,
52
+ correct colours, verified segment by segment against the threshold pixels. `ex2.svg` carried
53
+ `idfunction now() { [native code] }1` in its element ids, from a `Date.now` passed without the
54
+ call. An image nobody can regenerate ages quietly; these now come from the script, rendered
55
+ out of `dist/` — what the package actually ships.
56
+ - **Two gallery captions described something else than the image showed** (`ex1` was credited
57
+ with threshold fills it does not have; `ex2` is a min/max/avg band, not multi-zone fills).
58
+ - **The `SKILLS.md` link in both READMEs returned 404 on npmjs.com.** It was a *relative* link,
59
+ and npm rewrites those against the `repository` field into a path GitLab does not serve. The
60
+ file is right there in the package, but the place people actually click is the npm page.
61
+ Both READMEs now link absolutely, like every other link in them; each one was checked
62
+ afterwards and returns 200.
63
+ - **`homepage` in `package.json` pointed at GitHub** (`github.com/mlc0911/mlctimegraph`), which
64
+ is a 404 — the project lives on GitLab. That is the "Homepage" link in the npm sidebar, so
65
+ the first link a visitor takes was broken.
66
+ - **The product page metadata (`mlcprodweb/meta.yaml`) said 1.5.2** — five releases behind,
67
+ because `release.mjs` did not know about the file. It does now, so the page cannot fall
68
+ behind again. The same entry claimed 13 demos; there are 15.
69
+
70
+ ---
71
+
72
+ ## [1.7.1] - 2026-09-21
73
+
74
+ ### Fixed
75
+ - **`toStepData` / `toStepPoints` are now actually exported** (via `ml-time-graph/internals`).
76
+ 1.7.0 announced the staircase geometry as public so that a second output path would draw the
77
+ same step instead of deriving it again — and then shipped it reachable from nowhere. The Go
78
+ port had it right (`renderer.ToStepData`), which is exactly the asymmetry that lets two
79
+ derivations of the same step drift apart.
80
+ - **The link to the Go port in both READMEs returned 403.** It carried the Go *module path*
81
+ (`gitlab.com/mlc0911/mlctimegraph/go-time-graph`) as if it were a web address. `go get`
82
+ resolves it because the Go tooling appends `?go-get=1` and GitLab answers with a meta tag; a
83
+ browser gets no such treatment and GitLab reads the path as namespace/group/project. A
84
+ subdirectory needs the `/-/tree/<branch>/` form. Every absolute link in the published docs was
85
+ checked afterwards — all of them resolve.
86
+
87
+ ### Removed
88
+ - **`packages/ml-time-graph/CHANGELOG.md` and `go-time-graph/CHANGELOG.md`.** Both stopped at
89
+ 1.2.0 in August and had been telling readers ever since that the library stood still — while
90
+ five releases went out. Every entry in them was a word-for-word duplicate of this file, and
91
+ nothing linked to them. Both libraries ship in lockstep on one version number, so one
92
+ changelog is the honest number of changelogs. The READMEs now link here.
93
+
94
+ ### Added
95
+ - **The PDF companion is mentioned in the package README** (and in `README.de.md` and
96
+ `SKILLS.md`). [mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf) is the second
97
+ consumer of the same draw commands and writes native PDF vectors — until now it was only
98
+ named in the monorepo README, which npm readers never see. Listed with what it is: 0.2.0, not
99
+ 1.0, and a fill on a path still renders opaque and without its hatch there.
100
+
101
+ ---
102
+
103
+ ## [1.7.0] - 2026-09-21
104
+
105
+ ### Fixed
106
+ - **Filled steps (`shape: "step"` + `style.fill`):** The area was built from the raw readings
107
+ and ran as a **ramp** underneath a step line — a triangle missing below every step, one too
108
+ many above it. That is precisely what a step is there to prevent for state-like quantities
109
+ (runtime, stage, operating mode): the fill claimed values nobody measured between two
110
+ readings, so a filled staircase could not be drawn at all. The step is now formed **in data
111
+ space**, before anything is split or drawn (`toStepData` / `ToStepData`): line, area and
112
+ hatch all use the same sequence of points. Both libraries had the same gap — a defect both
113
+ sides share is invisible to a parity comparison until a template shows it. The new
114
+ `step_filled` template shows it.
115
+ - **Zone colours on a step (`colorByThresholds` + `shape: "step"`):** The colour change sat at
116
+ the **interpolated** crossing time, with a horizontal piece at threshold level in between
117
+ that does not exist in the data. The boundary now cuts the vertical jump itself, at the
118
+ reading's timestamp.
119
+ - **No smoothing on a step:** A `smoothing: true` alongside `shape: "step"` is now ignored for
120
+ the line *and* the fill, instead of rounding off the very corners that make the step.
121
+ - **`style.line` as an array (`LineStyle[]`) — one spelling, two pictures:** "A step outline
122
+ plus a smoothed trend line" has been documented all along (USAGE.md, "Series"), and neither
123
+ library delivered it. TypeScript emitted N paths but never read `shape` there, so both layers
124
+ came out as ramps. Go read the shape of the FIRST entry and drew exactly ONE line; the second
125
+ layer was missing entirely. Both now draw N layers, each **in its own shape**: an entry
126
+ without a `shape` is a straight line and does not inherit the first one's step — otherwise
127
+ that exact combination would not be expressible. `seriesType: 'step'` still applies to every
128
+ layer without a shape of its own, and the first entry is the series' shape (fill, zones,
129
+ markers). The new `line_overlay` template holds both sides together.
130
+ - **`line: false` in the Go port:** The field was never read — an explicitly disabled line was
131
+ drawn anyway, which made ghost series impossible.
132
+ - **`opacity` on a line (Go):** was discarded and always written as 1. The value now passes
133
+ through per layer, as it does in TypeScript — the whole point of the array form, letting the
134
+ upper layer show the one below, depended on it.
135
+ - **Per-layer colour (Go):** Every layer would have carried the first entry's colour. The zone
136
+ colour (`colorByThresholds`) still wins over the layer's own colour.
137
+
138
+ ### Added
139
+ - **Demo `demos/adapters.html` — "Input Adapters":** one chart built from tuples, a REST payload
140
+ in Unix seconds, a CSV export of strings with an empty cell, and a nested document.
141
+ - **Demo `demos/steps.html` — "Filled Steps":** the area under the staircase, the area against
142
+ a limit, enum states, and a step with a smoothed trend line on top — each with the optional
143
+ hatch, plus a step ↔ line switch.
144
+ - **Parity templates `step_filled` and `line_overlay`:** a filled step with two regions and
145
+ hatching; a step with a smoothed trend line above it. 34 templates now stand at 0/0.
146
+ - **`LineShape` (TS) / `LineStyleSpec.IsArray`, `FlatSeriesStyle.Opacity`, `IDSuffix` (Go):**
147
+ the types that make the array form distinguishable in the first place — `line: [{…}]` and
148
+ `line: {…}` hand out different SVG ids (`-line-<segment>-<layer>` vs `-line-<segment>`), and
149
+ without that field the port could not have told one form from the other.
150
+ - **`toStepData` (TS) / `renderer.ToStepData` (Go):** the staircase geometry as data — public,
151
+ so a second output path draws the same step instead of deriving it again.
152
+ - **`toDataPoints(rows, spec?)` and `toSeries(name, rows, spec?)` — input adapters.** `DataPoint`
153
+ stays strict, because scales, run splitting, zone cuts, the tooltip and the Go port all read
154
+ those two fields; widening the core would push that variance through every one of them. The
155
+ give belongs at the boundary, and until now every caller wrote that `.map()` themselves. The
156
+ adapter takes `[time, value]` tuples, objects with foreign field names (`{ time: 'ts', value:
157
+ 'val' }`) and accessor functions for anything nested. Numeric timestamps are milliseconds
158
+ unless `timeUnit: 's'` or `'auto'` says otherwise — and `'auto'` deliberately leaves a relative
159
+ time base (0, 1000, 2000 …) alone instead of shifting it by a factor of 1000. ISO strings and
160
+ `Date`s are recognised on their own, numeric strings are converted, and a missing reading
161
+ (`null`, `undefined`, `NaN`, `''`) becomes a **gap** rather than a zero — a chart must not
162
+ claim a value the sensor never reported. Anything genuinely broken throws and names the row.
163
+ See the new `demos/adapters.html`: the same chart from four input shapes.
164
+
165
+ ### Changed
166
+ - **`API_DESIGN.md` is no longer part of the npm package** and is now `DESIGN_NOTES.md`. It
167
+ called itself "API reference (v1.0.0)" but was a **target** design from the cleanup phase: it
168
+ described a `Series { points }` without `seriesType` that never existed, `view` instead of
169
+ `showAs`, two Y axes instead of arbitrarily many, a `src/analyze/` (long since its own
170
+ package) and CJS exports (the library is ESM only). Anyone typing out its examples got code
171
+ that does not compile — and it shipped in every tarball since 1.0.0. What is kept is what was
172
+ recorded nowhere else: principles P1–P9 and the resolved decisions Q1–Q11 with their
173
+ reasoning, each with today's status beside it, including where that status contradicts the
174
+ decision. The phase-by-phase cleanup log is condensed to one paragraph; the full version
175
+ lives in the git history. `USAGE.md` is the user documentation, the generated types are
176
+ binding.
177
+ - **Six `§` references in the source pointed nowhere** — the numbering had shifted, so "fills
178
+ §6" landed on the axes and "theme §12" on the options. They now name a section in `USAGE.md`
179
+ instead of a number that moves again with the next insertion.
180
+ - **`QUICKSTART_GRAPH_BUILDER.md`, `QUICKSTART_GRAPH_BUILDER.de.md` and
181
+ `GRAPH_JSON_STRUCTURE.md` now ship with the npm package** (20 files instead of 17). They used
182
+ to live in the repository only, while linking `USAGE.md` and each other — whoever unpacked
183
+ the package had neither the graph-builder walkthrough nor the full JSON form. Every link
184
+ inside the tarball now resolves to a file inside it. A link to a `GRAPH_JSON_STRUCTURE.de.md`
185
+ that never existed turned up on the way; it points at the English version now.
186
+
187
+ ### Removed
188
+ - **`API_DESIGN.md.merged` and `chunks/API_DESIGN-part-*.md`:** md-splitter working files,
189
+ committed by accident — a second copy of the same text that had already started to diverge.
190
+ `chunks/` and `*.md.merged` are in `.gitignore` now.
191
+
192
+ ---
193
+
194
+ ## [1.6.0] - 2026-09-21
195
+
196
+ ### Added
197
+ - **Automatic gap detection in Go (`gaps.autoDetect`):** The Go port now supports
198
+ `gaps.autoDetect: true` with configurable `minGapMs`, matching TypeScript parity.
199
+ - **Marker `lineStyle: "none"`:** Added support for standalone point markers without
200
+ projection lines.
201
+ - **Companion project for PDF output:** [mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf)
202
+ consumes the same draw commands and writes native PDF vectors — no browser, no SVG parsing.
203
+ Linked from the README as the worked example of what the command-based engine is for.
204
+ - **`renderer.SmoothPath` (Go):** The Catmull-Rom geometry behind smoothed lines is now
205
+ exported as `SmoothPath(points, smoothing, smoothCount) (segments, straight)`, returning
206
+ cubic Bézier segments plus the remaining straight points. The SVG renderer uses the same
207
+ function, so a second output format (PDF) draws the identical curve instead of
208
+ re-deriving it. Control-point rounding is part of the result, not of the SVG formatting.
209
+ - **`ZoneLow` / `zoneLow` on `SplitSegment`:** Explicit lower boundary field on segments
210
+ produced by `splitByBoundaries` / `SplitByBoundaries` in both TypeScript and Go.
211
+ - **12 Edge-Case Fixtures & Golden Templates:** Added comprehensive parity templates
212
+ covering unsorted thresholds, gap detection, steep crossings, step threshold splits,
213
+ single-point aggregations, separate legends, constant values, duplicate timestamps,
214
+ and annotation band overflows (32 total parity test suites passing with 0 diffs).
215
+
216
+ - **`title` on annotation band items:** An item can carry a hover tooltip, rendered as an
217
+ SVG `<title>` child of its rectangle (`SetTitle(...)` in Go, `title` in TypeScript).
218
+ It holds the detail that does not fit as a printed label — a full id, exact times, a
219
+ duration. Interactive only: PDF and raster output drop it, so a chart must stay readable
220
+ without it. `<title>` makes the rectangle a paired element; items without one are
221
+ unchanged and still self-closing.
222
+
223
+ ### Changed
224
+ - **`legend.position: "separate"` renders no SVG overlay in Go:** In parity with TypeScript,
225
+ a separate legend delegates rendering entirely to external HTML/DOM callers.
226
+ - **`gapThreshold` actively breaks lines in Go:** `style.line.gapThreshold` in Go now splits
227
+ series segments when time differences exceed the threshold, matching TypeScript behaviour.
228
+
229
+ ### Fixed
230
+ - **An annotation band item shorter than one pixel was not drawn at all.** Both ports
231
+ skipped it (`if endX - startX < 1`), and how short that is depends entirely on the
232
+ window: half a minute in a six-hour chart of 800px, a quarter of an **hour** in a
233
+ seven-day one. A five-minute outage was simply absent from the weekly view — not
234
+ shortened, not a hairline: gone. For a chart used as evidence that is the one failure
235
+ mode that must not exist, because a reader cannot notice what was never drawn. Such an
236
+ item is now drawn one pixel wide, clamped to stay inside the plot. One pixel claims no
237
+ duration — the exact times are the item's own data — it says “here was something”.
238
+ Items lying entirely outside the window are still dropped; that is a different
239
+ statement. Found in mlcsensormonitor on 20.09.2026, on a report with 32 events in six
240
+ hours.
241
+
242
+ - **Thresholds without `label` no longer suppress axis ticks:** Suppressing ticks required an
243
+ explicit label string; unlabelled thresholds no longer trigger nil pointer crashes in Go or
244
+ suppress neighbouring axis tick values.
245
+ - **Multi-axis marker projection targeting correct value scale:** Standalone markers targeting
246
+ series on secondary or arbitrary Y-axes (`seriesIndex > 0`) now map against the target series'
247
+ scale instead of erroneously projecting onto axis 0.
248
+ - **Zoned line coloring with unsorted thresholds:** Zone colors are now resolved using `ZoneLow`
249
+ and the highest reached boundary, rather than the caller's input slice ordering.
250
+ - **Zoned fills for dips and peaks returning to the same threshold:** Corrected `above` / `below`
251
+ determination for segments whose endpoints start and end on the boundary value.
252
+ - **Duplicate boundary intersection points:** Eliminated duplicate points and empty 2-point
253
+ segments in `splitByBoundaries` (TS) and `SplitByBoundaries` (Go) when crossing values coincide.
254
+
255
+ ---
256
+
257
+ ## [1.5.2] - 2026-09-19
258
+
259
+ ### Fixed
260
+ - **A dip that returns to the same threshold was coloured as if it were above it.**
261
+ `colorByThresholds` derived a segment's zone from the *mean of its endpoints*. A
262
+ spike below the lowest threshold starts and ends exactly ON it, so the mean landed
263
+ on the boundary and `>=` counted it as “above”: the whole excursion was drawn in
264
+ the colour of the zone above, while the markers of the same points carried the
265
+ right one. On a chart used as evidence, green where it was not in order is the
266
+ worst statement a picture can make. The zone now comes from the split itself
267
+ (`splitByBoundaries` already computes it from the crossing).
268
+
269
+ - **`FillRegion.outer` limits a fill; it no longer filters it.** It used to drop
270
+ every sub-segment that ran past the outer bound. For a zone corridor — “fill
271
+ between the line and the warning limit, but never past the hard limit” — that
272
+ tore a HOLE exactly where the excursion was worst. It now clamps: the fill stops
273
+ at the bound and what lies beyond belongs to the next region. Anyone who really
274
+ wants to filter can say so with two regions.
275
+
276
+ Both found in mlcsensormonitor on 19.09.2026, both invisible until a fixture
277
+ provoked them: no template had data crossing a colour threshold and returning, and
278
+ none used `outer` at all. The new fixture `fill_outer_clamp` covers both. No
279
+ existing golden changed.
280
+
281
+ ---
282
+
283
+ ## [1.5.1] - 2026-09-19
284
+
285
+ ### Fixed
286
+ - **The Go port drew a grid when none was configured**, while TypeScript drew
287
+ none — the same JSON produced two different charts. Now both follow the
288
+ TypeScript rule: a grid appears only when `axes.x.grid.major` or
289
+ `axes.left.grid.major` is set, and setting either gives both axes one.
290
+
291
+ It went unnoticed for as long as it did because *every* fixture set the grid
292
+ explicitly; it surfaced the moment a new one left it out (19.09.2026). No
293
+ existing golden changed — which is the proof that only the previously
294
+ undefined case is affected. The new fixture `grid_default` pins it.
295
+
296
+ **If you use the Go port and rely on the implicit grid, set it explicitly**
297
+ before upgrading: `axes: { x: { grid: { major: {} } }, left: { grid: { major: {} } } }`.
298
+
299
+ ---
300
+
301
+ ## [1.5.0] - 2026-09-19
302
+
303
+ ### Changed
304
+ - **A series is clipped to the plot area** (`clipSeries`, default `true`; set it to
305
+ `false` to opt out — every clipped group carries a `clip-path` and a browser may
306
+ give it its own layer, which is nothing for a handful of series and worth
307
+ measuring for dozens). Only thresholds were clipped before,
308
+ because series data is practically always inside the domain — with an automatic
309
+ domain it cannot be otherwise. The moment a caller *fixes* the time axis and
310
+ passes points outside it (the last reading before the window, so the curve runs
311
+ to the edge instead of starting in mid-air), the series painted into the axis
312
+ gutter: line and markers sat on top of the axis labels. A canvas that does not
313
+ keep to its own bounds makes every fixed range unusable. TS and Go; the fixture
314
+ goldens gained the clip and nothing else. Two new fixtures (`series_clip`,
315
+ `series_clip_off`) pin both switch positions — until now no fixture had data
316
+ outside its range, which is why nobody noticed. A demo card shows both side by
317
+ side (Styles → “Clip an der festen Zeitachse”).
318
+ - **A threshold is no longer labelled with its own name.** Leaving `label` out used
319
+ to mean “paint the name”. But `name` is an IDENTIFIER — it wires
320
+ `colorByThresholds`, fill regions and CSS classes — so an invisible anchor
321
+ (`line: 'none'`, used to colour a line by zone) shouted its internal name into
322
+ the chart: `z_hi`, `w_lo` right next to real captions like “Grenze ↑ 8”. That is
323
+ not a default, it is a leak. Now: nothing given, nothing drawn. `label: true`
324
+ asks for the name explicitly, a string or `{ text }` sets your own, and
325
+ `label: false` keeps working. TS and Go, one contract.
326
+
327
+ ---
328
+
329
+ ## [1.4.0] - 2026-09-18
330
+
331
+ ### Added
332
+ - **`getLineStyle` and `drawMarker` are public** (TypeScript). Both were internal,
333
+ and both are exactly what a caller needs to draw its **own** legend: a swatch
334
+ has to show the same dash pattern and the same symbol as the curve it names.
335
+ The built-in legend is left/right only and not clickable, so callers do draw
336
+ their own — and until now each of them re-implemented the dash table on the
337
+ outside. Such a copy drifts silently: the swatch then advertises a line the
338
+ chart does not contain, which only shows up on a black-and-white print, where
339
+ colour no longer tells the series apart. `drawMarker` emits `DrawCommand`s;
340
+ feed them to the already-exported `SVGRenderer` for SVG. The Go port keeps both
341
+ helpers internal for now; no renderer changed for this one.
342
+ - **`opaqueColor` / `hasAlpha`** (TypeScript, `patterns/hatch.js`): the two colour
343
+ rules the hatch derivation below is built on, exported so a caller can follow
344
+ the same rule. Mirrored 1:1 in Go (`pkg/renderer`, unexported).
345
+ - **`resolveDash(variant, strokeWidth?, dashed?)`** (TypeScript): what the renderer
346
+ *actually* draws, including the two historical exceptions — `dashed` and `dotted`
347
+ keep their fixed `"4,4"` / `"2,4"` patterns, everything else comes from the
348
+ scale-aware table. It used to be a private method of `SVGRenderer`, so a caller
349
+ drawing its own legend had to re-derive it and got `getLineStyle`'s `"6, 4"` for
350
+ `dashed`: a swatch dashed 6-on-4 beside a curve dashed 4-on-4. The renderer now
351
+ calls the exported function — one rule, one place. Output is byte-identical.
352
+ - **`LegendItem` carries `line` and `marker`** (TS + Go): the line variant of the
353
+ series and its marker shape, so `chart.legendItems()` is enough to draw a legend
354
+ that matches the curves. `marker` is omitted when the chart does not actually
355
+ draw one (a series whose `markers.threshold` hides them above n samples) —
356
+ a symbol in the legend that is missing from the chart states something untrue.
357
+ Both fields are optional and the built-in legend ignores them: nothing rendered
358
+ changes.
359
+ - **`LegendItem` and `DrawCommand` are exported from the main entry.** Both are
360
+ the types of main-entry functions (`chart.legendItems()`, `drawMarker`), so the
361
+ recipe below could not be written in typed code without them. The rest of the
362
+ DrawCommand model stays behind `/internals`.
363
+ - **Docs: „Drawing your own legend"** — USAGE.md gets the recipe and the reason a
364
+ coloured block stops working as soon as series differ by more than colour (any
365
+ print, any red-green deficiency); the manual (`book/`, chapter 4) gets the same
366
+ in prose. The legend demo now draws the swatch that way and hides a series on
367
+ click — it used to demonstrate the coloured block.
368
+
369
+ ### Changed
370
+ - **A hatch now takes the colour of the area it marks** (TS + Go). The pattern
371
+ lines were always `#4D88FF` — blue hatching on a red zone, on charts whose
372
+ colours *are* the statement. An extra colour there does not decorate, it says
373
+ something, and what it said was nothing. The lines now use the fill's colour at
374
+ full strength; a translucent fill stays the backdrop as given, an opaque one is
375
+ drawn at 30 % so the lines have something to stand out against. A caller that
376
+ wants a different line colour still passes one to `getHatch`.
377
+
378
+ `getHatch`'s `linecolor` parameter therefore no longer defaults to blue — it is
379
+ optional, and left out means "derive from the fill". The only fixture affected
380
+ is `hatch_patterns`; its Go golden was regenerated and parity re-checked.
381
+
382
+ ---
383
+
384
+ ## [1.3.3] - 2026-09-04
385
+
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.
393
+
394
+
395
+ ### Added
396
+ - **`scripts/render-book-images.mts`**: renders every fixture twice — light and
397
+ dark — into `book/images/`. There was no script at all before; the eighteen
398
+ figures in the manual were hand-copied Go goldens, which is why they were
399
+ stale the moment a renderer changed and why every one of them carried the
400
+ white background the golden test paints (`SetBackgroundColor("white")`) — a
401
+ white box on mlcgo.eu's dark pages. Both sets now come out of one run:
402
+ missing one of them would show a gap, not the other version.
403
+
404
+ ### Fixed
405
+ - **`setDefaultTheme()` only half worked (TS)**: `style/resolver.ts` read the
406
+ runtime theme, the other 132 accesses in the render path read the static
407
+ object from `theme/defaults.ts` — so setting a theme changed the series
408
+ colour and left the axes, grid, labels and legend alone. Worse than no theme
409
+ at all, and the documented example in `theme/runtime.ts` promised the
410
+ opposite. The `theme` facade now reads the runtime value.
411
+ - **`seriesType: "step"` drew a ramp, in both libraries (TS + Go)**: the older,
412
+ documented way to ask for a step chart was assigned, described in the model
413
+ docs — and read by nobody on the render path. Go never looked at
414
+ `SeriesType`; in TS `style/resolver.ts` knew the mapping but `MLTimeGraph`
415
+ took a different route and never asked it. `style.line.shape: "step"` was the
416
+ only thing that worked. The canonical `step_sensor` example therefore drew
417
+ diagonal transitions instead of steps — and the parity check could not see
418
+ it, because both libraries were wrong in the same way. A comparison of two
419
+ implementations finds no fault they share.
420
+
421
+ ## [1.3.1] - 2026-09-04
422
+
423
+ ### Fixed
424
+ - **Crash on a threshold without a label (Go)**: `Threshold.Label` is a pointer
425
+ and `nil` is the normal case — a threshold configured without an explicit
426
+ label. The tick-suppression pass added in 1.3.0 dereferenced it unchecked, so
427
+ `RenderCommands` panicked on every such chart. Found while integrating 1.3.0
428
+ into mlcsensor; a regression test now covers it.
429
+ - **A threshold without a label drew nothing in the Go port (Go)**: `nil` was
430
+ read as "no label" while the TypeScript side has always read it as "label
431
+ from the threshold's name" (`threshold_renderer.ts`: `if (t.label !== false)`
432
+ with `labelObj?.text ?? t.name`). The same JSON therefore produced a labelled
433
+ line in the browser and a bare one on the server — in the most common
434
+ configuration of all. Only an explicit `label: false` suppresses it now.
435
+ New fixture `threshold_no_label` covers the case in the parity test, which is
436
+ why nobody noticed: every existing fixture sets a label.
437
+
438
+ ## [1.3.0] - 2026-09-04
439
+
440
+ Includes everything that was bumped to 1.2.1 and 1.2.2 in `package.json` but never tagged and never
441
+ published — npm and the Go module both went from 1.2.0 straight to this release.
442
+
443
+ This release **changes what is drawn**, on both sides. Most of it is a rendering difference between
444
+ the two libraries being removed — the same JSON now produces the same chart in TypeScript and in Go
445
+ across all thirteen reference configurations, checked element by element on every test run. The
446
+ visible changes are listed under *Changed* and *Fixed*; the one to read before upgrading is the new
447
+ id scheme.
448
+
449
+ ### Added
450
+ - **Marker shapes `plus`, `triangle-down`, `hexagon`, `hourglass` and `line-horizontal` for series,
451
+ in both libraries**: they only ever existed in the TypeScript annotation renderer. A series could
452
+ not use them, and the Go port did not know them at all — a `pointStyle: "hexagon"` silently fell
453
+ through to a circle there.
454
+
455
+ ### Changed
456
+ - **Series id scheme (TS + Go, breaking)**: the prefix of every element id of a series was a
457
+ timestamp in TS (`id1788523516216-…`, different on every render) and the raw series name in Go
458
+ (`Temperatur (min/max/avg)-…` — with spaces and parentheses, not a valid id). Both sides now
459
+ derive it the same way: an explicit `id` from the configuration verbatim, otherwise
460
+ `s-<crc32 of the name>`. The same checksum in both languages, so a chart rendered on the server
461
+ and one rendered in the browser address the same elements. **If you select elements by id, your
462
+ selectors need updating.**
463
+ - **One marker drawing routine instead of two (TS)**: `annotation/marker.ts` kept its own. The same
464
+ `pointStyle` looked different depending on where it came from, and an annotation point had no
465
+ outline while a series point did. Annotations now use the same routine as series, which gives an
466
+ annotation point a 1.5px outline — 0.75px larger than before, and exactly what the Go port has
467
+ always drawn.
468
+ - **Per-series group in the Go port (Go)**: the port set no id on the `<g>` and wrote the raw name
469
+ into the class attribute — `class="series series-Solid Line"` is in fact three classes. Now as in
470
+ TS: `<g class="series series--solid-line" id="series-solid-line">`, so a whole measurement series
471
+ can be shown or hidden through one selector.
472
+ - **Axis stroke width (TS)**: `axes.*.axis.width` now defaults to `1` instead of `undefined`, so
473
+ the SVG carries `stroke-width="1"` on the axis line and its ticks. The Go port has always used
474
+ that default. The line looks the same — 1 is the SVG default — but the two outputs no longer
475
+ differ on every axis line, and an inherited `line { stroke-width: … }` from the embedding page no
476
+ longer drags the axis along.
477
+ - **Tooltip performance (from 1.2.1)**: `mousemove` is coalesced through `requestAnimationFrame`,
478
+ and `Intl` formatters are cached (`src/intl_cache.ts`).
479
+ - **Cleanup (from 1.2.2)**: refactoring for large time series, generated docs, formatting.
480
+
481
+ ### Fixed
482
+ - **`showAs: "minmaxavg"` in the Go port (Go)**: the port never evaluated `showAs`. An aggregated
483
+ series was reduced to its averages and drawn as one ordinary line in the default colour — no
484
+ boundaries, no fill, and `minColor`, `maxColor`, `avgColor`, `avgDashed`, `fillToMax`,
485
+ `fillToMin` were all ignored. The same JSON produced two entirely different pictures.
486
+ `renderer.RenderMinMaxAvg` now draws what the TypeScript side draws.
487
+ - **Marker lines and labels in the Go port (Go)**: `YRange` arrives as `[bottom, top]`, but the
488
+ names in the marker renderer were assigned by position — and were therefore swapped. A
489
+ `to-value` line ran from the top edge down to the point instead of up from the baseline,
490
+ `to-top` the other way round, and a marker label ended up at `yTop - 6`, i.e. **below** the plot
491
+ area (y=354 instead of y=14).
492
+ - **`style.line.shape: "step"` (TS)**: the type knew the field and `renderStep()` existed — nobody
493
+ in `MLTimeGraph` ever read it. A series configured as a step chart came out as a straight line in
494
+ the browser while the Go port drew the steps.
495
+ - **`colorByThresholds` against an explicit line colour (TS)**: the zone colour only applied when
496
+ no `style.line.color` was set, which made the option silently useless in almost every real
497
+ configuration. The base colour is now the default that the zone colour overrides, as in the Go
498
+ port.
499
+ - **Threshold references by id (TS)**: the lookup table was keyed by name only. A `fillSpec`
500
+ referring to a threshold by its `id` did not find it and threw — `thresholds_fill_demo` could not
501
+ be rendered in TypeScript at all, while the port produced the chart. The key is now the id, else
502
+ the name, as in the port and as for a threshold's CSS class.
503
+ - **Axis titles in the Go port (Go)**: `axes.{left,right,x}.label` was never drawn — the field
504
+ exists in the model, nobody read it. A chart with "Temp (°C)" on the left axis came out of the
505
+ backend without that title.
506
+ - **Grid style in the Go port (Go)**: `axes.*.grid.major.{color,width,opacity,style}` was ignored,
507
+ the port always used the theme values. A dashed grid at half opacity came out as a solid line at
508
+ full opacity.
509
+ - **Tick labels overprinted by threshold labels (Go)**: a threshold at 20 carrying a label
510
+ ("WARNING HIGH (20°C)") and the axis tick at the same height ("20") were drawn on top of each
511
+ other. The axis could prevent that all along — `ValueAxisConfig.SuppressLabelsNear` exists — but
512
+ nobody filled it in. The TypeScript side has done so since 7859993.
513
+ - **Marker stroke width and colour in the Go port (Go)**: `style.markers.stroke`, `.fill` and
514
+ `.strokeWidth` were not passed through at all — a configured marker colour had no effect — and
515
+ without one the stroke width was missing entirely instead of the theme's 1.5.
516
+ - **Duplicate ids on aggregated series (TS + Go)**: a minmaxavg series with a data gap is split
517
+ into several runs, and every run received the same ids — `<id>-max-line-0` appeared twice in one
518
+ document. Ids have to be unique: `getElementById` otherwise returns whichever element it finds
519
+ first, and `#id` in a stylesheet matches only one of the two. The fills now carry the run index
520
+ themselves (`-fillToMax-<run>-fill-0`), the lines get it through the segment index `renderLine`
521
+ appends anyway (`-max-line-0`, `-max-line-1`). Side effect: all fills now sit behind all lines
522
+ instead of only behind those of their own run.
523
+ - **Series id (TS)**: `"id" + Date.now + …` — without the parentheses. Every series without an id
524
+ of its own was therefore called `idfunction now() { [native code] }<n>`; with spaces and braces
525
+ that is not a valid id, and those elements were reachable neither through `getElementById` nor
526
+ through a CSS selector.
527
+ - **Gap labels (TS)**: the SVG renderer wrote `textBaseline="middle"` — that is the Canvas API
528
+ name; in SVG the attribute is called `dominant-baseline`. The browser ignored it silently and the
529
+ label sat vertically off its intended position. The Go port was never affected.
530
+ - **Alignment of text edges (TS + Go)**: `textBaseline: "top" | "bottom"` was passed through to
531
+ `dominant-baseline` unchanged. Those are not valid values there, the browser fell back to `auto`,
532
+ and the label sat on its baseline instead of at the intended edge. Both libraries now map to
533
+ `text-top` / `text-bottom`.
534
+ - **Star shape of annotation markers (TS)**: an annotation's star was drawn with inner radius 0.4,
535
+ a series' star with 0.5 — the same `pointStyle: "star"` looked different depending on where it
536
+ came from. Both are 0.5 now, as in the Go port.
537
+ - **Hatch pattern numbering (Go)**: the port counted from 1, the TypeScript side from 0 — the same
538
+ drawing referred to `hatch-dots-0` in the browser and `hatch-dots-1` on the server.
539
+ - **Mini axis of an annotation band in the Go port (Go)**: it was written into the band as loose
540
+ lines instead of its own `annotation-band-axis` group, as the TypeScript side does — it could not
541
+ be addressed as a whole.
542
+ - **Smoothing control points (TS)**: after rounding to two decimals the renderer truncated again at
543
+ three (`Math.trunc(x * 1000) / 1000`). That could not improve anything but could make it worse:
544
+ 259.83 is not exact in binary, times 1000 gives 259829.99999999997, and out came 259.829. The
545
+ step is gone.
546
+ - **Zone crossing timestamps (TS)**: rounded to whole milliseconds. The Go port cannot do otherwise
547
+ — its timestamp is an `int64` — and without the rounding the crossing points of the two libraries
548
+ drifted apart from the sixth decimal onwards.
549
+ - **Large data series (from 1.2.1)**: `Math.min(...arr)` / `Math.max(...arr)` replaced with
550
+ explicit loops. The spread blows the call stack on long series
551
+ (`RangeError: Maximum call stack size exceeded`).
552
+
553
+ ## [1.2.0] - 2026-08-28
554
+
555
+ ### Added
556
+ - **Configurable Axis Offsets**: Added `offset?: number` (TS) and `Offset *float64` (Go) to `YAxisConfig` for explicit pixel placement of stacked vertical axes, eliminating label collisions when using custom units/formatters.
557
+ - **Go Interactive Coordinate Math**: Added `Project(timeMs, value, axisIndex)`, `InvertTime(px)`, and `InvertValue(py, axisIndex)` methods to Go's `MLTimeGraph` for 1:1 parity with the TypeScript interactive calculations.
558
+ - **Fluent Builder Extensions**:
559
+ - TypeScript `TimeSeriesBuilder`: Added `setYAxisIndex()`, `setColor()`, and `setData()`.
560
+ - Go `GraphBuilder` & `TimeSeriesBuilder`: Added `AddSeries()`, `SetYAxis()`, `SetYAxisIndex()`, `SetLineColor()`, and `SetColor()`.
561
+ - **Interactive Multi-Axis Demo**: Added comprehensive multi-axis examples to the demo gallery (`demos/src/demos/multi-axis.ts`), including an Environmental Station (4 axes: 2 left, 2 right) and Industrial Telemetry Dashboard (4 axes: 1 left, 3 right stacked) with external HTML legends.
562
+
563
+ ### Fixed
564
+ - **Time-Axis Baseline Span**: Fixed horizontal time-axis baseline rendering in both TypeScript (`TimeAxis.render`) and Go (`TimeAxis.Render`) to span the complete chart plot width (`[x0, x1]`) instead of cutting off at the last tick coordinate.
565
+ - **Multi-Axis Placement Parity**: Fixed an issue where vertical axes with index $\ge 2$ were forced to the right side; both engines now respect `position: "left" | "right"` for any index.
566
+ - **Demo Container Widths**: Adjusted zoom and rolling MKT demo charts to fit within card container boundaries with dynamic viewBox ratio calculations for brush interactions.
567
+ - **Internationalization**: Translated all German UI text, demo titles, descriptions, and code comments to English.
568
+
569
+ ### Changed
570
+ - **Modularized Graph Builders**: Refactored monolithic `graph_builder.ts` into modular classes under `packages/ml-time-graph/src/builders/`.
571
+ - **Modularized Spatial Math**: Refactored `spatial.ts` in `ml-time-analyze` into a structured module under `src/spatial/`.
572
+ - **Code Formatting**: Adopted Prettier across all TypeScript and JavaScript sources.
573
+ - **Documentation**: Updated `USAGE.md`, `BUILDER.md`, `JSON_CONFIG.md`, `API_REFERENCE.md`, and READMEs with multi-axis and coordinate conversion guides.
574
+
575
+ ---
576
+
577
+ ## [1.1.1] - 2026-08-28
578
+
579
+ ### Added
580
+ - **`attachTooltip` Documentation & API**: Detailed usage guide for tooltip integration, hover picks, and server-side DOM-free SVG export.
581
+ - **`SKILLS.md` Guide**: 60-second architecture map and workflow guide for developers and agents.
582
+
583
+ ### Fixed
584
+ - **Tooltip Viewport Flipping**: Improved tooltip positioning to flip automatically across cursor axes when nearing plot area edges.
585
+
586
+ ---
587
+
588
+ ## [1.1.0] - 2026-08-28
589
+
590
+ ### Added
591
+ - **Go Locale-Aware Time Formatting**: Added dependency-free i18n date/time formatting for Go (`en-US`, `de-DE`, `fr-FR`, `es-ES`, etc.).
592
+
593
+ ### Fixed
594
+ - **Value Axis Tick De-duplication**: Resolved duplicate rounded tick labels on value axes with small numeric domains.
595
+ - **Annotation Band Vertical Alignment**: Centered labels vertically within annotation bands across TypeScript and Go.
596
+
597
+ ---
598
+
599
+ ## [1.0.7] - 2026-08-28
600
+
601
+ ### Added
602
+ - **Lockstep Release Workflow**: Unified versioning across `packages/ml-time-graph` and `go-time-graph`.
603
+ - **SVG Baseline Gallery**: Comprehensive golden rendering test suite for Go chart rendering.
@@ -117,7 +117,7 @@ Varianten hängen Arrays an. Alle geben `this` zurück.
117
117
  Beispiele:
118
118
 
119
119
  ```ts
120
- // Schwellwert: `fill` ist eine Zeichenkette ("above" | "below" | "none") und
120
+ // Schwellenwert: `fill` ist eine Zeichenkette ("above" | "below" | "none") und
121
121
  // `line` ist eine Zeichenkette ("solid" | "dashed" | "dotted" | "none");
122
122
  // die Deckkraft ist ein separates Feld.
123
123
  g.addThreshold({
package/README.de.md CHANGED
@@ -8,7 +8,7 @@ schnell und unkompliziert aufbereiten, mit Fokus auf Reporting und Incident-Anal
8
8
  > Voll typisiert · i18n-aware · DOM-freier SVG-Renderer (Browser & serverseitig) · keine Laufzeit-Abhängigkeiten · ESM-only
9
9
 
10
10
  > 🤖 **Sie arbeiten mit einem KI-Assistenten?** Geben Sie ihm
11
- > **[SKILLS.md](SKILLS.md)** — die Datei wird mitgeliefert und liegt nach
11
+ > **[SKILLS.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/SKILLS.md)** — die Datei wird mitgeliefert und liegt nach
12
12
  > `npm install` unter `node_modules/ml-time-graph/SKILLS.md`. Eine Seite: der
13
13
  > kürzeste Weg zum Diagramm, die vier Einstiegspunkte, die üblichen Aufgaben und
14
14
  > ein Abschnitt **Traps** für die Stellen, an denen ein Modell danebengreift
@@ -77,21 +77,25 @@ mount('#chart', {
77
77
  ## Galerie
78
78
 
79
79
  <p align="center">
80
- <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex1.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex1.svg" alt="Linie mit Zonen-Färbung und Threshold-Fills" width="300"></a>
81
- <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex2.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex2.svg" alt="Multi-Zonen-Hatch-Fills" width="300"></a>
80
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex1.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex1.svg" alt="Linie nach Schwellenwert-Zonen eingefärbt, mit Datenlücken" width="300"></a>
81
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex2.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex2.svg" alt="Min/Max/Avg-Band mit schraffierten Flächen" width="300"></a>
82
82
  <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex3.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex3.svg" alt="stdDevBand + movingMkt-Overlays auf einem Sensorstrom" width="300"></a>
83
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex4.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex4.svg" alt="Annotationsbänder markieren Betriebszustände unter dem Diagramm" width="300"></a>
83
84
  </p>
84
85
 
85
- Typische Sensor-Darstellung (links), Multi-Zonen-Schraffuren für
86
- Incident-Reports (Mitte), Sensorstrom mit Statistik-Overlays (rechts:
87
- ±2σ-Band + 12-h-MKT) — alles dieselbe Library, alle in der
88
- Demo-Galerie zu sehen (`pnpm dev`).
86
+ Typische Sensor-Darstellung, Min/Max/Avg mit Schraffuren für
87
+ Incident-Reports, ein Sensorstrom mit Statistik-Overlays (±2σ-Band +
88
+ 12-h-MKT) und Annotationsbänder, die Betriebszustände und Ereignisse
89
+ *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
92
+ `node scripts/make-examples.mjs`.
89
93
 
90
94
  ---
91
95
 
92
96
  ## 🔄 Go-Port & 1:1 Rendering-Parität
93
97
 
94
- 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/go-time-graph)**.
98
+ 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)**.
95
99
 
96
100
  Sowohl die TypeScript- als auch die Go-Bibliothek:
97
101
  - Verarbeiten das **exakt gleiche JSON-Konfigurationsschema**.
@@ -101,6 +105,48 @@ Sowohl die TypeScript- als auch die Go-Bibliothek:
101
105
 
102
106
  ---
103
107
 
108
+ ## 🐞 Fehler gefunden?
109
+
110
+ Issues liegen unter
111
+ [gitlab.com/mlc0911/mlctimegraph/-/issues](https://gitlab.com/mlc0911/mlctimegraph/-/issues).
112
+ Die Vorlagen fragen nach deinen Chart-Optionen — damit wird aus einer Meldung in
113
+ Minuten ein fehlschlagender Test. Einzelheiten in
114
+ [CONTRIBUTING.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CONTRIBUTING.md).
115
+
116
+ ---
117
+
118
+ ## 📜 Versionsverlauf
119
+
120
+ Beide Bibliotheken werden im Gleichschritt unter einer Versionsnummer veröffentlicht —
121
+ deshalb gibt es **ein** Changelog für beide: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CHANGELOG.md).
122
+ Es liegt auch dem Paket bei — die Historie genau der Version, die du installiert hast, liegt
123
+ damit neben dem Code.
124
+
125
+ ---
126
+
127
+ ## 📄 PDF-Ausgabe
128
+
129
+ Die Engine zeichnet kein SVG — sie erzeugt eine Liste von Zeichenbefehlen, und SVG ist ein
130
+ Abnehmer dieser Liste. **[mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf)** ist der
131
+ zweite: Es geht dieselben Befehle durch und schreibt native PDF-Vektoren. Kein Browser, kein
132
+ SVG-Parsen, kein Headless-Chromium — und es ist dasselbe Diagramm, weil es aus denselben
133
+ Befehlen kommt.
134
+
135
+ Es liest dasselbe JSON, mit dem auch das Diagramm konfiguriert wird:
136
+
137
+ ```bash
138
+ go get gitlab.com/mlc0911/mlctimegraphpdf
139
+ mtg-pdf -in chart.json -out chart.pdf
140
+ ```
141
+
142
+ Noch jung: Version 0.2.0, nicht 1.0, und ein, zwei Fähigkeiten hinter dieser Bibliothek. Was man
143
+ vorher wissen sollte — eine Füllung auf einem *Pfad*, also die Fläche unter einer Linie oder
144
+ einer Treppe, kommt derzeit deckend und ohne Schraffur heraus, weil nur Rechtecke beides
145
+ durchreichen. Linien, Marker, Text, Strichmuster, Kurvengeometrie und rechteckige Füllungen sind
146
+ da.
147
+
148
+ ---
149
+
104
150
  ## Warum schon wieder eine neue Library?
105
151
 
106
152
  Alle Libraries, die ich in der Vergangenheit professionell genutzt habe, haben
package/README.md CHANGED
@@ -8,7 +8,7 @@ clear, readable charts quickly, with a focus on reporting and incident analysis.
8
8
  > Fully typed · i18n-aware · DOM-free SVG output (browser & server) · zero runtime dependencies · ESM-only
9
9
 
10
10
  > 🤖 **Working with an AI coding assistant?** Point it at
11
- > **[SKILLS.md](SKILLS.md)** — it ships inside the package, so after
11
+ > **[SKILLS.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/SKILLS.md)** — it ships inside the package, so after
12
12
  > `npm install` it sits at `node_modules/ml-time-graph/SKILLS.md`. One page:
13
13
  > the shortest path to a chart, the four entry points, the recipes, and a
14
14
  > **Traps** section for the places a model guesses wrong (timestamps are epoch
@@ -77,21 +77,25 @@ mount('#chart', {
77
77
  ## Gallery
78
78
 
79
79
  <p align="center">
80
- <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex1.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex1.svg" alt="Line chart with zoned colouring + threshold fills" width="300"></a>
81
- <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex2.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex2.svg" alt="Hatched multi-zone threshold fills" width="300"></a>
82
- <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex3.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex3.svg" alt="stdDevBand + movingMkt-Overlays on a sensor stream" width="300"></a>
80
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex1.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex1.svg" alt="Line coloured by threshold zones, with gaps" width="300"></a>
81
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex2.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex2.svg" alt="Min/max/avg band with hatched fills" width="300"></a>
82
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex3.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex3.svg" alt="stdDevBand + movingMkt overlays on a sensor stream" width="300"></a>
83
+ <a href="https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/packages/ml-time-graph/ex4.svg"><img src="https://gitlab.com/mlc0911/mlctimegraph/-/raw/main/packages/ml-time-graph/ex4.svg" alt="Annotation bands marking operating states below the chart" width="300"></a>
83
84
  </p>
84
85
 
85
- A typical sensor visualisation (left), multi-zone hatched fills for
86
- incident-style reports (center), and a sensor stream with statistic
87
- overlays (right: ±2σ band + 12 h MKT) — all rendered with the same
88
- library, all live in the demo gallery (`pnpm dev`).
86
+ A typical sensor visualisation, min/max/avg with hatched fills for
87
+ incident-style reports, a sensor stream with statistic overlays (±2σ band +
88
+ 12 h MKT), and annotation bands marking operating states and events *below*
89
+ 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
92
+ `node scripts/make-examples.mjs`.
89
93
 
90
94
  ---
91
95
 
92
96
  ## 🔄 Go Port & 1:1 Rendering Parity
93
97
 
94
- 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/go-time-graph)**.
98
+ 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)**.
95
99
 
96
100
  Both the TypeScript and Go libraries:
97
101
  - Process the **exact same JSON configuration schema**.
@@ -101,6 +105,45 @@ Both the TypeScript and Go libraries:
101
105
 
102
106
  ---
103
107
 
108
+ ## 🐞 Found a bug?
109
+
110
+ Issues live at
111
+ [gitlab.com/mlc0911/mlctimegraph/-/issues](https://gitlab.com/mlc0911/mlctimegraph/-/issues).
112
+ The templates ask for your chart options — with them a report becomes a failing
113
+ test in minutes. [CONTRIBUTING.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CONTRIBUTING.md) has the details.
114
+
115
+ ---
116
+
117
+ ## 📜 Release history
118
+
119
+ Both libraries are released in lockstep on one version number, so there is **one**
120
+ changelog for both: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CHANGELOG.md).
121
+ It ships with this package too, so the history of the exact version you installed is right
122
+ next to the code.
123
+
124
+ ---
125
+
126
+ ## 📄 PDF Output
127
+
128
+ The engine does not draw SVG — it produces a list of draw commands, and SVG is one consumer
129
+ of that list. **[mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf)** is the second
130
+ one: it walks the same commands and writes native PDF vectors. No browser, no SVG parsing, no
131
+ headless Chromium — and it is the same chart, because it comes from the same commands.
132
+
133
+ It reads the same JSON your chart is configured with:
134
+
135
+ ```bash
136
+ go get gitlab.com/mlc0911/mlctimegraphpdf
137
+ mtg-pdf -in chart.json -out chart.pdf
138
+ ```
139
+
140
+ Early days: it is at 0.2.0, not 1.0, and trails this library by a feature or two. Worth knowing
141
+ before you rely on it — a fill on a *path* (the area under a line or a step) currently renders
142
+ opaque and without its hatch pattern, because only rectangles carry those through. Lines,
143
+ markers, text, dash patterns, curve geometry and rectangular fills are there.
144
+
145
+ ---
146
+
104
147
  ## Why another chart library?
105
148
 
106
149
  Every charting library I relied on professionally eventually switched its license
package/SKILLS.md CHANGED
@@ -32,6 +32,7 @@ mount('#chart', {
32
32
  - `new MLTimeGraph(options)`: The core headless engine when working with options objects directly — use for Node.js SSR, headless testing, or custom render pipelines.
33
33
  - Builders (`GraphBuilder`, etc.): The fluent, imperative chaining API — use when assembling charts dynamically across conditional branches.
34
34
  - Go port (`go-time-graph`): The 1:1 server-side Go implementation (`gitlab.com/mlc0911/mlctimegraph/go-time-graph`) — use when rendering charts in Go backends or microservices without a Node runtime.
35
+ - PDF output (`mlctimegraph-pdf`): A second consumer of the same draw commands (`gitlab.com/mlc0911/mlctimegraphpdf`) — writes native PDF vectors without a browser. Early (0.2.0); a fill on a path is still opaque and unhatched there.
35
36
 
36
37
  ## Package Entry Points
37
38
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './series_renderer-DQXKJttA.js';
2
- export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme } from './series_renderer-DQXKJttA.js';
1
+ import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './series_renderer-COVNvq2x.js';
2
+ export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme } from './series_renderer-COVNvq2x.js';
3
3
  import { L as LineVariant, A as AnySeries, T as Threshold, H as Highlight, G as Gap, a as GapsConfig, b as Annotation, c as AnnotationBandConfig, D as DrawCommand, d as TimeScale, e as LinearScale, S as SeriesStyle, F as FillSpec, f as TimeSeries, g as HatchVariant, h as ThresholdLabelPosition, P as PointStyleType, i as AnnotationBandItem, j as AggregatedPoint, k as AggregatedSeries, l as DataPoint } from './scale-D6NtEaUB.js';
4
4
  export { m as AggregationConfig, n as AggregationMode, o as DataPointRef, E as EnumMap, p as FillBound, q as FillDirectionType, r as FillRegion, s as FillSide, t as FillStyle, u as GapConfig, v as GapLabel, w as GapRegion, x as GapStyle, y as LineDashStyle, z as LineStyle, M as MarkerStyle, B as SVGLineStyle, C as SensorType, I as SeriesOverlay, J as SeriesOverlayKind, K as SeriesType, N as ShadowStyle, O as ThresholdLabelConfig, Q as getLineStyle, R as resolveDash } from './scale-D6NtEaUB.js';
5
5
 
@@ -1,5 +1,5 @@
1
- import { T as Theme, M as Marker } from './series_renderer-DQXKJttA.js';
2
- export { e as Layout, f as LayoutConfig, b as LayoutResult, h as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, i as renderArea, j as renderLegend, k as renderLine, l as renderSeriesMarkers, n as renderSplitLine, o as renderStep, p as renderZonedArea } from './series_renderer-DQXKJttA.js';
1
+ import { T as Theme, M as Marker } from './series_renderer-COVNvq2x.js';
2
+ export { e as Layout, f as LayoutConfig, b as LayoutResult, h as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, i as renderArea, j as renderLegend, k as renderLine, l as renderSeriesMarkers, n as renderSplitLine, o as renderStep, p as renderZonedArea, t as toStepData, q as toStepPoints } from './series_renderer-COVNvq2x.js';
3
3
  import { D as DrawCommand, T as Threshold, e as LinearScale, G as Gap, d as TimeScale, g as HatchVariant, H as Highlight, b as Annotation, E as EnumMap, U as BandScale, l as DataPoint, P as PointStyleType, V as Point, j as AggregatedPoint, i as AnnotationBandItem, L as LineVariant, F as FillSpec, x as GapStyle, f as TimeSeries } from './scale-D6NtEaUB.js';
4
4
  export { W as AxisOrientation, X as AxisPosition, Y as BandScaleConfig, Z as CircleParams, _ as Dashstyle_t, $ as DomainScaleConfig, a0 as DrawCircle, a1 as DrawGap, a2 as DrawGapType_t, a3 as DrawGradient, a4 as DrawGroup, a5 as DrawLine, a6 as DrawPath, a7 as DrawRect, a8 as DrawText, a9 as LabelAnchor, aa as LineParams, ab as LinearScaleConfig, ac as PathParams, ad as RectParams, ae as Scale, af as ScaleConfig, ag as TIME_INTERVALS, ah as TextParams, ai as TimeScaleConfig, aj as getHatch } from './scale-D6NtEaUB.js';
5
5
 
package/dist/internals.js CHANGED
@@ -1,4 +1,4 @@
1
- var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((l,i)=>l.time-i.time),r=[],o=[],s=null;for(let l of n){let i=e(l),m=t>0&&s&&l.time-s.time>t;(i||m)&&o.length&&(r.push(o),o=[]),i||o.push(l),s=l;}return o.length&&r.push(o),r}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},i=[a[0]];for(let m=1;m<a.length;m++){let u=a[m-1],c=a[m],d=t(u),p=t(c),f;p>d?f=r.filter(b=>b>d&&b<=p):p<d?f=r.filter(b=>b>=p&&b<d).reverse():f=[];let g=d;for(let b of f){let y=(b-d)/(p-d),x=n(u,c,y);i.push(x);let C=l((g+b)/2);o.push({data:i,zoneIndex:C,zoneLow:s(C)}),i=[x],g=b;}(f.length===0||f[f.length-1]!==p)&&i.push(c);}if(i.length>1){let m=t(i[0]),u=t(i[i.length-1]),c=l((m+u)/2);o.push({data:i,zoneIndex:c,zoneLow:s(c)});}return o}static splitByThreshold(a,e,t,n){let r=this.splitByBoundaries(a,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};var ce=class{static compute(a){let e=a.map(l=>l.value).filter(l=>l!==null).sort((l,i)=>l-i);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,i)=>l+i,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,i)=>l+Math.pow(i-n,2),0)/t,s=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:s,count:t}}static computeInRange(a,e,t){let n=a.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};var de={stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var we={...de};function T(){return we}function Ce(a){let e=a.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function Te(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function he(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Ce(t),s=Te(t)?"":' fill-opacity="0.3"';if(e==="none")return `
1
+ var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((l,i)=>l.time-i.time),r=[],o=[],s=null;for(let l of n){let i=e(l),m=t>0&&s&&l.time-s.time>t;(i||m)&&o.length&&(r.push(o),o=[]),i||o.push(l),s=l;}return o.length&&r.push(o),r}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},i=[a[0]];for(let m=1;m<a.length;m++){let u=a[m-1],c=a[m],d=t(u),p=t(c),f;p>d?f=r.filter(b=>b>d&&b<=p):p<d?f=r.filter(b=>b>=p&&b<d).reverse():f=[];let g=d;for(let b of f){let y=(b-d)/(p-d),x=n(u,c,y);i.push(x);let C=l((g+b)/2);o.push({data:i,zoneIndex:C,zoneLow:s(C)}),i=[x],g=b;}(f.length===0||f[f.length-1]!==p)&&i.push(c);}if(i.length>1){let m=t(i[0]),u=t(i[i.length-1]),c=l((m+u)/2);o.push({data:i,zoneIndex:c,zoneLow:s(c)});}return o}static splitByThreshold(a,e,t,n){let r=this.splitByBoundaries(a,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};var ce=class{static compute(a){let e=a.map(l=>l.value).filter(l=>l!==null).sort((l,i)=>l-i);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,i)=>l+i,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,i)=>l+Math.pow(i-n,2),0)/t,s=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:s,count:t}}static computeInRange(a,e,t){let n=a.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};var de={stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var Ce={...de};function T(){return Ce}function Te(a){let e=a.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function Le(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function he(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Te(t),s=Le(t)?"":' fill-opacity="0.3"';if(e==="none")return `
2
2
  <pattern id="${a}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${t}" />
4
4
  </pattern>
@@ -21,10 +21,10 @@ var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time
21
21
  ${c}
22
22
  ${u}
23
23
  </pattern>
24
- `.trim()}var h=new Proxy({},{get:(a,e)=>T()[e],has:(a,e)=>e in T(),ownKeys:()=>Reflect.ownKeys(T()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(T(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((s,l)=>s+l.data.length,0),o=H(t);for(let s=0;s<a.length;s++){let l=a[s];l.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${s}`:void 0,points:l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:l.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):l.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:l.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Le(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function G(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let s=a[o];if(s.data.length<2)continue;let l=Le(s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:s.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function De(a,e,t,n,r){let o=[],s=H(t);for(let l=0;l<a.length;l++){let i=a[l];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:i.color??s.fill,hatch:t.hatch,stroke:"none"});}return o}function N(a,e,t,n){if(a.length<2)return [];let r=S.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let l=r[s];if(l.data.length<2)continue;let i=t.getColor(l.zoneIndex);if(!i)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function Me(a,e,t,n){let r=S.splitByThreshold(a,e,s=>s.value,S.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(s=>({data:s})),t,n.below)),n.above&&o.push(...w(r.above.map(s=>({data:s})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<a.length;s++){let l=a[s],i=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,s,l,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:s,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:s,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});}}var D=12,V=8,X=20,_e=11,Z=18,U=a=>a.length*_e*.6;function $e(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=D+V+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:D+V+t,height:a.length*X}}function Fe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],s=t;return e.forEach((l,i)=>{let m=r==="horizontal"?s:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:D,h:D,fill:l.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:l.name,x:m+D+V,y:u+D-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(s+=D+V+U(l.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function Pe(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:s=h.gridStrokeWidth,dashed:l=false,opacity:i=h.gridOpacity}=a,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:s,dashed:l,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:s,dashed:l,opacity:i});return m}var pe=new Map;function We(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=We(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var M=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,s]=this.#t;return r===n?o:o+(t-n)/(r-n)*(s-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),s=o-r;if(s<=0)return {interval:k[0].ms};let l=s/e,i=k[0].ms;for(let c of k)if(c.ms>=l){i=c.ms;break}let m=i,u=Math.round(s/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(s/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(s/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,s]=this.#e.domain(),l=[],i=Math.ceil(o/r)*r;for(let m=i;m<=s;m+=r)l.push(m);return l}format(e,t){return A(this.#t,t).format(new Date(e))}},O=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let s=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-s,i=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*i+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),s=Math.abs(e-o);s<n&&(n=s,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Ae(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[s,l]=t.range(),i=Math.min(s,l),m=Math.max(s,l),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Ae(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let b=typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,x=b?.position??"right";c.push({...Ie(y,x,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Oe(a){let e=Re(a);return [...e.inside,...e.labels]}function Ie(a,e,t,n,r,o,s){let l=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function je(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:s=h.gapFillOpacity??.15,stroke:l=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let x=t.map(y.startTime),C=t.map(y.endTime),L=y.fill??r,P=y.hatch??o,me=y.fillOpacity??s,ue=y.label??"",Se=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me,stroke:l,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me}),ue){let ke=Be(f,g,E),ve=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(x+C)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function Be(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function He(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,s]=r,l=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?l.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),c!=="none"&&Y(l,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;l.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),i.label&&l.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return l}function Ne(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,s]=n,l=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);l.push({type:"rect",x:m,y:o,w:u-m,h:s-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&l.push({type:"text",content:i.label,x:(m+u)/2,y:Ve(i.labelPosition??"top",o,s,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return l}function Ve(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ee(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=s=>{let l=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:l?l.map(s.value):0}};for(let s of e){let l=[],i=m=>l.push(m);switch(s.type){case "line":{let m=o(s.from),u=o(s.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:s.color??h.annotationColor,strokeWidth:s.width??h.annotationWidth,dash:s.dash});break}case "arrow":{let m=o(s.from),u=o(s.to),c=s.color??h.annotationColor,d=s.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:s.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(s.from),u=o(s.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let m=o(s.at),u=s.color??"#334155",c=s.radius??h.annotationRadius,d=s.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(s.at);i({type:"text",content:s.text,x:m.x+(s.dx??0),y:m.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:h.annotationFontSize,fill:s.color??h.annotationColor,rotate:s.rotate});break}}if(s.id&&l.length>0){let m=q(s.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}var K=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
24
+ `.trim()}var h=new Proxy({},{get:(a,e)=>T()[e],has:(a,e)=>e in T(),ownKeys:()=>Reflect.ownKeys(T()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(T(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((s,l)=>s+l.data.length,0),o=H(t);for(let s=0;s<a.length;s++){let l=a[s];l.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${s}`:void 0,points:l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:l.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):l.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:l.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function pe(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function De(a){let e=[];for(let t of a)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function G(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let s=a[o];if(s.data.length<2)continue;let l=pe(s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:s.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function Me(a,e,t,n,r){let o=[],s=H(t);for(let l=0;l<a.length;l++){let i=a[l];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:i.color??s.fill,hatch:t.hatch,stroke:"none"});}return o}function N(a,e,t,n){if(a.length<2)return [];let r=S.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let l=r[s];if(l.data.length<2)continue;let i=t.getColor(l.zoneIndex);if(!i)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function _e(a,e,t,n){let r=S.splitByThreshold(a,e,s=>s.value,S.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(s=>({data:s})),t,n.below)),n.above&&o.push(...w(r.above.map(s=>({data:s})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<a.length;s++){let l=a[s],i=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,s,l,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:s,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:s,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});}}var D=12,V=8,X=20,$e=11,Z=18,U=a=>a.length*$e*.6;function Fe(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=D+V+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:D+V+t,height:a.length*X}}function Pe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],s=t;return e.forEach((l,i)=>{let m=r==="horizontal"?s:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:D,h:D,fill:l.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:l.name,x:m+D+V,y:u+D-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(s+=D+V+U(l.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function We(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:s=h.gridStrokeWidth,dashed:l=false,opacity:i=h.gridOpacity}=a,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:s,dashed:l,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:s,dashed:l,opacity:i});return m}var fe=new Map;function Ae(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=Ae(a,e),n=fe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),fe.set(t,n)),n}var M=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,s]=this.#t;return r===n?o:o+(t-n)/(r-n)*(s-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),s=o-r;if(s<=0)return {interval:k[0].ms};let l=s/e,i=k[0].ms;for(let c of k)if(c.ms>=l){i=c.ms;break}let m=i,u=Math.round(s/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(s/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(s/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,s]=this.#e.domain(),l=[],i=Math.ceil(o/r)*r;for(let m=i;m<=s;m+=r)l.push(m);return l}format(e,t){return A(this.#t,t).format(new Date(e))}},O=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let s=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-s,i=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*i+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),s=Math.abs(e-o);s<n&&(n=s,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Re(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Oe(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[s,l]=t.range(),i=Math.min(s,l),m=Math.max(s,l),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Re(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let b=typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,x=b?.position??"right";c.push({...je(y,x,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Ie(a){let e=Oe(a);return [...e.inside,...e.labels]}function je(a,e,t,n,r,o,s){let l=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function Be(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:s=h.gapFillOpacity??.15,stroke:l=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let x=t.map(y.startTime),C=t.map(y.endTime),L=y.fill??r,P=y.hatch??o,me=y.fillOpacity??s,ue=y.label??"",ke=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me,stroke:l,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me}),ue){let ve=He(f,g,E),we=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(x+C)/2,y:ve,anchor:"middle",fontSize:u,fill:c,textBaseline:we,rotate:ke});}}return b}function He(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Ne(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,s]=r,l=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?l.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),c!=="none"&&Y(l,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;l.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),i.label&&l.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return l}function Ve(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,s]=n,l=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);l.push({type:"rect",x:m,y:o,w:u-m,h:s-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&l.push({type:"text",content:i.label,x:(m+u)/2,y:Ee(i.labelPosition??"top",o,s,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return l}function Ee(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function ze(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=s=>{let l=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:l?l.map(s.value):0}};for(let s of e){let l=[],i=m=>l.push(m);switch(s.type){case "line":{let m=o(s.from),u=o(s.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:s.color??h.annotationColor,strokeWidth:s.width??h.annotationWidth,dash:s.dash});break}case "arrow":{let m=o(s.from),u=o(s.to),c=s.color??h.annotationColor,d=s.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:s.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(s.from),u=o(s.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let m=o(s.at),u=s.color??"#334155",c=s.radius??h.annotationRadius,d=s.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(s.at);i({type:"text",content:s.text,x:m.x+(s.dx??0),y:m.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:h.annotationFontSize,fill:s.color??h.annotationColor,rotate:s.rotate});break}}if(s.id&&l.length>0){let m=q(s.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}var K=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
25
25
  `);return `<clipPath id="${e}">
26
26
  ${t}
27
- </clipPath>`}get regions(){return [...this.#e]}};var I={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??I,n=this.#t.y??0,r=[],[o,s]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:l.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ze(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ge(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??ze,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,r]=this.#e.domain(),o=Math.min(n,r),s=Math.max(n,r),l=s-o;if(l===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=l/t,m=Math.pow(10,Math.floor(Math.log10(i))),u=i/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],p=Math.ceil(o/c)*c;for(let f=p;f<=s;f+=c)d.push({value:f,position:this.#e.map(f),label:e(f)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,i=u=>s.some(c=>Math.abs(c-u)<=l),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ge(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new O({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((s,l)=>{let i=Number(s),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[l%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:11,fill:r.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,r=e.gapThreshold??h.gapThreshold,o=e.id,s=S.getRuns(this.data,c=>c.value===null,r),l=s.reduce((c,d)=>c+d.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=s.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of s)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),s=e.map(t[r].value);r===0?n.push({x:o,y:s}):n.push({x:o,y:n[n.length-1].y},{x:o,y:s});}return n}render(){let e=S.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,s=e.bandWidth??10,l=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=s,p=this.data.indexOf(i);if(l.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);l.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return l}};var oe=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,r=e.avgColor??h.avgColor,o=e.avgDashed??true,s=e.smoothing??false,l=e.strokeWidth??h.strokeWidth,i=S.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:l,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,s=S.getRuns(this.data,u=>u.value===null,r),l=s.reduce((u,c)=>u+c.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of s){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=S.splitByBoundaries(u,[f],y=>y.value,S.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let x=g[y];if(x.data.length<2)continue;let C=x.zoneIndex>0;if(e.fill.side==="above"===C){let L=x.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...L,{x:L[L.length-1].x,y:b},{x:L[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=S.splitByBoundaries(u,c,f=>f.value,S.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...W(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return m}};var Ye=1,ae=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:s,y:l,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:s[0],y:l,w:s[1]-s[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(d<s[0]||c>s[1])continue;let p=Math.max(s[0],Math.min(s[1],c)),f=Math.max(s[0],Math.min(s[1],d)),g=Math.max(f-p,Ye);p+g>s[1]&&(p=Math.max(s[0],s[1]-g));let b=p+g/2;if(m.push({type:"rect",x:p,y:l,w:g,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let y=u.labelFontSize??10;m.push({type:"text",content:u.label,x:b,y:this.#t(u.labelBaseline,y),anchor:"middle",fontSize:y,fill:u.labelFill??"#333"});}}if(o){let u=new j({domain:t.domain(),xRange:s,y:l+i+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:s=true,showMedian:l=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:s},{name:"median",value:c.median,enabled:l}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:m,strokeWidth:1});let x=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:x,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:x,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:x,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var _=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,s=36e5,l=6e4,i={};return r<l?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<s?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var $=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var F=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new a({map:n,showValue:t})}};var Xe={time:new _,value:new $,enum:new F};function le(a,e){let t=T();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function fe(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ge(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=T(),r=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function ye(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function be(a){return a.style?.gap}function xe(a){return a.style?.fill}function Ze(a){return {lines:fe(a),fill:xe(a),markers:ge(a),shadow:ye(a),gap:be(a),id:a.style?.id??a.id}}/*!
27
+ </clipPath>`}get regions(){return [...this.#e]}};var I={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??I,n=this.#t.y??0,r=[],[o,s]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:l.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ge(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ye(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??Ge,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,r]=this.#e.domain(),o=Math.min(n,r),s=Math.max(n,r),l=s-o;if(l===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=l/t,m=Math.pow(10,Math.floor(Math.log10(i))),u=i/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],p=Math.ceil(o/c)*c;for(let f=p;f<=s;f+=c)d.push({value:f,position:this.#e.map(f),label:e(f)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,i=u=>s.some(c=>Math.abs(c-u)<=l),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ye(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new O({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((s,l)=>{let i=Number(s),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[l%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:11,fill:r.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,r=e.gapThreshold??h.gapThreshold,o=e.id,s=S.getRuns(this.data,c=>c.value===null,r),l=s.reduce((c,d)=>c+d.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=s.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of s)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),s=e.map(t[r].value);r===0?n.push({x:o,y:s}):n.push({x:o,y:n[n.length-1].y},{x:o,y:s});}return n}render(){let e=S.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,s=e.bandWidth??10,l=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=s,p=this.data.indexOf(i);if(l.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);l.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return l}};var oe=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,r=e.avgColor??h.avgColor,o=e.avgDashed??true,s=e.smoothing??false,l=e.strokeWidth??h.strokeWidth,i=S.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:l,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,s=S.getRuns(this.data,u=>u.value===null,r),l=s.reduce((u,c)=>u+c.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of s){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=S.splitByBoundaries(u,[f],y=>y.value,S.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let x=g[y];if(x.data.length<2)continue;let C=x.zoneIndex>0;if(e.fill.side==="above"===C){let L=x.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...L,{x:L[L.length-1].x,y:b},{x:L[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=S.splitByBoundaries(u,c,f=>f.value,S.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...W(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return m}};var Xe=1,ae=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:s,y:l,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:s[0],y:l,w:s[1]-s[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(d<s[0]||c>s[1])continue;let p=Math.max(s[0],Math.min(s[1],c)),f=Math.max(s[0],Math.min(s[1],d)),g=Math.max(f-p,Xe);p+g>s[1]&&(p=Math.max(s[0],s[1]-g));let b=p+g/2;if(m.push({type:"rect",x:p,y:l,w:g,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let y=u.labelFontSize??10;m.push({type:"text",content:u.label,x:b,y:this.#t(u.labelBaseline,y),anchor:"middle",fontSize:y,fill:u.labelFill??"#333"});}}if(o){let u=new j({domain:t.domain(),xRange:s,y:l+i+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:s=true,showMedian:l=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:s},{name:"median",value:c.median,enabled:l}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:m,strokeWidth:1});let x=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:x,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:x,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:x,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var _=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,s=36e5,l=6e4,i={};return r<l?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<s?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var $=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var F=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new a({map:n,showValue:t})}};var Ze={time:new _,value:new $,enum:new F};function le(a,e){let t=T();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ge(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ye(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=T(),r=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function be(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function xe(a){return a.style?.gap}function Se(a){return a.style?.fill}function Ue(a){return {lines:ge(a),fill:Se(a),markers:ye(a),shadow:be(a),gap:xe(a),id:a.style?.id??a.id}}/*!
28
28
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
29
29
  * MIT with Attribution: free use incl. commercial requires visible credit to
30
30
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -43,4 +43,4 @@ var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time
43
43
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
44
44
  * MIT with Attribution: free use incl. commercial must have visible credit to
45
45
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
46
- */export{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,F as EnumFormatter,Xe as Formatters,K as Layout,te as LineSeries,M as LinearScale,oe as MinMaxAvgSeries,z as Renderer,se as StatsOverlay,ne as StepSeries,k as TIME_INTERVALS,j as TimeAxis,_ as TimeFormatter,R as TimeScale,Q as ValueAxis,$ as ValueFormatter,ie as ZonedLineSeries,he as getHatch,$e as measureLegend,Ee as renderAnnotations,De as renderArea,je as renderGaps,Pe as renderGrid,Ne as renderHighlights,Fe as renderLegend,w as renderLine,He as renderMarkers,W as renderSeriesMarkers,Me as renderSplitLine,G as renderStep,Oe as renderThresholds,N as renderZonedArea,xe as resolveFill,be as resolveGap,fe as resolveLines,ge as resolveMarkers,Ze as resolveSeriesStyle,ye as resolveShadow,q as slugify,h as theme};
46
+ */export{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,F as EnumFormatter,Ze as Formatters,K as Layout,te as LineSeries,M as LinearScale,oe as MinMaxAvgSeries,z as Renderer,se as StatsOverlay,ne as StepSeries,k as TIME_INTERVALS,j as TimeAxis,_ as TimeFormatter,R as TimeScale,Q as ValueAxis,$ as ValueFormatter,ie as ZonedLineSeries,he as getHatch,Fe as measureLegend,ze as renderAnnotations,Me as renderArea,Be as renderGaps,We as renderGrid,Ve as renderHighlights,Pe as renderLegend,w as renderLine,Ne as renderMarkers,W as renderSeriesMarkers,_e as renderSplitLine,G as renderStep,Ie as renderThresholds,N as renderZonedArea,Se as resolveFill,xe as resolveGap,ge as resolveLines,ye as resolveMarkers,Ue as resolveSeriesStyle,be as resolveShadow,q as slugify,h as theme,De as toStepData,pe as toStepPoints};
@@ -341,6 +341,32 @@ declare function renderLine(segments: {
341
341
  data: DataPoint[];
342
342
  color?: string;
343
343
  }[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
344
+ /** Render segments as step-functions. */
345
+ /**
346
+ * Punktfolge einer Treppe: vor jeden Punkt kommt die Ecke auf seiner X- und
347
+ * der vorigen Y-Hoehe. Steht hier und nicht nur in renderStep, weil
348
+ * MLTimeGraph seine Pfade selbst zusammenbaut und `style.line.shape: "step"`
349
+ * sonst wirkungslos bliebe -- so war es bis hierher.
350
+ */
351
+ declare function toStepPoints(pts: {
352
+ x: number;
353
+ y: number;
354
+ }[]): {
355
+ x: number;
356
+ y: number;
357
+ }[];
358
+ /**
359
+ * Dieselbe Treppe, aber im *Daten*raum: vor jeden Punkt kommt ein Punkt auf
360
+ * seiner Zeit und dem vorigen Wert. Erst damit wird die Stufe zu Daten, die
361
+ * jeder weitere Schritt -- Zonenteilung an einer Grenze, Flaeche unter der
362
+ * Kurve -- ohne eigenes Wissen ueber Treppen richtig behandelt.
363
+ *
364
+ * In Pixeln (toStepPoints) war die Stufe dafuer zu spaet: die Flaeche wurde
365
+ * aus den rohen Messwerten gebaut und lief als Rampe unter einer Treppe her,
366
+ * und eine Zonengrenze schnitt den senkrechten Sprung an der interpolierten
367
+ * Zeit statt am Zeitstempel des naechsten Wertes.
368
+ */
369
+ declare function toStepData(data: DataPoint[]): DataPoint[];
344
370
  declare function renderStep(segments: {
345
371
  data: DataPoint[];
346
372
  color?: string;
@@ -378,4 +404,4 @@ declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style
378
404
  declare function drawMarker(// NOSONAR
379
405
  commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
380
406
 
381
- export { type LegendOrientation as L, type Marker as M, Renderer as R, type Theme as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, drawMarker as d, Layout as e, type LayoutConfig as f, getDefaultTheme as g, type LegendConfig as h, renderArea as i, renderLegend as j, renderLine as k, renderMarkers as l, measureLegend as m, renderSplitLine as n, renderStep as o, renderZonedArea as p, resetDefaultTheme as r, setDefaultTheme as s };
407
+ export { type LegendOrientation as L, type Marker as M, Renderer as R, type Theme as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, drawMarker as d, Layout as e, type LayoutConfig as f, getDefaultTheme as g, type LegendConfig as h, renderArea as i, renderLegend as j, renderLine as k, renderMarkers as l, measureLegend as m, renderSplitLine as n, renderStep as o, renderZonedArea as p, toStepPoints as q, resetDefaultTheme as r, setDefaultTheme as s, toStepData as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "TypeScript library for time-series chart rendering — DOM-free SVG output (works in the browser and on the server).",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "README.md",
32
32
  "README.de.md",
33
33
  "USAGE.md",
34
+ "CHANGELOG.md",
34
35
  "QUICKSTART_GRAPH_BUILDER.md",
35
36
  "QUICKSTART_GRAPH_BUILDER.de.md",
36
37
  "GRAPH_JSON_STRUCTURE.md",
@@ -40,7 +41,9 @@
40
41
  "build": "tsup",
41
42
  "test": "vitest run",
42
43
  "typecheck": "tsc --noEmit",
43
- "prepublishOnly": "tsup"
44
+ "prepublishOnly": "tsup",
45
+ "prepack": "node ../../scripts/sync-changelog.mjs",
46
+ "postpack": "node ../../scripts/sync-changelog.mjs --clean"
44
47
  },
45
48
  "keywords": [
46
49
  "chart",
@@ -59,7 +62,7 @@
59
62
  },
60
63
  "author": "Michael Lechner",
61
64
  "license": "SEE LICENSE IN LICENSE",
62
- "homepage": "https://github.com/mlc0911/mlctimegraph",
65
+ "homepage": "https://gitlab.com/mlc0911/mlctimegraph",
63
66
  "repository": {
64
67
  "type": "git",
65
68
  "url": "git+https://gitlab.com/mlc0911/mlctimegraph.git",