ml-time-graph 1.21.1 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -19,6 +19,53 @@ release notes, and every change is in `git log` in full.
19
19
 
20
20
  ---
21
21
 
22
+ ## [1.23.0] - 2026-11-02
23
+
24
+ ### Added
25
+ - **`minItemWidth` on annotation bands** (TS and Go) — short events in long windows stay visible; a
26
+ narrower item widens around its centre.
27
+
28
+ ### Changed
29
+ - **The `gap` draw command** now draws its `label` with any style except `"empty"`. Affects only
30
+ hand-written command lists; charts do not produce this command.
31
+
32
+ ### Fixed
33
+ - **A series line with `width: 0` or style `"none"` is no longer drawn** (TS and Go); markers stay. It
34
+ used to come out at 1 px between the points. In TS, `"none"` works from JSON; the type offers
35
+ `line: false`.
36
+ - **`showInLegend: true` on an annotation band now lists it in the legend** (TS and Go). The field did
37
+ nothing before. The default is now documented as `false`, so existing charts do not change. Such a
38
+ band also appears in `legendItems()`, without a `seriesId`.
39
+
40
+ ### Removed
41
+ - **Gap style `"label"`** (TS and Go), deprecated since 1.17.1. Use `"empty"` with a `label`: it draws
42
+ the same. TypeScript no longer accepts the value; JSON that still has it keeps drawing as before,
43
+ and `warnings()` reports it.
44
+
45
+ ## [1.22.0] - 2026-10-22
46
+
47
+ ### Security
48
+ - **go-time-graph builds with Go 1.26.10** — closes GO-2026-6809 (`crypto/x509`), reachable from
49
+ `graph-server` through gin. The minimum Go version stays 1.26.0.
50
+
51
+ ### Added
52
+ - **`margin: "auto"`** (TS and Go) — measures the margins from what the chart draws (tick labels,
53
+ state names, axis titles, threshold labels in the margin), the same measurement as
54
+ `autoMargin()`. Plain JSON, so it works for options built in Go, the `graph-cli`, the HTTP API
55
+ and the PDF port; in TS it is resolved on every `renderCommands()`, also after `setData`.
56
+ Without it the fixed default margins stay as before.
57
+
58
+ ## [1.21.2] - 2026-10-22
59
+
60
+ ### Fixed
61
+ - **Go: markers respect the point limit** — `style.markers.threshold` (else `theme.pointThreshold`)
62
+ was checked only in TypeScript; the Go renderer drew a marker on every point. A chart with
63
+ 4000 samples got 4000 circles and the line turned into a thick string of beads, while the
64
+ browser drew the same JSON without markers. Affects Go output of dense series with markers.
65
+ (B-TGRAF-20261022-05)
66
+
67
+ Go only; not published to npm — the npm packages go from 1.21.1 to 1.22.0.
68
+
22
69
  ## [1.21.1] - 2026-10-22
23
70
 
24
71
  ### Fixed
@@ -14,7 +14,7 @@ All fields are optional.
14
14
  |-------|------|---------|-------------|
15
15
  | `width` | `number` | auto | Chart width in pixels |
16
16
  | `height` | `number` | auto | Chart height in pixels |
17
- | `margin` | `Margin` | 0 on each side | Inner padding around the plot area |
17
+ | `margin` | `Margin \| "auto"` | 20 / 20 / 40 / 60 (top/right/bottom/left) | Space around the plot area; `"auto"` measures it from what is drawn (see `autoMargin` in USAGE.md) |
18
18
  | `renderer` | `Renderer` (class instance) | — | **Non-serializable.** Rendering backend instance; set programmatically only |
19
19
  | `series` | `AnySeries[]` | `[]` | Data series to draw (`TimeSeries` \| `AggregatedSeries`) |
20
20
  | `locale` | `string` | `de-DE` | IETF locale tag used for number/date formatting, e.g. `'en-US'`, `'de-DE'` |
@@ -218,7 +218,7 @@ Applies to both series kinds and to overlay curves.
218
218
  | Field | Type | Description |
