ml-time-graph 1.0.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.
@@ -0,0 +1,246 @@
1
+ import { p as DrawCommand, t as DrawGroup, $ as PointStyleType } from './scale-Cbr0KpPz.js';
2
+
3
+ /** Output format type for the renderer (SVG string, Canvas, or nothing). */
4
+ type RenderType = 'svg' | 'canvas' | 'none';
5
+
6
+ /*!
7
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
8
+ * MIT with Attribution: free use incl. commercial requires visible credit to
9
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
10
+ */
11
+
12
+ /** Renderer-Output */
13
+ interface RenderOutput {
14
+ type: RenderType;
15
+ content: string;
16
+ }
17
+
18
+ /*!
19
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
20
+ * MIT with Attribution: free use incl. commercial requires visible credit to
21
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
22
+ */
23
+
24
+ /**
25
+ * Abstract renderer — the chart logic never knows rendering details. It emits
26
+ * `DrawCommand[]`, a renderer turns those into output.
27
+ *
28
+ * The shipped {@link SVGRenderer} produces a DOM-free SVG string (works in the
29
+ * browser and on the server). For DOM-specific behaviour, extend SVGRenderer.
30
+ */
31
+ declare abstract class Renderer {
32
+ abstract render(commands: DrawCommand[]): RenderOutput;
33
+ }
34
+
35
+ /*!
36
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
37
+ * MIT with Attribution: free use incl. commercial requires visible credit to
38
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
39
+ */
40
+ /**
41
+ * Central defaults for the entire library.
42
+ * Override individual values or mutate `theme` to restyle the chart globally.
43
+ */
44
+ declare const theme: {
45
+ /** Default stroke color for series lines */
46
+ readonly stroke: "#4285f4";
47
+ /** Default line width in pixels */
48
+ readonly strokeWidth: 2;
49
+ /** Default point marker size (radius / half-width) */
50
+ readonly pointSize: 4;
51
+ /** Max data points before point markers are suppressed */
52
+ readonly pointThreshold: 100;
53
+ /** Default max time gap (ms) before the line breaks; 0 = off */
54
+ readonly gapThreshold: 0;
55
+ /** Default series type */
56
+ readonly fill: "none";
57
+ readonly hatch: null;
58
+ /** Default band fill color */
59
+ readonly bandFill: "#4285f4";
60
+ /** Default band opacity (when countOpacity is disabled) */
61
+ readonly bandOpacity: 0.6;
62
+ /** Default avg line color for bands */
63
+ readonly bandAvgLine: "#e53e3e";
64
+ /** Default min color for minmaxavg series */
65
+ readonly minColor: "#3b82f6";
66
+ /** Default max color for minmaxavg series */
67
+ readonly maxColor: "#ef4444";
68
+ /** Default avg color for minmaxavg series */
69
+ readonly avgColor: "#64748b";
70
+ /** Area fill alpha suffix (hex) for zoned areas — default 20% opacity */
71
+ readonly areaFillAlpha: "4285f433";
72
+ /** Default axis baseline color */
73
+ readonly axisColor: "#ccc";
74
+ /** Default tick mark color */
75
+ readonly tickColor: "#ddd";
76
+ /** Default axis label text color */
77
+ readonly textColor: "#777";
78
+ /** Default axis text size (axis labels, tick labels) */
79
+ readonly textSize: 11;
80
+ /** Axis label (rotated title next to axis) fill color */
81
+ readonly axisLabelColor: "#444";
82
+ /** Axis label font size */
83
+ readonly axisLabelSize: 12;
84
+ /** Default grid line stroke */
85
+ readonly gridStroke: "#e2e8f0";
86
+ /** Default grid line stroke width */
87
+ readonly gridStrokeWidth: 1;
88
+ /** Default grid opacity */
89
+ readonly gridOpacity: 1;
90
+ /** Legend swatch stroke */
91
+ readonly legendStroke: "#ccc";
92
+ /** Legend text fill */
93
+ readonly legendText: "#333";
94
+ /** Legend font size */
95
+ readonly legendFont: 11;
96
+ /** Default annotation color */
97
+ readonly annotationColor: "#334155";
98
+ /** Default annotation line width */
99
+ readonly annotationWidth: 1.5;
100
+ /** Default annotation arrow head size */
101
+ readonly annotationHead: 9;
102
+ /** Default annotation point radius */
103
+ readonly annotationRadius: 4;
104
+ /** Default annotation text font size */
105
+ readonly annotationFontSize: 11;
106
+ /** Default threshold line color */
107
+ readonly thresholdColor: "#666";
108
+ /** Default threshold line style */
109
+ readonly thresholdLine: "dashed";
110
+ /** Default threshold fill opacity */
111
+ readonly thresholdFillOpacity: 0.12;
112
+ /** Default threshold label font size */
113
+ readonly thresholdFontSize: 10;
114
+ /** Default highlight fill color */
115
+ readonly highlightColor: "#fbbf24";
116
+ /** Default highlight box opacity */
117
+ readonly highlightOpacity: 0.2;
118
+ /** Default highlight label text color */
119
+ readonly highlightLabelColor: "#92400e";
120
+ /** Default marker color */
121
+ readonly markerColor: "#f59e0b";
122
+ /** Default marker point size (cross / circle radius) */
123
+ readonly markerSize: 5;
124
+ /** Gap region background fill */
125
+ readonly gapFill: "#fff";
126
+ /** Gap border stroke */
127
+ readonly gapStroke: "#ccc";
128
+ /** Gap border stroke width */
129
+ readonly gapStrokeWidth: 1;
130
+ /** Gap label text color */
131
+ readonly gapFontColor: "#999";
132
+ /** Gap label font size */
133
+ readonly gapFontSize: 10;
134
+ readonly gapFillOpacity: 0.15;
135
+ /** Tooltip box background */
136
+ readonly tooltipBg: "#fff";
137
+ /** Tooltip border */
138
+ readonly tooltipBorder: "#cbd5e1";
139
+ /** Tooltip text color */
140
+ readonly tooltipText: "#1e293b";
141
+ /** Tooltip value label color */
142
+ readonly tooltipValue: "#3b82f6";
143
+ /** Tooltip crosshair stroke */
144
+ readonly tooltipCrosshair: "#94a3b8";
145
+ /** Tooltip snap radius in pixels */
146
+ readonly tooltipSnapRadius: 20;
147
+ /** Stats overlay line color */
148
+ readonly statsLineColor: "#94a3b8";
149
+ /** Stats label color */
150
+ readonly statsLabelColor: "#64748b";
151
+ /** Minimap overview line stroke */
152
+ readonly minimapStroke: "#94a3b8";
153
+ /** Minimap background */
154
+ readonly minimapBg: "#f8f9fa";
155
+ /** Minimap brush (viewport) fill */
156
+ readonly minimapBrush: "#3b82f644";
157
+ /** Default colour palette for enum categories and multi-series. */
158
+ readonly palette: readonly ["#4285f4", "#ea4335", "#22c55e", "#fbbc05", "#9334ea", "#12b5e5", "#fb923c", "#6366f1"];
159
+ };
160
+
161
+ /*!
162
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
163
+ * MIT with Attribution: free use incl. commercial requires visible credit to
164
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
165
+ */
166
+
167
+ /** Single legend entry with series name and color swatch. */
168
+ interface LegendItem {
169
+ name: string;
170
+ color: string;
171
+ }
172
+ /** Layout direction for legend items. */
173
+ type LegendOrientation = 'vertical' | 'horizontal';
174
+ /** Configuration for legend rendering including items, position, and orientation. */
175
+ interface LegendConfig {
176
+ items: LegendItem[];
177
+ /** Top-left pixel position. */
178
+ x: number;
179
+ y: number;
180
+ /** Stack items vertically (default) or lay them in a row. */
181
+ orientation?: LegendOrientation;
182
+ }
183
+ /** Estimated pixel size of the legend box (for layout reservation). */
184
+ declare function measureLegend(items: LegendItem[], orientation?: LegendOrientation): {
185
+ width: number;
186
+ height: number;
187
+ };
188
+ /** Render a legend (swatch + label per item) as a single group of commands. */
189
+ declare function renderLegend(config: LegendConfig): DrawGroup;
190
+
191
+ /** Vertical marker on the chart: point circle, full-height line, or label at a specific time. */
192
+ interface Marker {
193
+ time: number;
194
+ value?: number;
195
+ label?: string;
196
+ color?: string;
197
+ pointStyle?: PointStyleType;
198
+ lineStyle?: 'full' | 'to-value' | 'to-top';
199
+ seriesIndex?: number;
200
+ }
201
+
202
+ /*!
203
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
204
+ * MIT with Attribution: free use incl. commercial requires visible credit to
205
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
206
+ */
207
+ /** Layout configuration: dimensions, margins, and padding for the chart. */
208
+ interface LayoutConfig {
209
+ /** Total dimensions */
210
+ width: number;
211
+ height: number;
212
+ /** Margins (in pixels) */
213
+ margin: {
214
+ top: number;
215
+ right: number;
216
+ bottom: number;
217
+ left: number;
218
+ };
219
+ }
220
+ /** Computed layout result with chart area dimensions and offsets. */
221
+ interface LayoutResult {
222
+ /** Total width */
223
+ totalWidth: number;
224
+ /** Total height */
225
+ totalHeight: number;
226
+ /** Chart content area width (excluding margins) */
227
+ chartWidth: number;
228
+ /** Chart content area height (excluding margins) */
229
+ chartHeight: number;
230
+ /** Pixel X offset of chart area */
231
+ chartX: number;
232
+ /** Pixel Y offset of chart area */
233
+ chartY: number;
234
+ /** Margins used */
235
+ margin: LayoutConfig['margin'];
236
+ }
237
+ declare class Layout {
238
+ readonly _config: LayoutConfig;
239
+ constructor(config: LayoutConfig);
240
+ /** Calculate layout dimensions */
241
+ compute(): LayoutResult;
242
+ /** Default layout for standard charts */
243
+ static default(width?: number, height?: number): Layout;
244
+ }
245
+
246
+ export { Layout as L, type Marker as M, type RenderOutput as R, type LayoutConfig as a, type LayoutResult as b, type LegendConfig as c, type LegendItem as d, type LegendOrientation as e, Renderer as f, measureLegend as m, renderLegend as r, theme as t };