ml-time-graph 1.7.2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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
- 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
- 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';
1
+ import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './slug-aDUz3wBN.js';
2
+ export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme, e as slugify } from './slug-aDUz3wBN.js';
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-CQhADkWB.js';
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-CQhADkWB.js';
5
5
 
6
6
  /*!
7
7
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -54,6 +54,29 @@ interface YAxisConfig {
54
54
  label?: string;
55
55
  /** Override the value domain. `'auto'` lets the chart compute it from data. */
56
56
  domain?: [number, number] | "auto";
57
+ /**
58
+ * Extra room above and below the data, **in pixels**. Ignored when `domain`
59
+ * is set explicitly — then you decide the range.
60
+ *
61
+ * The computed domain ends exactly at the smallest and largest reading, and
62
+ * the plot is clipped to its rectangle. A line of width 10 at the maximum
63
+ * therefore loses half its stroke, and a marker half its disc. That is right
64
+ * for the *value* and wrong for the *picture*.
65
+ *
66
+ * Pixels rather than a share of the range: the cause is in pixels
67
+ * (`style.line.width`, `markers.size`), and the same number then works for a
68
+ * series in °C and one in kW. A rule of thumb is half the widest stroke plus
69
+ * a little — `padding: 8` covers a 10 px line and a size-6 marker.
70
+ *
71
+ * ```ts
72
+ * axes: { left: { padding: 8 } }
73
+ * axes: { left: { padding: { top: 24, bottom: 4 } } } // room for a label
74
+ * ```
75
+ */
76
+ padding?: number | {
77
+ top?: number;
78
+ bottom?: number;
79
+ };
57
80
  /** Format a tick value into its label text. */
58
81
  format?: (value: number) => string;
59
82
  /** Tick density / sizing. */