219
219
  |-------|------|-------------|
220
220
  | `id` | `string` | Stable style identifier |
221
- | `line` | `LineStyle \| LineStyle[] \| false` | Single style, per-segment array, or `false` (no line) |
221
+ | `line` | `LineStyle \| LineStyle[] \| false` | Single style, per-segment array, or `false` (no line). `width: 0` or `style: 'none'` on a `LineStyle` also draws no line (`'none'` from JSON; the TS type has `false` for it) |
222
222
  | `fill` | `FillSpec` | Area fill below/above the curve (section 5.1) |
223
223
  | `markers` | `MarkerStyle` | Per-point marker glyphs (distinct from reference markers, section 10) |
224
224
  | `shadow` | `ShadowStyle` | Soft shadow behind the line |
@@ -431,7 +431,7 @@ Two equivalent forms; prefer `GapsConfig`.
431
431
  | `fillOpacity` | `number` | Background opacity |
432
432
  | `labelBaseline` | `'above' \| 'middle' \| 'below'` | Vertical label alignment — **note the value set differs from `AnnotationBandItem.labelBaseline`** |
433
433
  | `rotate` | `number` | Label rotation |
434
- | `style` | `'dashed_border' \| 'empty' \| 'label'` | Rendering mode. `'label'` is **deprecated** and will be removed before 2.0 — use `'empty'` with `label`. |
434
+ | `style` | `'dashed_border' \| 'empty' \| 'filled'` | Rendering mode. `'label'` was removed — use `'empty'` with `label`; JSON that still has it draws like `'empty'` and `warnings()` reports it. |
435
435
 
436
436
  ### 10b. Preferred config form (`gaps: GapsConfig`)
437
437
 
@@ -479,7 +479,8 @@ Bands rendered in a dedicated strip *outside* the plot area, useful for shift/ph
479
479
  | `height` | `number` | `12` | Strip height in px |
480
480
  | `spacing` | `number` | `0` | Extra spacing below the strip, px |
481
481
  | `showAxis` | `boolean` | `false` | Draw a dedicated axis with band tick labels |
482
- | `showInLegend` | `boolean` | `true` | Include in the legend |
482
+ | `showInLegend` | `boolean` | `false` | List in the legend, with the colour of its first item; the legend itself still needs `legend.show` |
483
+ | `minItemWidth` | `number` | `1` | Smallest item width in px; a narrower item widens around its centre and claims no duration |
483
484
  | `background` | `string` | transparent | Strip background color |
484
485
  | `items` | `AnnotationBandItem[]` | **required** | Individual windows inside the strip |
485
486
  | `labels` | `'all' \| 'fit' \| { mode, keep? }` | `'all'` | `'fit'`: draw only the item labels that fit side by side (see below) |
@@ -556,7 +557,7 @@ covered — the label moves past its tick labels. Axis titles on that side keep
556
557
 
557
558
  **GapStyle.display** (4): `empty`, `dashed_border`, `filled`, `bridge_line`
558
559
 
559
- **DrawGapType_t** (3) — legacy `Gap.style`: `dashed_border`, `empty`, `label` (deprecated, removed before 2.0)
560
+ **DrawGapType_t** (3) — legacy `Gap.style`: `dashed_border`, `empty`, `filled`
560
561
 
561
562
  **FillSide:** `above`, `below`
562
563
 
package/USAGE.md CHANGED
@@ -100,7 +100,7 @@ See `demos/adapters.html` — the same chart from four input shapes.
100
100
 
101
101
  Visual styling lives in a nested `style` block — `line`, `fill`, `markers`, `shadow`,
102
102
  `gap`. Any combination is allowed: set `line` for a line, add `fill` for an area
103
- underneath, add `markers` for points, set `style.line: false` for points only.
103
+ underneath, add `markers` for points, set `style.line: false` (or `width: 0`) for points only.
104
104
 
105
105
  ```ts
106
106
  // Raw line
@@ -403,6 +403,10 @@ interface LegendItem {
403
403
  }
404
404
  ```
405
405
 
