ml-time-graph 1.5.2 → 1.7.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/GRAPH_JSON_STRUCTURE.md +668 -0
- package/QUICKSTART_GRAPH_BUILDER.de.md +217 -0
- package/QUICKSTART_GRAPH_BUILDER.md +244 -0
- package/USAGE.md +62 -1
- package/dist/analyze/index.d.ts +1 -0
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +80 -6
- package/dist/index.js +25 -25
- package/dist/interaction/index.d.ts +1 -1
- package/dist/internals.d.ts +4 -4
- package/dist/internals.js +18 -18
- package/dist/{scale-ByGpczxS.d.ts → scale-D6NtEaUB.d.ts} +28 -7
- package/dist/{series_renderer-BxGvCHMY.d.ts → series_renderer-DQXKJttA.d.ts} +2 -2
- package/package.json +4 -2
- package/API_DESIGN.md +0 -1211
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
# Graph JSON Structure Reference
|
|
2
|
+
|
|
3
|
+
A complete, field-by-field reference for the `MLTimeGraphOptions` object — the same shape that `GraphBuilder.build()` (or `GraphBuilder.toOptions()`) produces and that `new MLTimeGraph(options)` consumes. Read this if you author graph configurations directly as JSON/objects rather than through the builder API.
|
|
4
|
+
|
|
5
|
+
Every field listed here is serializable as plain JSON **except** the ones flagged with a function/object warning in section 2.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Top level: `MLTimeGraphOptions`
|
|
10
|
+
|
|
11
|
+
All fields are optional.
|
|
12
|
+
|
|
13
|
+
| Field | Type | Default | Description |
|
|
14
|
+
|-------|------|---------|-------------|
|
|
15
|
+
| `width` | `number` | auto | Chart width in pixels |
|
|
16
|
+
| `height` | `number` | auto | Chart height in pixels |
|
|
17
|
+
| `margin` | `Margin` | 0 on each side | Inner padding around the plot area |
|
|
18
|
+
| `renderer` | `Renderer` (class instance) | — | **Non-serializable.** Rendering backend instance; set programmatically only |
|
|
19
|
+
| `series` | `AnySeries[]` | `[]` | Data series to draw (`TimeSeries` \| `AggregatedSeries`) |
|
|
20
|
+
| `locale` | `string` | `de-DE` | IETF locale tag used for number/date formatting, e.g. `'en-US'`, `'de-DE'` |
|
|
21
|
+
| `legend` | `LegendOptions` | legend hidden | Legend visibility, position, orientation |
|
|
22
|
+
| `markers` | `Marker[]` | `[]` | Vertical reference markers at specific points in time |
|
|
23
|
+
| `thresholds` | `Threshold[]` | `[]` | Horizontal threshold lines with optional fill |
|
|
24
|
+
| `highlights` | `Highlight[]` | `[]` | Shaded vertical time ranges (e.g. outages) |
|
|
25
|
+
| `gaps` | `Gap[]` \| `GapsConfig` | — | Gap rendering; accepts a plain array (legacy) or the richer config object (preferred) |
|
|
26
|
+
| `annotations` | `Annotation[]` | `[]` | Free-form overlays: lines, arrows, rects, points, labels |
|
|
27
|
+
| `annotationBands` | `AnnotationBandConfig[]` | `[]` | Time bands drawn in a separate strip outside the plot area |
|
|
28
|
+
| `axes` | `AxesConfig` | defaults | X axis and one or two Y axes |
|
|
29
|
+
|
|
30
|
+
> **Note:** tooltip options (`TooltipOptions`) are *not* part of `MLTimeGraphOptions`. They are attached separately via `GraphBuilder.setTooltip()` / `attachTooltip()`. See section 14.
|
|
31
|
+
|
|
32
|
+
### Margin
|
|
33
|
+
|
|
34
|
+
All four edges are required when the object is present:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{ "top": number, "right": number, "bottom": number, "left": number }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### LegendOptions
|
|
41
|
+
|
|
42
|
+
| Field | Type | Default |
|
|
43
|
+
|-------|------|---------|
|
|
44
|
+
| `show` | `boolean` | `false` |
|
|
45
|
+
| `position` | `LegendPosition` | `'inside-right'` |
|
|
46
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 2. Warning: non-serializable fields
|
|
51
|
+
|
|
52
|
+
The following fields hold **live objects or functions** and must not appear in JSON configuration or serialized state. Strip them before serializing; re-attach them in code.
|
|
53
|
+
|
|
54
|
+
| Field (type) | Location | Reason |
|
|
55
|
+
|--------------|----------|--------|
|
|
56
|
+
| `renderer` (`Renderer`) | top level | class instance with DOM/browser bindings |
|
|
57
|
+
| `format((d: Date) => string)` | `axes.x` | function |
|
|
58
|
+
| `format((value: number) => string)` | `axes.y` / `axes.left` / `axes.right` | function |
|
|
59
|
+
| `format((samples) => string)` | tooltip options (outside this object) | function |
|
|
60
|
+
|
|
61
|
+
Everything else in this document is plain JSON.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 3. Axes
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
"axes": {
|
|
69
|
+
"x": XAxisConfig, // horizontal time axis
|
|
70
|
+
"left": YAxisConfig, // optional left value axis
|
|
71
|
+
"right": YAxisConfig, // optional right value axis
|
|
72
|
+
"y": YAxisConfig[] // alternative: array form for multiple value axes
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Use `left`/`right` for the classic two-axis setup. Use `y` as an array when more than two scales are needed; series reference their scale via `yAxisIndex` (`0` = first, `1` = second, …).
|
|
77
|
+
|
|
78
|
+
### XAxisConfig
|
|
79
|
+
|
|
80
|
+
| Field | Type | Description |
|
|
81
|
+
|-------|------|-------------|
|
|
82
|
+
| `label` | `string` | Axis title text |
|
|
83
|
+
| `domain` | `[number, number] \| 'auto'` | Time extent (epoch ms). `'auto'` derives from data |
|
|
84
|
+
| `format` | **function — non-serializable** | Custom date formatter `(d: Date) => string` |
|
|
85
|
+
| `ticks` | `TickConfig` | Tick mark lengths |
|
|
86
|
+
| `grid` | `GridStyle` | Grid line styling |
|
|
87
|
+
| `axis` | `AxisStyle` | Axis line color/width |
|
|
88
|
+
| `labels` | `AxisLabelsStyle` | Tick label color/font size |
|
|
89
|
+
|
|
90
|
+
### YAxisConfig
|
|
91
|
+
|
|
92
|
+
| Field | Type | Description |
|
|
93
|
+
|-------|------|-------------|
|
|
94
|
+
| `position` | `'left' \| 'right'` | Side of the plot area |
|
|
95
|
+
| `offset` | `number` | Extra offset from the plot edge, px |
|
|
96
|
+
| `label` | `string` | Axis title text |
|
|
97
|
+
| `domain` | `[number, number] \| 'auto'` | Value range. `'auto'` derives from data |
|
|
98
|
+
| `format` | **function — non-serializable** | Custom value formatter `(value: number) => string` |
|
|
99
|
+
| `ticks` | `TickConfig` | Tick mark lengths |
|
|
100
|
+
| `grid` | `GridStyle` | Grid line styling |
|
|
101
|
+
| `axis` | `AxisStyle` | Axis line color/width |
|
|
102
|
+
| `labels` | `AxisLabelsStyle` | Tick label color/font size |
|
|
103
|
+
|
|
104
|
+
### Shared axis sub-configs
|
|
105
|
+
|
|
106
|
+
**TickConfig** — pixel lengths of tick marks:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "major"?: number, "minor"?: number, "size"?: number }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**GridLineStyle** —
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"color"?: string,
|
|
117
|
+
"width"?: number,
|
|
118
|
+
"style"?: LineVariant, // see section 15
|
|
119
|
+
"opacity"?: number
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**GridStyle** —
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{ "major"?: GridLineStyle | false, "minor"?: GridLineStyle | false }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use `false` to suppress a grid level entirely.
|
|
130
|
+
|
|
131
|
+
**AxisStyle** — `{ "color"?: string, "width"?: number }`
|
|
132
|
+
|
|
133
|
+
**AxisLabelsStyle** — `{ "color"?: string, "fontSize"?: number }` (font size in px)
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 4. Series
|
|
138
|
+
|
|
139
|
+
A series is either a `TimeSeries` (individual samples) or an `AggregatedSeries` (binned min/max/avg bars + lines). Both share `name`, `style`, and `overlays`.
|
|
140
|
+
|
|
141
|
+
### TimeSeries
|
|
142
|
+
|
|
143
|
+
| Field | Type | Description |
|
|
144
|
+
|-------|------|-------------|
|
|
145
|
+
| `id` | `string` | Stable identifier (used by selection/highlight logic) |
|
|
146
|
+
| `name` | `string` | Display name (legend, tooltips) |
|
|
147
|
+
| `data` | `DataPoint[]` | Samples, sorted by time |
|
|
148
|
+
| `sensorType` | `string` | Optional semantic type tag |
|
|
149
|
+
| `enumMap` | `Record<string \| number, string>` | Maps raw codes to labels, e.g. `{ "1": "running", "2": "stopped" }` |
|
|
150
|
+
| `style` | `SeriesStyle` | Visual appearance (section 5) |
|
|
151
|
+
| `overlays` | `SeriesOverlay[]` | Derived curves such as moving averages (section 6) |
|
|
152
|
+
| `yAxisIndex` | `number` | Which Y scale to draw on (`0` = left, `1` = right) |
|
|
153
|
+
| `seriesType` | `'line' \| 'area' \| 'step'` | Render mode (default `'line'`) |
|
|
154
|
+
| `colorByThresholds` | `string[]` | Colors applied segment-wise depending on which thresholds the values cross |
|
|
155
|
+
|
|
156
|
+
### DataPoint
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"time": number, // epoch milliseconds — required
|
|
161
|
+
"value"?: number | null, // null draws as missing (gap)
|
|
162
|
+
"annotation"?: string, // optional per-point note
|
|
163
|
+
"synthetic"?: boolean // true if not a real measurement (e.g. interpolated)
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### AggregatedSeries
|
|
168
|
+
|
|
169
|
+
| Field | Type | Description |
|
|
170
|
+
|-------|------|-------------|
|
|
171
|
+
| `name` | `string` | Display name |
|
|
172
|
+
| `data` | `AggregatedPoint[]` | One bin per point |
|
|
173
|
+
| `showAs` | `'band' \| 'minmaxavg'` | Draw the min/max envelope vs. three lines |
|
|
174
|
+
| `yAxisIndex` | `number` | Y scale index |
|
|
175
|
+
| `style` | `SeriesStyle` | Base styling |
|
|
176
|
+
| `overlays` | `SeriesOverlay[]` | Same as TimeSeries |
|
|
177
|
+
| `minColor` / `maxColor` | `string` | Override envelope edge colors |
|
|
178
|
+
| `avgLine` | `boolean` | Whether to draw the average line in `band` mode |
|
|
179
|
+
| `countOpacity` | `number` | Fill opacity for count shading |
|
|
180
|
+
|
|
181
|
+
### AggregatedPoint
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"time": number, // bin time — required
|
|
186
|
+
"min"?: number | null,
|
|
187
|
+
"max"?: number | null,
|
|
188
|
+
"avg"?: number | null,
|
|
189
|
+
"count": number // samples aggregated into this bin — required
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### SeriesOverlay (discriminated union on `kind`)
|
|
194
|
+
|
|
195
|
+
Common optional field: `style` (`SeriesStyle`).
|
|
196
|
+
|
|
197
|
+
| kind | Required | Optional | Notes |
|
|
198
|
+
|------|----------|----------|-------|
|
|
199
|
+
| `"movingAverage"` | `window: number` | `type?: 'simple' \| 'exponential'`, `style` | Classic MA / EMA |
|
|
200
|
+
| `"movingMkt"` | `window: number` | `activationEnergy?` (default `83144`), `style` | Arrhenius temperature-compensated average for chemical processes |
|
|
201
|
+
| `"stdDevBand"` | `window: number` | `multiplier?` (default `1`), `style` | Rolling ±(multiplier × σ) band |
|
|
202
|
+
| `"limits"` | — | `low?`, `high?`, `style` | Static tolerance limits |
|
|
203
|
+
|
|
204
|
+
Example:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{ "kind": "movingAverage", "window": 30, "type": "exponential" }
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 5. SeriesStyle
|
|
213
|
+
|
|
214
|
+
Applies to both series kinds and to overlay curves.
|
|
215
|
+
|
|
216
|
+
| Field | Type | Description |
|
|
217
|
+
|-------|------|-------------|
|
|
218
|
+
| `id` | `string` | Stable style identifier |
|
|
219
|
+
| `line` | `LineStyle \| LineStyle[] \| false` | Single style, per-segment array, or `false` (no line) |
|
|
220
|
+
| `fill` | `FillSpec` | Area fill below/above the curve (section 5.1) |
|
|
221
|
+
| `markers` | `MarkerStyle` | Per-point marker glyphs (distinct from reference markers, section 10) |
|
|
222
|
+
| `shadow` | `ShadowStyle` | Soft shadow behind the line |
|
|
223
|
+
| `gap` | `GapStyle` | How value gaps render for this series |
|
|
224
|
+
|
|
225
|
+
### LineStyle
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"color"?: string, // CSS color; defaults from palette
|
|
230
|
+
"width"?: number, // px
|
|
231
|
+
"style"?: LineVariant, // see section 15 (9 values)
|
|
232
|
+
"smoothing"?: number, // 0..1 curve smoothing factor
|
|
233
|
+
"shape"?: "line" | "step", // polyline vs. step rendering
|
|
234
|
+
"gapThreshold"?: number, // ms; gaps shorter than this still get bridged
|
|
235
|
+
"opacity"?: number // 0..1
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### MarkerStyle (per-point glyphs)
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"type"?: PointStyleType, // 13 values, see section 15; default 'none'
|
|
244
|
+
"size"?: number, // px
|
|
245
|
+
"stroke"?: string,
|
|
246
|
+
"fill"?: string,
|
|
247
|
+
"strokeWidth"?: number,
|
|
248
|
+
"threshold"?: number // only draw the point when value >= threshold
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### ShadowStyle
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{ "color"?: string, "blur"?: number, "offsetX"?: number, "offsetY"?: number }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### 5.1 FillSpec and regions
|
|
259
|
+
|
|
260
|
+
A fill is either a single flat style or a list of bounded regions:
|
|
261
|
+
|
|
262
|
+
- **Simple:** `fill` = `FillStyle` (string or object) — fills toward the default bound.
|
|
263
|
+
- **Regioned:** `fill` = `{ "regions": [ FillRegion, ... ] }`.
|
|
264
|
+
|
|
265
|
+
**FillStyle:**
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
"#a3e634"
|
|
269
|
+
// or
|
|
270
|
+
{ "color": "#a3e634", "hatch"?: HatchVariant, "hatchColor"?: string, "hatchWidth"?: number }
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Hatching overlays a pattern (section 15) on top of the base color — useful for transparent fills in dense charts.
|
|
274
|
+
|
|
275
|
+
**FillBound:**
|
|
276
|
+
|
|
277
|
+
```json
|
|
278
|
+
"series" // the curve itself
|
|
279
|
+
| "chartTop" // top of plot area
|
|
280
|
+
| "chartBottom" // bottom of plot area
|
|
281
|
+
| { "threshold": id } // up to a named threshold
|
|
282
|
+
| { "value": number } // to an absolute value
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**FillRegion:**
|
|
286
|
+
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"from"?: FillBound, // default 'series'
|
|
290
|
+
"to"?: FillBound, // default 'chartBottom'
|
|
291
|
+
"fill": FillStyle,
|
|
292
|
+
"side"?: "above" | "below", // which side of the curve
|
|
293
|
+
"outer"?: FillBound // secondary bound for multi-bounded fills
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 6. Thresholds
|
|
300
|
+
|
|
301
|
+
Horizontal lines at fixed values, with optional filled zones and labels.
|
|
302
|
+
|
|
303
|
+
| Field | Type | Default | Description |
|
|
304
|
+
|-------|------|---------|-------------|
|
|
305
|
+
| `name` | `string` | **required** | Unique id-like name (referenced by fills via `{ "threshold": name }`) |
|
|
306
|
+
| `value` | `number` | **required** | Y value of the line |
|
|
307
|
+
| `color` | `string` | `'#666'` | Line color |
|
|
308
|
+
| `line` | `'solid' \| 'dashed' \| 'dotted' \| 'none'` | `'dashed'` | Dash pattern. **Note:** this is the 4-value `LineDashStyle`, *not* the 9-value `LineVariant` used for series lines |
|
|
309
|
+
| `fill` | `'above' \| 'below' \| 'none'` | `'none'` | Shade the area on one side of the line |
|
|
310
|
+
| `fillHatch` | `HatchVariant` | — | Hatching pattern for the fill |
|
|
311
|
+
| `fillOpacity` | `number` | `0.12` | Fill opacity 0..1 |
|
|
312
|
+
| `label` | `false \| string \| ThresholdLabelConfig` | name at `'right'` | Four states: omitted → draw `name` on the right; `false` → no label; a `string` → custom text, default position; an object → full control (below) |
|
|
313
|
+
| `axisIndex` | `number` | `0` | Which Y axis the threshold belongs to (`0`=left, `1`=right) |
|
|
314
|
+
| `id` | `string` | — | Explicit identifier |
|
|
315
|
+
| `shadowColor` / `shadowBlur` / `shadowOffsetX` / `shadowOffsetY` | `string` / `number` ×3 | — | Optional shadow under the line |
|
|
316
|
+
|
|
317
|
+
**ThresholdLabelConfig:**
|
|
318
|
+
|
|
319
|
+
```json
|
|
320
|
+
{
|
|
321
|
+
"text"?: string, // override label text (defaults to threshold name)
|
|
322
|
+
"position"?: ThresholdLabelPosition, // 7 values, see section 15
|
|
323
|
+
"rotate"?: number, // degrees
|
|
324
|
+
"textBaseline"?: "top" | "middle" | "bottom"
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Example:
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"name": "max-temp",
|
|
333
|
+
"value": 95,
|
|
334
|
+
"color": "#e11d48",
|
|
335
|
+
"line": "solid",
|
|
336
|
+
"fill": "above",
|
|
337
|
+
"fillOpacity": 0.15,
|
|
338
|
+
"label": { "text": "Max 95 °C", "position": "outside-right", "rotate": -90 }
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## 7. Highlights
|
|
345
|
+
|
|
346
|
+
Shaded vertical time windows, e.g. production stops under investigation.
|
|
347
|
+
|
|
348
|
+
| Field | Type | Default | Description |
|
|
349
|
+
|-------|------|---------|-------------|
|
|
350
|
+
| `startTime` | `number` | **required** | Window start (epoch ms) |
|
|
351
|
+
| `endTime` | `number` | **required** | Window end (epoch ms) |
|
|
352
|
+
| `label` | `string` | — | Text centered in the band |
|
|
353
|
+
| `color` | `string` | — | Band color |
|
|
354
|
+
| `opacity` | `number` | — | Band opacity 0..1 |
|
|
355
|
+
| `labelPosition` | `'top' \| 'center' \| 'bottom' \| 'above' \| 'below'` | `'top'` | Where the label sits relative to the band |
|
|
356
|
+
| `rotate` | `number` | — | Label rotation in degrees |
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## 8. Annotations
|
|
361
|
+
|
|
362
|
+
Five kinds of point-anchored overlays. All variants share optional `id` and `title`. Coordinates are given by `DataPointRef`:
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{ "time": number, "value": number, "axis"?: number } // axis: which Y scale value refers to
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
The union is discriminated on `type`.
|
|
369
|
+
|
|
370
|
+
| type | Anchor fields | Own fields (all optional) |
|
|
371
|
+
|------|---------------|---------------------------|
|
|
372
|
+
| `"line"` | `from`, `to` (`DataPointRef`) | `color`, `width`, `dash?: 'dashed' \| 'dotted'` |
|
|
373
|
+
| `"arrow"` | `from`, `to` | `color`, `width`, `headSize?` (px) |
|
|
374
|
+
| `"rect"` | `from`, `to` (diagonal corners) | `fill?`, `hatch?: HatchVariant`, `stroke?`, `opacity?` |
|
|
375
|
+
| `"point"` | `at` | `color?`, `radius?`, `shape?: 'circle' \| 'square' \| 'cross'` |
|
|
376
|
+
| `"label"` | `at` | `text: string` (**required**), `color?`, `anchor?: 'start' \| 'middle' \| 'end'`, `dx?`, `dy?` (px offset), `rotate?` (deg) |
|
|
377
|
+
|
|
378
|
+
Example — arrow plus caption:
|
|
379
|
+
|
|
380
|
+
```json
|
|
381
|
+
[
|
|
382
|
+
{
|
|
383
|
+
"type": "arrow",
|
|
384
|
+
"from": { "time": 1705300000000, "value": 40 },
|
|
385
|
+
"to": { "time": 1705303600000, "value": 92 },
|
|
386
|
+
"color": "#0ea5e9"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"type": "label",
|
|
390
|
+
"at": { "time": 1705303600000, "value": 92 },
|
|
391
|
+
"text": "spike start",
|
|
392
|
+
"dx": 8,
|
|
393
|
+
"dy": -8,
|
|
394
|
+
"anchor": "start"
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 9. Markers (referenzen at chart level)
|
|
402
|
+
|
|
403
|
+
Vertical reference lines at a specific time — independent of any series.
|
|
404
|
+
|
|
405
|
+
| Field | Type | Description |
|
|
406
|
+
|-------|------|-------------|
|
|
407
|
+
| `time` | `number` | **required** — position on the X axis (epoch ms) |
|
|
408
|
+
| `value` | `number` | Anchor value (draws line only to that point) |
|
|
409
|
+
| `label` | `string` | Text on top of the marker |
|
|
410
|
+
| `color` | `string` | Line/label color |
|
|
411
|
+
| `pointStyle` | `PointStyleType` | Glyph at the anchor (13 values, section 15) |
|
|
412
|
+
| `lineStyle` | `'full' \| 'to-value' \| 'to-top'` | How far the vertical line extends. **Note:** this is *not* a dash style — unrelated to `Threshold.line` |
|
|
413
|
+
| `seriesIndex` | `number` | Restrict the marker to one series |
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 10. Gaps
|
|
418
|
+
|
|
419
|
+
Two equivalent forms; prefer `GapsConfig`.
|
|
420
|
+
|
|
421
|
+
### 10a. Legacy array form (`gaps: Gap[]`)
|
|
422
|
+
|
|
423
|
+
| Field | Type | Description |
|
|
424
|
+
|-------|------|-------------|
|
|
425
|
+
| `startTime` / `endTime` | `number` | Gap window (epoch ms) |
|
|
426
|
+
| `label` | `string` | Text shown on the gap |
|
|
427
|
+
| `fill` | `FillStyle` | Gap background |
|
|
428
|
+
| `hatch` | `HatchVariant` | Pattern overlay |
|
|
429
|
+
| `fillOpacity` | `number` | Background opacity |
|
|
430
|
+
| `labelBaseline` | `'above' \| 'middle' \| 'below'` | Vertical label alignment — **note the value set differs from `AnnotationBandItem.labelBaseline`** |
|
|
431
|
+
| `rotate` | `number` | Label rotation |
|
|
432
|
+
| `style` | `'dashed_border' \| 'empty' \| 'label'` | Rendering mode |
|
|
433
|
+
|
|
434
|
+
### 10b. Preferred config form (`gaps: GapsConfig`)
|
|
435
|
+
|
|
436
|
+
```json
|
|
437
|
+
{
|
|
438
|
+
"autoDetect"?: boolean, // derive gaps from null/missing data values
|
|
439
|
+
"minGapMs"?: number, // only flag gaps at least this long when autoDetecting
|
|
440
|
+
"regions"?: [ GapRegion ], // explicit windows
|
|
441
|
+
"style"?: GapStyle // shared default style for all regions
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**GapRegion:** `{ startTime: number, endTime: number, label?: string, style?: GapStyle }`
|
|
446
|
+
|
|
447
|
+
**GapStyle:**
|
|
448
|
+
|
|
449
|
+
```json
|
|
450
|
+
{
|
|
451
|
+
"display"?: "empty" | "dashed_border" | "filled" | "bridge_line",
|
|
452
|
+
"fill"?: FillStyle,
|
|
453
|
+
"opacity"?: number,
|
|
454
|
+
"label"?: GapLabel,
|
|
455
|
+
"bridge"?: { // used by 'bridge_line'
|
|
456
|
+
"color"?: string,
|
|
457
|
+
"width"?: number,
|
|
458
|
+
"style"?: "solid" | "dotted" | "dashed"
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
**GapLabel:** `{ baseline?: 'above' | 'middle' | 'below', rotate?: number, color?: string, fontSize?: number }`
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## 11. Annotation bands
|
|
468
|
+
|
|
469
|
+
Bands rendered in a dedicated strip *outside* the plot area, useful for shift/phase context across the full chart width.
|
|
470
|
+
|
|
471
|
+
### AnnotationBandConfig
|
|
472
|
+
|
|
473
|
+
| Field | Type | Default | Description |
|
|
474
|
+
|-------|------|---------|-------------|
|
|
475
|
+
| `name` | `string` | **required** | Band title (legend entry) |
|
|
476
|
+
| `hatch` | `HatchVariant` | — | Pattern across the strip |
|
|
477
|
+
| `height` | `number` | `12` | Strip height in px |
|
|
478
|
+
| `spacing` | `number` | `0` | Extra spacing below the strip, px |
|
|
479
|
+
| `showAxis` | `boolean` | `false` | Draw a dedicated axis with band tick labels |
|
|
480
|
+
| `showInLegend` | `boolean` | `true` | Include in the legend |
|
|
481
|
+
| `background` | `string` | transparent | Strip background color |
|
|
482
|
+
| `items` | `AnnotationBandItem[]` | **required** | Individual windows inside the strip |
|
|
483
|
+
|
|
484
|
+
### AnnotationBandItem
|
|
485
|
+
|
|
486
|
+
| Field | Type | Default | Description |
|
|
487
|
+
|-------|------|---------|-------------|
|
|
488
|
+
| `startTime` / `endTime` | `number` | **required** | Window (epoch ms) |
|
|
489
|
+
| `fill` | `string` | `'#6b728044'` | Window background (CSS color, alpha allowed) |
|
|
490
|
+
| `hatch` | `HatchVariant` | — | Pattern overlay |
|
|
491
|
+
| `stroke` | `string` | none | Border color |
|
|
492
|
+
| `strokeWidth` | `number` | `0` | Border width in px |
|
|
493
|
+
| `label` | `string` | — | Text inside the window |
|
|
494
|
+
| `labelFontSize` | `number` | `10` | px |
|
|
495
|
+
| `labelFill` | `string` | inherited | Label color |
|
|
496
|
+
| `labelBaseline` | `'top' \| 'middle' \| 'bottom'` | `'middle'` | **Different value set than gap labels (`above/middle/below`)** |
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## 12. Tooltip options (outside the JSON object)
|
|
501
|
+
|
|
502
|
+
Available only through `GraphBuilder.setTooltip()` — not part of `MLTimeGraphOptions`.
|
|
503
|
+
|
|
504
|
+
| Field | Type | Description |
|
|
505
|
+
|-------|------|-------------|
|
|
506
|
+
| `show` | `boolean` | Enable the tooltip |
|
|
507
|
+
| `format` | **function — non-serializable** | `(samples) => string` custom render |
|
|
508
|
+
| `snapRadius` | `number` | Snap radius in px |
|
|
509
|
+
| `className` | `string` | CSS class for the DOM tooltip |
|
|
510
|
+
| `showPicks` | `boolean` | Show crosshair pick markers |
|
|
511
|
+
| `pickRadius` | `number` | Marker radius in px |
|
|
512
|
+
| `picksClassName` | `string` | CSS class for pick markers |
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## 13. All enum / union value reference
|
|
517
|
+
|
|
518
|
+
**LineVariant** (9) — series lines, grid lines:
|
|
519
|
+
`solid`, `dotted`, `sparse-dots`, `dashed`, `long-dash`, `dense-dash`, `dash-dot`, `dash-dot-dot`, `loose-dash`
|
|
520
|
+
|
|
521
|
+
**LineDashStyle** (4) — **only** for `Threshold.line`:
|
|
522
|
+
`solid`, `dashed`, `dotted`, `none`
|
|
523
|
+
|
|
524
|
+
**HatchVariant** (11):
|
|
525
|
+
`none`, `classic-diagonal`, `dense-steep`, `crosshatch`, `dots`, `waves`, `dashed`, `herringbone`, `brick`, `double-stripe`, `honeycomb`
|
|
526
|
+
|
|
527
|
+
**PointStyleType** (13):
|
|
528
|
+
`none`, `circle`, `cross`, `square`, `diamond`, `triangle`, `star`, `arrow`, `plus`, `triangle-down`, `hexagon`, `hourglass`, `line-horizontal`
|
|
529
|
+
|
|
530
|
+
**LegendPosition** (5):
|
|
531
|
+
`inside-right`, `inside-left`, `outside-right`, `outside-left`, `separate`
|
|
532
|
+
|
|
533
|
+
**ThresholdLabelPosition** (7):
|
|
534
|
+
`left`, `right`, `above`, `below`, `center`, `outside-left`, `outside-right`
|
|
535
|
+
|
|
536
|
+
**SeriesType** (3): `line`, `area`, `step`
|
|
537
|
+
|
|
538
|
+
**Annotation.type** (5): `line`, `arrow`, `rect`, `point`, `label`
|
|
539
|
+
|
|
540
|
+
**Highlight.labelPosition** (5): `top`, `center`, `bottom`, `above`, `below`
|
|
541
|
+
|
|
542
|
+
**GapStyle.display** (4): `empty`, `dashed_border`, `filled`, `bridge_line`
|
|
543
|
+
|
|
544
|
+
**DrawGapType_t** (3) — legacy `Gap.style`: `dashed_border`, `empty`, `label`
|
|
545
|
+
|
|
546
|
+
**FillSide:** `above`, `below`
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
550
|
+
## 14. Complete example
|
|
551
|
+
|
|
552
|
+
A realistic configuration exercising most of the structure:
|
|
553
|
+
|
|
554
|
+
```json
|
|
555
|
+
{
|
|
556
|
+
"width": 960,
|
|
557
|
+
"height": 420,
|
|
558
|
+
"locale": "de-DE",
|
|
559
|
+
"margin": { "top": 24, "right": 72, "bottom": 48, "left": 56 },
|
|
560
|
+
|
|
561
|
+
"legend": { "show": true, "position": "outside-right", "orientation": "vertical" },
|
|
562
|
+
|
|
563
|
+
"axes": {
|
|
564
|
+
"x": {
|
|
565
|
+
"label": "Zeit",
|
|
566
|
+
"domain": [1705243200000, 1705329600000],
|
|
567
|
+
"grid": { "major": { "color": "#e5e7eb", "width": 1 }, "minor": false }
|
|
568
|
+
},
|
|
569
|
+
"left": { "label": "Temperatur (°C)", "domain": [0, 120] },
|
|
570
|
+
"right": { "label": "Druck (bar)", "domain": [0, 16] }
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
"series": [
|
|
574
|
+
{
|
|
575
|
+
"id": "t-main",
|
|
576
|
+
"name": "Reaktor T",
|
|
577
|
+
"yAxisIndex": 0,
|
|
578
|
+
"seriesType": "line",
|
|
579
|
+
"style": {
|
|
580
|
+
"line": { "color": "#0ea5e9", "width": 2 },
|
|
581
|
+
"fill": {
|
|
582
|
+
"regions": [
|
|
583
|
+
{ "from": "series", "to": { "threshold": "min-temp" },
|
|
584
|
+
"fill": { "color": "#bae6fd", "opacity": 1 } }
|
|
585
|
+
]
|
|
586
|
+
},
|
|
587
|
+
"shadow": { "color": "#0ea5e933", "blur": 4, "offsetY": 2 }
|
|
588
|
+
},
|
|
589
|
+
"overlays": [
|
|
590
|
+
{ "kind": "movingAverage", "window": 60, "type": "exponential" },
|
|
591
|
+
{ "kind": "limits", "low": 55, "high": 95 }
|
|
592
|
+
],
|
|
593
|
+
"data": [
|
|
594
|
+
{ "time": 1705243800000, "value": 62 },
|
|
595
|
+
{ "time": 1705247400000, "value": 88 },
|
|
596
|
+
{ "time": 1705251000000, "value": null }
|
|
597
|
+
]
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
"name": "Druckmittel",
|
|
601
|
+
"yAxisIndex": 1,
|
|
602
|
+
"showAs": "band",
|
|
603
|
+
"minColor": "#a3e634",
|
|
604
|
+
"maxColor": "#65a30d",
|
|
605
|
+
"data": [
|
|
606
|
+
{ "time": 1705245000000, "min": 8.1, "max": 9.4, "avg": 8.8, "count": 14 }
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
],
|
|
610
|
+
|
|
611
|
+
"thresholds": [
|
|
612
|
+
{ "name": "max-temp", "value": 95, "color": "#e11d48",
|
|
613
|
+
"fill": "above", "fillHatch": "classic-diagonal",
|
|
614
|
+
"label": { "text": "Grenzwert 95 °C", "position": "outside-right" } },
|
|
615
|
+
{ "name": "min-temp", "value": 30, "color": "#2563eb", "line": "dotted" }
|
|
616
|
+
],
|
|
617
|
+
|
|
618
|
+
"highlights": [
|
|
619
|
+
{ "startTime": 1705259400000, "endTime": 1705262000000,
|
|
620
|
+
"label": "Stillstand", "color": "#fbbf24", "opacity": 0.25,
|
|
621
|
+
"labelPosition": "center" }
|
|
622
|
+
],
|
|
623
|
+
|
|
624
|
+
"markers": [
|
|
625
|
+
{ "time": 1705265600000, "label": "Probenahme",
|
|
626
|
+
"pointStyle": "diamond", "lineStyle": "to-top", "color": "#7c3aed" }
|
|
627
|
+
],
|
|
628
|
+
|
|
629
|
+
"annotations": [
|
|
630
|
+
{ "type": "rect",
|
|
631
|
+
"from": { "time": 1705255800000, "value": 60 },
|
|
632
|
+
"to": { "time": 1705260600000, "value": 110 },
|
|
633
|
+
"fill": "#f43f5e", "hatch": "dots", "opacity": 0.12 }
|
|
634
|
+
],
|
|
635
|
+
|
|
636
|
+
"annotationBands": [
|
|
637
|
+
{
|
|
638
|
+
"name": "Schicht",
|
|
639
|
+
"height": 26,
|
|
640
|
+
"items": [
|
|
641
|
+
{ "startTime": 1705243200000, "endTime": 1705268400000,
|
|
642
|
+
"fill": "#3b82f688", "label": "Schicht A" },
|
|
643
|
+
{ "startTime": 1705268400000, "endTime": 1705291200000,
|
|
644
|
+
"fill": "#8b5cf688", "label": "Schicht B" }
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
],
|
|
648
|
+
|
|
649
|
+
"gaps": {
|
|
650
|
+
"autoDetect": true,
|
|
651
|
+
"minGapMs": 3600000,
|
|
652
|
+
"style": {
|
|
653
|
+
"display": "dashed_border",
|
|
654
|
+
"label": { "text": "keine Daten" }
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
> Reminder: the example above is valid JSON. If you build it programmatically you may additionally set `renderer`, axis label/value/formatters, and tooltip options in code — those fields are intentionally excluded here because they hold live functions/objects.
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
## 15. Related documentation
|
|
665
|
+
|
|
666
|
+
- **[QUICKSTART_GRAPH_BUILDER.md](./QUICKSTART_GRAPH_BUILDER.md)** — how to build the same structure fluently with `GraphBuilder`
|
|
667
|
+
- **[USAGE.md](./USAGE.md)** — usage walkthroughs and recipes
|
|
668
|
+
- **[USAGE.md](./USAGE.md)** — the API from a caller’s view
|