@@ -144,6 +167,43 @@ interface MLTimeGraphOptions {
144
167
  clipSeries?: boolean;
145
168
  /** Locale for i18n (e.g. 'de-DE') */
146
169
  locale?: string;
170
+ /**
171
+ * IANA time zone for the time axis, e.g. `'Europe/Berlin'` or `'UTC'`.
172
+ *
173
+ * Unset means the machine's zone — the behaviour up to 1.8.1, kept so that
174
+ * nothing changes for callers who never thought about it. But a browser sits
175
+ * in the reader's zone and a server almost always in UTC, so the *same* JSON
176
+ * labelled the same reading with different times depending on where it was
177
+ * drawn. That is the opposite of what a DOM-free renderer is for; set this
178
+ * whenever a chart is produced in one place and read in another.
179
+ *
180
+ * The tick *positions* never depended on it — they are epoch arithmetic. Only
181
+ * the labels do.
182
+ */
183
+ timeZone?: string;
184
+ /**
185
+ * Font for every text in the chart, written into the SVG as `font-family`.
186
+ *
187
+ * Unset means the default stack below. Why name one at all: the SVG says
188
+ * nothing about fonts today, so a viewer picks its own, and the same chart
189
+ * has different label widths in a browser, in an email client and in a
190
+ * rasteriser. Naming a stack removes that variance.
191
+ *
192
+ * The default is chosen for **metric compatibility**, not looks: Liberation
193
+ * Sans was designed with the same advance widths as Arial, so Linux lands on
194
+ * Liberation, Windows and macOS on Arial or Helvetica, and the labels occupy
195
+ * the same space. A stack with DejaVu Sans would not do that — it is
196
+ * noticeably wider, and labels would collide differently.
197
+ *
198
+ * A CSS stack *is* "use it if installed, otherwise ours" — no extra
199
+ * mechanism needed.
200
+ *
201
+ * Note that the library never **measures** text (it renders DOM-free), so
202
+ * this does not change the layout: anchors and `text-anchor` stay where they
203
+ * are. It changes what the viewer draws. A much wider house font will
204
+ * therefore collide differently; that is on you.
205
+ */
206
+ fontFamily?: string;
147
207
  /** Integrated legend configuration */
148
208
  legend?: LegendOptions;
149
209
  /** Markers */
@@ -180,16 +240,12 @@ interface MLTimeGraphOptions {
180
240
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
181
241
  */
182
242
 
183
- /**
184
- * Time-series chart. Configure it with {@link MLTimeGraphOptions} (series,
185
- * thresholds, legend, axis labels, …), then call {@link MLTimeGraph.renderCommands}
186
- * to get renderer-agnostic draw commands — a {@link Renderer} (e.g. SVGRenderer)
187
- * turns those into output. The chart never touches the DOM itself.
188
- */
189
243
  declare class MLTimeGraph {
190
244
  private readonly _layout;
191
245
  private readonly _renderer?;
192
246
  private readonly _locale?;
247
+ private readonly _timeZone?;
248
+ private readonly _fontFamily?;
193
249
  private readonly _legend?;
194
250
  /** Serien auf die Zeichenflaeche beschneiden (Vorgabe: ja) — siehe options.ts. */
195
251
  private readonly _clipSeries;
@@ -741,8 +797,6 @@ declare class SVGRenderer extends Renderer {
741
797
  _toSVG(cmd: DrawCommand): string;
742
798
  /** Register or retrieve a hatch pattern by variant. Returns the pattern id for use as fill="url(#id)". */
743
799
  _hatchPattern(variant: string, fillColor: string | undefined): string;
744
- /** Monotonic counter for unique hatch pattern ids. */
745
- _hatchIndex: number;
746
800
  _path(c: Extract<DrawCommand, {
747
801
  type: "path";
748
802
  }>): string;
@@ -755,9 +809,6 @@ declare class SVGRenderer extends Renderer {
755
809
  _circle(c: Extract<DrawCommand, {
756
810
  type: "circle";
757
811
  }>): string;
758
- _gradient(c: Extract<DrawCommand, {
759
- type: "gradient";
760
- }>): string;
761
812
  _gap(c: Extract<DrawCommand, {
762
813
  type: "gap";
763
814
  }>): string;
@@ -934,4 +985,68 @@ declare function toSeries<T>(name: string, rows: readonly T[], spec?: ToDataPoin
934
985
  data: DataPoint[];
935
986
  };
936
987
 
937
- export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, HighlightBuilder, LegendItem, type LegendOptions, LegendOrientation, type LegendPosition, type LimitStatsPoint, LineVariant, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, MarkerBuilder, type MktPoint, PointStyleType, SVGRenderer, SeriesStyle, type StatsAggregatedPoint, type StdDevPoint, Threshold, ThresholdBuilder, ThresholdLabelPosition, type TickConfig, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };
988
+ /*!
989
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
990
+ * MIT with Attribution: free use incl. commercial requires visible credit to
991
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
992
+ */
993
+
994
+ /**
995
+ * Ein Fragment: dieselbe Form wie die Optionen, nur unvollstaendig.
996
+ *
997
+ * Die zweite Haelfte der Union ist der Ausweg fuer rohes JSON -- ein aus einer
998
+ * Datei gelesenes Fragment ist nicht typisiert, und `mergeOptions` soll es
999
+ * trotzdem annehmen. Ohne die erste Haelfte waere dagegen der haeufigste
1000
+ * Aufruf unmoeglich: `mergeOptions(theme, optionen)` mit zwei typisierten
1001
+ * Objekten -- `MLTimeGraphOptions` ist nicht auf `Record<string, unknown>`
1002
+ * zuweisbar, weil ihm die Index-Signatur fehlt.
1003
+ */
1004
+ type OptionsLayer = Partial<MLTimeGraphOptions> | Record<string, unknown>;
1005
+ /**
1006
+ * Layer chart options on top of each other — the later layer wins.
1007
+ *
1008
+ * Use it when part of the options repeats across many charts: colours, axes,
1009
+ * legend, dimensions. Keep that part in one place and put it over the data
1010
+ * instead of copying it into every call.
1011
+ *
1012
+ * ```ts
1013
+ * const chart = new MLTimeGraph(mergeOptions(hausTheme, messwerte));
1014
+ * ```
1015
+ *
1016
+ * **The rule, in one sentence:** objects are merged key by key, to any depth;
1017
+ * everything else — numbers, strings, booleans, `null` and **arrays** — is
1018
+ * replaced.
1019
+ *
1020
+ * Replacing arrays rather than appending is deliberate. If a layer appended, a
1021
+ * theme carrying a single line style would *add* it to your series instead of
1022
+ * styling them, and nobody would guess why there is one curve too many. To add
1023
+ * entries, write the array out in full — longer, but it says so.
1024
+ *
1025
+ * This is the same rule the Go port applies (`models.MergeJSON`), and the
1026
+ * CLI's `-with` flag uses it. A different rule on either side would mean the
1027
+ * same job draws two different pictures.
1028
+ *
1029
+ * Note that `{ ...a, ...b }` is *not* the same thing: the spread is shallow, so
1030
+ * an `axes` in the later object replaces the whole `axes` of the earlier one —
1031
+ * grid, ticks and all.
1032
+ */
1033
+ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGraphOptions;
1034
+
1035
+ /*!
1036
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
1037
+ * MIT with Attribution: free use incl. commercial requires visible credit to
1038
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
1039
+ */
1040
+ /**
1041
+ * Die Version dieser Bibliothek — das Gegenstueck zu `version.Version` im
1042
+ * Go-Port, und dieselbe Zahl: beide werden von `scripts/release.mjs` im
1043
+ * selben Lauf gesetzt.
1044
+ *
1045
+ * Es gab sie auf der TS-Seite bisher nicht. Gebraucht wird sie, seit jedes
1046
+ * erzeugte SVG sagt, woraus es stammt (`<!-- MLTimeGraph x.y.z -->`): Wer
1047
+ * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
1048
+ * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
1049
+ */
1050
+ declare const VERSION = "1.9.0";
1051
+
1052
+ export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, HighlightBuilder, LegendItem, type LegendOptions, LegendOrientation, type LegendPosition, type LimitStatsPoint, LineVariant, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, MarkerBuilder, type MktPoint, type OptionsLayer, PointStyleType, SVGRenderer, SeriesStyle, type StatsAggregatedPoint, type StdDevPoint, Threshold, ThresholdBuilder, ThresholdLabelPosition, type TickConfig, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, VERSION, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };