ml-time-graph 1.9.0 → 1.10.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 +97 -0
- package/SKILLS.md +84 -3
- package/USAGE.md +14 -0
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +113 -17
- package/dist/index.js +16 -16
- package/dist/interaction/index.d.ts +1 -1
- package/dist/interaction/index.js +1 -1
- package/dist/internals.d.ts +146 -45
- package/dist/internals.js +21 -21
- package/dist/{slug-aDUz3wBN.d.ts → marker_renderer-D6rDW2Pe.d.ts} +71 -85
- package/dist/{scale-CQhADkWB.d.ts → scale-B3MhoTu1.d.ts} +183 -68
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as DrawCommand, b as LineVariant, P as PointStyleType, c as DrawGroup, M as MarkerLineStyle, T as TimeScale, L as LinearScale, S as SmoothingType, H as HatchVariant, D as DataPoint } from './scale-B3MhoTu1.js';
|
|
2
2
|
|
|
3
3
|
/** Output format type for the renderer (SVG string, Canvas, or nothing). */
|
|
4
4
|
type RenderType = "svg" | "canvas" | "none";
|
|
@@ -112,6 +112,21 @@ declare const theme: {
|
|
|
112
112
|
readonly annotationRadius: 4;
|
|
113
113
|
/** Default annotation text font size */
|
|
114
114
|
readonly annotationFontSize: 11;
|
|
115
|
+
/**
|
|
116
|
+
* Schriftgroesse der Marker-Beschriftung.
|
|
117
|
+
*
|
|
118
|
+
* Stand bis 1.10.0 als feste 11 im Renderer -- wer das Theme umstellte,
|
|
119
|
+
* bekam ueberall groessere Schrift, nur an den Markern nicht.
|
|
120
|
+
*/
|
|
121
|
+
readonly markerFontSize: 11;
|
|
122
|
+
/**
|
|
123
|
+
* Schriftgroesse der Beschriftungen an statistischen Overlays
|
|
124
|
+
* (Mittelwert, MKT, Grenzlinien). Stand bis 1.10.0 als feste 10 im Renderer.
|
|
125
|
+
*/
|
|
126
|
+
readonly statFontSize: 10;
|
|
127
|
+
/** Schriftgroessen im eingebauten Tooltip: Zeit und Wert. */
|
|
128
|
+
readonly tooltipTimeFontSize: 10;
|
|
129
|
+
readonly tooltipValueFontSize: 11;
|
|
115
130
|
/** Default threshold line color */
|
|
116
131
|
readonly thresholdColor: "#666";
|
|
117
132
|
/** Default threshold line style */
|
|
@@ -197,6 +212,39 @@ declare function getDefaultTheme(): Readonly<Theme>;
|
|
|
197
212
|
*/
|
|
198
213
|
declare function resetDefaultTheme(): void;
|
|
199
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Misst die Breite eines Textes in Pixeln.
|
|
217
|
+
*
|
|
218
|
+
* Die Bibliothek misst nicht selbst -- sie rendert DOM-frei, und ein Aufruf
|
|
219
|
+
* beim Benutzer haette das BILD davon abhaengig gemacht, WER misst: Canvas
|
|
220
|
+
* `measureText` im Browser und freetype im Go-Port stimmen nicht aufs Pixel
|
|
221
|
+
* ueberein, und die Zusage lautet, dass dasselbe JSON dasselbe Bild ergibt.
|
|
222
|
+
*
|
|
223
|
+
* Deshalb liegt die Vorgabe BEI (`liberationMetrics`), und der Callback ist die
|
|
224
|
+
* Ausnahme fuer den, der sie bewusst verlaesst.
|
|
225
|
+
*/
|
|
226
|
+
type TextMetrics = (text: string, fontSize: number) => number;
|
|
227
|
+
/**
|
|
228
|
+
* Die mitgelieferte Metrik: Vorschubbreiten von Liberation Sans.
|
|
229
|
+
*
|
|
230
|
+
* Gilt fuer den ganzen Vorgabe-Stapel `Liberation Sans, Arial, Helvetica` --
|
|
231
|
+
* die drei sind metrikkompatibel, deshalb wurde er so gewaehlt (1.9.0). Die
|
|
232
|
+
* Tabelle stimmt also auch dort, wo Liberation Sans nicht installiert ist.
|
|
233
|
+
*
|
|
234
|
+
* Was sie nicht kennt (Griechisch, Kyrillisch, CJK), bekommt 0,6 em -- die
|
|
235
|
+
* Schaetzung, die bis 1.10.0 fuer alles galt.
|
|
236
|
+
*/
|
|
237
|
+
declare const liberationMetrics: TextMetrics;
|
|
238
|
+
/**
|
|
239
|
+
* Die alte Schaetzung: 0,6 em je Zeichen.
|
|
240
|
+
*
|
|
241
|
+
* Steht hier, weil sie zwei Zwecke hat -- der Rueckfall fuer unbekannte
|
|
242
|
+
* Zeichen rechnet damit, und wer die Bilder von vor 1.10.0 reproduzieren muss,
|
|
243
|
+
* reicht sie als `textMetrics` herein. Genau sie war bis zu ±60 % daneben:
|
|
244
|
+
* "i" ist 0,222 em breit, "W" 0,944.
|
|
245
|
+
*/
|
|
246
|
+
declare const estimateMetrics: TextMetrics;
|
|
247
|
+
|
|
200
248
|
/*!
|
|
201
249
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
202
250
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
@@ -233,9 +281,13 @@ interface LegendConfig {
|
|
|
233
281
|
y: number;
|
|
234
282
|
/** Stack items vertically (default) or lay them in a row. */
|
|
235
283
|
orientation?: LegendOrientation;
|
|
284
|
+
/** Textbreiten; Vorgabe ist die mitgelieferte Tabelle (Liberation Sans). */
|
|
285
|
+
metrics?: TextMetrics;
|
|
286
|
+
/** Hoechstbreite einer waagerechten Zeile; darueber wird umgebrochen. */
|
|
287
|
+
maxBreite?: number;
|
|
236
288
|
}
|
|
237
289
|
/** Estimated pixel size of the legend box (for layout reservation). */
|
|
238
|
-
declare function measureLegend(items: LegendItem[], orientation?: LegendOrientation): {
|
|
290
|
+
declare function measureLegend(items: LegendItem[], orientation?: LegendOrientation, metrics?: TextMetrics, maxBreite?: number): {
|
|
239
291
|
width: number;
|
|
240
292
|
height: number;
|
|
241
293
|
};
|
|
@@ -249,7 +301,7 @@ interface Marker {
|
|
|
249
301
|
label?: string;
|
|
250
302
|
color?: string;
|
|
251
303
|
pointStyle?: PointStyleType;
|
|
252
|
-
lineStyle?:
|
|
304
|
+
lineStyle?: MarkerLineStyle;
|
|
253
305
|
seriesIndex?: number;
|
|
254
306
|
}
|
|
255
307
|
|
|
@@ -302,6 +354,16 @@ declare class Layout {
|
|
|
302
354
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
303
355
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
304
356
|
*/
|
|
357
|
+
/**
|
|
358
|
+
* Turn a free-form name into an ASCII slug usable as an `id`/CSS-class
|
|
359
|
+
* suffix. Lowercased, non-alphanumeric runs collapsed to `-`, accents
|
|
360
|
+
* stripped, trimmed, capped at 50 chars. Empty input → `'unnamed'`.
|
|
361
|
+
*
|
|
362
|
+
* slugify('Temperatur (°C)') → 'temperatur-c'
|
|
363
|
+
* slugify('Signal A') → 'signal-a'
|
|
364
|
+
* slugify(' ') → 'unnamed'
|
|
365
|
+
*/
|
|
366
|
+
declare function slugify(s: string | undefined | null): string;
|
|
305
367
|
|
|
306
368
|
/**
|
|
307
369
|
* Flat style configuration for series rendering.
|
|
@@ -312,14 +374,16 @@ interface SeriesStyle {
|
|
|
312
374
|
stroke?: string;
|
|
313
375
|
/** Stroke width in pixels. */
|
|
314
376
|
strokeWidth?: number;
|
|
315
|
-
/** Enable
|
|
377
|
+
/** Enable curve smoothing. */
|
|
316
378
|
smoothing?: boolean;
|
|
379
|
+
/** Which spline when `smoothing` is on. Default `"catmull-rom"`. */
|
|
380
|
+
smoothingType?: SmoothingType;
|
|
317
381
|
/** Enable dashed line style. */
|
|
318
382
|
dashed?: boolean;
|
|
319
383
|
/** Fill colour (hex, rgba, or `url(#gradient-id)`). */
|
|
320
384
|
fill?: string;
|
|
321
385
|
/** Hatch pattern for fill (default: none). */
|
|
322
|
-
hatch?:
|
|
386
|
+
hatch?: HatchVariant;
|
|
323
387
|
/** Data-point marker style. */
|
|
324
388
|
pointStyle?: PointStyleType;
|
|
325
389
|
/** Marker size (radius or half-width). */
|
|
@@ -345,88 +409,10 @@ interface RenderingContext {
|
|
|
345
409
|
timeScale: TimeScale;
|
|
346
410
|
valueScale: LinearScale;
|
|
347
411
|
}
|
|
348
|
-
|
|
349
|
-
declare function renderLine(segments: {
|
|
350
|
-
data: DataPoint[];
|
|
351
|
-
color?: string;
|
|
352
|
-
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
353
|
-
/** Render segments as step-functions. */
|
|
354
|
-
/**
|
|
355
|
-
* Punktfolge einer Treppe: vor jeden Punkt kommt die Ecke auf seiner X- und
|
|
356
|
-
* der vorigen Y-Hoehe. Steht hier und nicht nur in renderStep, weil
|
|
357
|
-
* MLTimeGraph seine Pfade selbst zusammenbaut und `style.line.shape: "step"`
|
|
358
|
-
* sonst wirkungslos bliebe -- so war es bis hierher.
|
|
359
|
-
*/
|
|
360
|
-
declare function toStepPoints(pts: {
|
|
361
|
-
x: number;
|
|
362
|
-
y: number;
|
|
363
|
-
}[]): {
|
|
364
|
-
x: number;
|
|
365
|
-
y: number;
|
|
366
|
-
}[];
|
|
367
|
-
/**
|
|
368
|
-
* Dieselbe Treppe, aber im *Daten*raum: vor jeden Punkt kommt ein Punkt auf
|
|
369
|
-
* seiner Zeit und dem vorigen Wert. Erst damit wird die Stufe zu Daten, die
|
|
370
|
-
* jeder weitere Schritt -- Zonenteilung an einer Grenze, Flaeche unter der
|
|
371
|
-
* Kurve -- ohne eigenes Wissen ueber Treppen richtig behandelt.
|
|
372
|
-
*
|
|
373
|
-
* In Pixeln (toStepPoints) war die Stufe dafuer zu spaet: die Flaeche wurde
|
|
374
|
-
* aus den rohen Messwerten gebaut und lief als Rampe unter einer Treppe her,
|
|
375
|
-
* und eine Zonengrenze schnitt den senkrechten Sprung an der interpolierten
|
|
376
|
-
* Zeit statt am Zeitstempel des naechsten Wertes.
|
|
377
|
-
*/
|
|
378
|
-
declare function toStepData(data: DataPoint[]): DataPoint[];
|
|
379
|
-
declare function renderStep(segments: {
|
|
380
|
-
data: DataPoint[];
|
|
381
|
-
color?: string;
|
|
382
|
-
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
383
|
-
/** Render segments as a filled area between two values (e.g. min/max band). */
|
|
384
|
-
declare function renderArea(segments: {
|
|
385
|
-
data: AggregatedPoint[];
|
|
386
|
-
color?: string;
|
|
387
|
-
}[], ctx: RenderingContext, style: SeriesStyle, yLow: (p: AggregatedPoint) => number, yHigh: (p: AggregatedPoint) => number): DrawCommand[];
|
|
388
|
-
/**
|
|
389
|
-
* Complex area renderer that splits a run by value boundaries (thresholds)
|
|
390
|
-
* and renders the resulting zones as separate filled areas.
|
|
391
|
-
*/
|
|
392
|
-
declare function renderZonedArea<T extends {
|
|
393
|
-
time: number;
|
|
394
|
-
}>(run: T[], ctx: RenderingContext, options: {
|
|
395
|
-
boundaries: number[];
|
|
396
|
-
yLow: (p: T) => number;
|
|
397
|
-
yHigh: (p: T) => number;
|
|
398
|
-
getValue: (p: T) => number;
|
|
399
|
-
interpolate: (p1: T, p2: T, t: number) => T;
|
|
400
|
-
getColor: (zoneIndex: number) => string | undefined;
|
|
401
|
-
getHatch?: (zoneIndex: number) => string | undefined;
|
|
402
|
-
}, style?: SeriesStyle): DrawCommand[];
|
|
403
|
-
/**
|
|
404
|
-
* Render a line series split by a threshold value, allowing different styles
|
|
405
|
-
* for parts above and below that value.
|
|
406
|
-
*/
|
|
407
|
-
declare function renderSplitLine(run: DataPoint[], threshold: number, ctx: RenderingContext, styles: {
|
|
408
|
-
above?: SeriesStyle;
|
|
409
|
-
below?: SeriesStyle;
|
|
410
|
-
}): DrawCommand[];
|
|
412
|
+
|
|
411
413
|
/** Render point markers for segments. */
|
|
412
414
|
declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style: SeriesStyle, getColor: (p: DataPoint) => string): DrawCommand[];
|
|
413
415
|
declare function drawMarker(// NOSONAR
|
|
414
416
|
commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
|
|
415
417
|
|
|
416
|
-
|
|
417
|
-
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
418
|
-
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
419
|
-
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
420
|
-
*/
|
|
421
|
-
/**
|
|
422
|
-
* Turn a free-form name into an ASCII slug usable as an `id`/CSS-class
|
|
423
|
-
* suffix. Lowercased, non-alphanumeric runs collapsed to `-`, accents
|
|
424
|
-
* stripped, trimmed, capped at 50 chars. Empty input → `'unnamed'`.
|
|
425
|
-
*
|
|
426
|
-
* slugify('Temperatur (°C)') → 'temperatur-c'
|
|
427
|
-
* slugify('Signal A') → 'signal-a'
|
|
428
|
-
* slugify(' ') → 'unnamed'
|
|
429
|
-
*/
|
|
430
|
-
declare function slugify(s: string | undefined | null): string;
|
|
431
|
-
|
|
432
|
-
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, slugify as e, Layout as f, getDefaultTheme as g, type LayoutConfig as h, type LegendConfig as i, renderArea as j, renderLegend as k, renderLine as l, measureLegend as m, renderMarkers as n, renderSplitLine as o, renderStep as p, renderZonedArea as q, resetDefaultTheme as r, setDefaultTheme as s, toStepData as t, toStepPoints as u };
|
|
418
|
+
export { type LegendOrientation as L, type Marker as M, Renderer as R, type SeriesStyle as S, type TextMetrics as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, type Theme as d, drawMarker as e, estimateMetrics as f, getDefaultTheme as g, slugify as h, type RenderingContext as i, Layout as j, type LayoutConfig as k, liberationMetrics as l, type LegendConfig as m, measureLegend as n, renderLegend as o, renderMarkers as p, resetDefaultTheme as r, setDefaultTheme as s };
|