406
+ An annotation band with `showInLegend: true` is listed after the series. Its `id` starts with
407
+ `band-`, it has no `seriesId`, and no series group belongs to it, so a click handler that hides
408
+ series has to skip it.
409
+
406
410
  Draw the swatch through the same renderer the chart uses, so it cannot drift from the
407
411
  curve it names — a 22×10 line with the series' dashes and, if there is one, its marker:
408
412
 
@@ -569,6 +573,14 @@ The chart draws into fixed margins. When they are too narrow, labels are cut, an
569
573
  is a wrong number (`-80` becomes `-8`). `autoMargin(options)` returns margins that fit what the
570
574
  chart actually draws — tick labels, axis titles, stacked axes, threshold labels `outside-*`:
571
575
 
576
+ ```ts
577
+ const chart = new MLTimeGraph({ ...options, margin: 'auto' });
578
+ ```
579
+
580
+ `margin: 'auto'` measures on every `renderCommands()`, with the data current then (also after
581
+ `setData`). It is plain JSON, so it works where no function can be called: options built in Go,
582
+ the `graph-cli`, the HTTP API, the PDF port. The helper is still there if you want the numbers:
583
+
572
584
  ```ts
573
585
  import { MLTimeGraph, autoMargin } from 'ml-time-graph';
574
586
 
@@ -577,12 +589,12 @@ const chart = new MLTimeGraph({ ...options, margin: autoMargin(options) });
577
589
 
578
590
  - **Measured, not estimated:** it renders the chart and measures the draw commands, with the
579
591
  options' `textMetrics` (default `liberationMetrics`). No DOM.
580
- - **A helper, not an option:** `margin` stays numbers. Call it once per change of the options —
581
- a few milliseconds, independent of the amount of data (it draws only each series' extreme
582
- points, which is what the axes are made of).
592
+ - **Cost:** a few milliseconds, independent of the amount of data (it draws only each series'
593
+ extreme points, which is what the axes are made of).
583
594
  - A legend `outside-*` reserves its room on top, as before. `{ padding, minimum }` tune the air
584
595
  (default 4 px) and the least any side gets (default 8 px).
585
- - The Go port has the same function (`chart.AutoMargin`) and gives the same margins.
596
+ - The Go port has the same function (`chart.AutoMargin`) and the same `"margin": "auto"`, and gives
597
+ the same margins.
586
598
 
587
599
  ### Multi-Axis Layout (N Stacked Y-Axes)
588
600
 
@@ -1093,8 +1105,8 @@ look different from what you meant. Same texts in Go (`Warnings()`):
1093
1105
  - `side` on a fill region that is not "line against a fixed bound", and `outer` without `side`
1094
1106
  — both are ignored there;
1095
1107
  - `where` on a smoothing that can overshoot (`catmull-rom`, `akima`);
1096
- - deprecated settings (`style: "label"` on a gap, `series.style.gap.label`, `series.sensorType`
1097
- other than `"numeric"`).
1108
+ - removed or deprecated settings (`style: "label"` on a gap, `series.style.gap.label`,
1109
+ `series.sensorType` other than `"numeric"`).
1098
1110
 
1099
1111
  Call it while you author a chart, or log it once; it costs a pass over the options.
1100
1112
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { M as MLTimeGraphOptions, L as LegendItem, b as Margin, Y as YAxisConfig, A as AxesConfig, X as XAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-VMXQOF8U.js';
1
+ import { M as MLTimeGraphOptions, L as LegendItem, b as Margin, Y as YAxisConfig, A as AxesConfig, X as XAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-Be-IsY5V.js';
2
2
  import { Renderer, LayoutResult } from './internals.js';
3
- export { h as AxisLabelsStyle, i as AxisStyle, G as GridLineStyle, j as GridStyle, T as TextMetrics, k as Theme, l as TickConfig, m as TickFormat, n as drawMarker, o as estimateMetrics, p as getDefaultTheme, q as liberationMetrics, r as resetDefaultTheme, s as setDefaultTheme, t as slugify } from './marker_renderer-VMXQOF8U.js';
4
- import { e as AnySeries, i as Annotation, a as DrawCommand, g as Gap, h as GapsConfig, f as Threshold, H as Highlight, j as AnnotationBandConfig, l as SeriesStyle, c as LineVariant, S as SmoothingType, F as FillSpec, m as TimeSeries, b as LineDashStyle, n as ThresholdFill, k as HatchVariant, o as ThresholdLabelPosition, P as PointStyleType, M as MarkerLineStyle, R as RangeLabelPosition, p as AnnotationPointShape, q as LabelAnchor, r as AnnotationBandItem, s as TextBaseline, t as AggregatedPoint, u as AggregatedSeries, D as DataPoint } from './types-Bo9798aK.js';
3
+ export { h as AxisLabelsStyle, i as AxisStyle, G as GridLineStyle, j as GridStyle, T as TextMetrics, k as Theme, l as TickConfig, m as TickFormat, n as drawMarker, o as estimateMetrics, p as getDefaultTheme, q as liberationMetrics, r as resetDefaultTheme, s as setDefaultTheme, t as slugify } from './marker_renderer-Be-IsY5V.js';
4
+ import { e as AnySeries, i as Annotation, a as DrawCommand, g as Gap, h as GapsConfig, f as Threshold, H as Highlight, j as AnnotationBandConfig, l as SeriesStyle, c as LineVariant, S as SmoothingType, F as FillSpec, m as TimeSeries, b as LineDashStyle, n as ThresholdFill, k as HatchVariant, o as ThresholdLabelPosition, P as PointStyleType, M as MarkerLineStyle, R as RangeLabelPosition, p as AnnotationPointShape, q as LabelAnchor, r as AnnotationBandItem, s as TextBaseline, t as AggregatedPoint, u as AggregatedSeries, D as DataPoint } from './types-fDUNEN4P.js';
5
5
  import { TimeScale, LinearScale } from './internals.js';
6
- export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationBandLabels, z as AnnotationKind, B as AxisOrientation, A as AxisPosition, C as DataPointRef, E as EnumMap, I as FillBound, J as FillRegion, K as FillSide, N as FillStyle, O as FillWhere, Q as GapBand, U as GapConfig, V as GapLabel, W as GapRegion, X as GapStyle, Y as GapsAtEnd, G as GridLayer, Z as LineShape, _ as LineStyle, $ as MarkerStyle, a0 as MovingAverageType, a1 as SVGLineStyle, a2 as SensorType, a3 as SeriesGapStyle, a4 as SeriesGaps, a5 as SeriesOverlay, a6 as SeriesOverlayKind, a7 as SeriesType, a8 as ShadowStyle, a9 as SolidDashStyle, aa as ThresholdLabelConfig, ab as getLineStyle, ac as resolveDash } from './types-Bo9798aK.js';
6
+ export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationBandLabels, z as AnnotationKind, B as AxisOrientation, A as AxisPosition, C as DataPointRef, E as EnumMap, I as FillBound, J as FillRegion, K as FillSide, N as FillStyle, O as FillWhere, Q as GapBand, U as GapConfig, V as GapLabel, W as GapRegion, X as GapStyle, Y as GapsAtEnd, G as GridLayer, Z as LineShape, _ as LineStyle, $ as MarkerStyle, a0 as MovingAverageType, a1 as SVGLineStyle, a2 as SensorType, a3 as SeriesGapStyle, a4 as SeriesGaps, a5 as SeriesOverlay, a6 as SeriesOverlayKind, a7 as SeriesType, a8 as ShadowStyle, a9 as SolidDashStyle, aa as ThresholdLabelConfig, ab as getLineStyle, ac as resolveDash } from './types-fDUNEN4P.js';
7
7
 
8
8
  /*!
9
9
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -102,7 +102,7 @@ interface PointsAtOptions {
102
102
  * turns those into output. The chart never touches the DOM itself.
103
103
  */
104
104
  declare class MLTimeGraph {
105
- private readonly _layout;
105
+ private _layout;
106
106
  private readonly _idPraefix?;
107
107
  /** classPrefix: vor jede Klasse ausser legend.itemClass (klassen_praefix.ts). */
108
108
  private readonly _klassenPraefix?;
@@ -138,6 +138,9 @@ declare class MLTimeGraph {
138
138
  private readonly _axes?;
139
139
  private _series;
140
140
  private _timeScale?;
141
+ /** Die Optionen, wie sie hereinkamen -- fuer die Messung bei margin: "auto". */
142
+ private readonly _optionen;
143
+ private readonly _randAuto;
141
144
  private readonly _valueScales;
142
145
  /** @param options Chart configuration; every field is optional and has a sensible default. */
143
146
  constructor(options?: MLTimeGraphOptions);
@@ -183,6 +186,13 @@ declare class MLTimeGraph {
183
186
  * oeffentlichen Wege, die Schemawerte lesen (legendItems, layout, pointsAt).
184
187
  */
185
188
  renderCommands(): DrawCommand[];
189
+ /**
190
+ * `margin: "auto"`: die Raender aus dem messen, was mit dem JETZIGEN Stand
191
+ * gezeichnet wird -- Daten koennen nach dem Konstruktor per setData kommen,
192
+ * Annotationen per addAnnotation. Dieselbe Messung wie autoMargin(); sie
193
+ * zeichnet ein Diagramm mit festen Zahlen, also keine Rekursion.
194
+ */
195
+ private _randMessen;
186
196
  private _zeichne;
187
197
  /** Build the draw commands for a single series based on its type. */
188
198
  /**
@@ -198,6 +208,12 @@ declare class MLTimeGraph {
198
208
  private _reihenKontext;
199
209
  legendItems(): LegendItem[];
200
210
  private _legendeneintraege;
211
+ /**
212
+ * Die Baender mit ausdruecklichem `showInLegend`. Getrennt von `_legendItems`, denn
213
+ * pointsAt greift dort je Reihe ueber den Index zu.
214
+ * Gegenstueck: bandLegendenEintraege in go-time-graph/pkg/chart/legende.go.
215
+ */
216
+ private _bandLegendItems;
201
217
  /**
202
218
  * Die Farbe einer Reihe ohne eigene Angabe.
203
219
  *
@@ -840,8 +856,10 @@ declare class AnnotationBandBuilder {
840
856
  setHatch(hatch: HatchVariant): this;
841
857
  /** Sets whether to draw a time axis under the band. */
842
858
  setShowAxis(show: boolean): this;
843
- /** Sets whether the band is listed in the chart legend. */
859
+ /** Sets whether the band is listed in the chart legend (default false). */
844
860
  setShowInLegend(show: boolean): this;
861
+ /** Sets the smallest width in pixels an item is drawn with; narrower ones widen around their centre. */
862
+ setMinItemWidth(px: number): this;
845
863
  /**
846
864
  * Sets which item labels are drawn: `"all"` (default) or `"fit"` — only those that fit
847
865
  * side by side; `keep` picks the label that is always drawn.
@@ -1157,7 +1175,7 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
1157
1175
  * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
1158
1176
  * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
1159
1177
  */
1160
- declare const VERSION = "1.21.1";
1178
+ declare const VERSION = "1.23.0";
1161
1179
 
1162
1180
  export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, AxesConfig, DataPoint, DrawCommand, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, PointStyleType, RangeLabelPosition, RenderOutput, SVGRenderer, SeriesStyle, SmoothingType, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, TimeSeries, TimeSeriesBuilder, VERSION, XAxisConfig, YAxisConfig, attachTooltip, autoMargin, axisGroups, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries, zeigerImSvg };
1163
1181
  export type { AutoMarginOptions, AxisGroupInput, AxisGroups, FieldAccessor, FillBetweenThresholdsInput, LimitStatsPoint, MktPoint, OptionsLayer, PointAt, PointsAtOptions, StatsAggregatedPoint, StdDevPoint, TimeInput, ToDataPointsSpec, TooltipOptions, TooltipSample };