ml-time-graph 1.25.0 → 1.27.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.
@@ -85,7 +85,7 @@ shallow and an `axes` in `b` drops `a`'s grid and ticks. Server-side the same ru
85
85
 
86
86
  | Task | File |
87
87
  | --- | --- |
88
- | Several series, a second or third value axis, `axisGroups`, axis titles and `labelOffset`, margins, grid, minor ticks, time zone | [reference/axes.md](reference/axes.md) |
88
+ | Several series, a second or third value axis, `axisGroups`, axis titles and `labelOffset`, margins, grid, minor ticks, a logarithmic axis (`scale: 'log'`, light sensors), time zone | [reference/axes.md](reference/axes.md) |
89
89
  | Threshold lines and zone colouring, filled areas between curve and threshold or between two series, `where`, `divergenceExcursions` | [reference/thresholds-and-fills.md](reference/thresholds-and-fills.md) |
90
90
  | Missing data (`value: null`), gap regions and labels, `gaps.atEnd` for a device that went quiet, `holdToEnd` for a sensor that reports only on change | [reference/gaps.md](reference/gaps.md) |
91
91
  | Arrows, labels and rectangles in data coordinates, time-range highlights, status bands (short events in long windows: `minItemWidth`), markers | [reference/annotations-and-markers.md](reference/annotations-and-markers.md) |
@@ -96,6 +96,7 @@ shallow and an `axes` in `b` drops `a`'s grid and ticks. Server-side the same ru
96
96
 
97
97
  ## Traps (Read Before Coding)
98
98
 
99
+ - **There are no bar or column charts:** `seriesType` is `'line'`, `'area'` or `'step'` — nothing draws separate bars, groups them side by side or stacks them. For counts per interval (messages per 15 minutes, events per hour) use `seriesType: 'step'` with `style.fill`; it reads like a histogram, and several series overlay cleanly. Do not fake bars out of rectangle annotations.
99
100
  - **Timestamps are numbers, not Date objects:** `time` is always milliseconds since Unix epoch (`number`). Passing a `Date` object fails typechecking or evaluates to `NaN`.
100
101
  - **Margins are fixed unless you measure them:** The chart draws into `margin` (default `{ top: 20, right: 20, bottom: 40, left: 60 }`). A right Y-axis or a formatted unit (`120.5 °C`) does not fit into `right: 20`, and a clipped number is a wrong number (`120` clipped to `20`). Use `margin: 'auto'` — it measures the labels the chart actually draws (no DOM, a few ms), also in JSON for the Go port, the CLI and the PDF; `autoMargin(options)` returns the same numbers if you need them — or set the margins yourself.
101
102
  - **Something you configured does not show up — ask `chart.warnings()`.** Drawing never throws for a threshold name with a typo, a fill bound naming an unknown series, `side` where it is ignored, two series sharing an id, or a deprecated field; it just leaves the thing out. `warnings()` (Go: `Warnings()`, same texts) lists exactly these. Thresholds are found by `id`, and by `name` only when they have no `id`.
@@ -28,6 +28,12 @@ same unit and nearby ranges together, a gap larger than the larger range apart.
28
28
  the middle of the title; the others avoid it. `labels.color` / `labels.fontSize` style the tick
29
29
  numbers and the title alike.
30
30
 
31
+ **Which series belongs to which axis** — when several share one, colour no longer tells.
32
+ `axes.y[i].key: true` (or `axes.left/right.key`) draws a line sample of every series on that
33
+ axis (colour, dash, marker) in the title's lane, above the title; without a title on its own.
34
+ It is drawn, so it survives PDF and print. Too many for the room: the last line reads "+n" and
35
+ `warnings()` reports it — make the chart taller.
36
+
31
37
  ## Axes & Margins
32
38
  The layout engine does not call into the DOM, but it does know how wide text is: the advance
33
39
  widths of the default font stack (`Liberation Sans, Arial, Helvetica` — the three are
@@ -68,6 +74,41 @@ travel in JSON, so the server cannot run yours. Same chart, two renderers, two l
68
74
  the browser is the only renderer; use a generated table when both have to agree. `estimateMetrics`
69
75
  (exported) reproduces the layout of versions before 1.10.0.
70
76
 
77
+ ## Logarithmic value axis — `scale: 'log'`
78
+ For readings that span several orders of magnitude: illuminance (0.1 lx at night, 100,000 lx in
79
+ the sun), particle counts, vacuum pressure, concentrations. Every power of ten gets the same
80
+ height.
81
+
82
+ ```ts
83
+ axes: { left: { scale: 'log', min: 0.1 } }
84
+ axes: { left: { scale: 'log', domain: [1, 100000] } } // both edges fixed
85
+ axes: { left: { scale: 'log', min: 0.1, ticks: { minor: 1 }, grid: { major: {}, minor: {} } } }
86
+ ```
87
+
88
+ - **`min` is required** (or a fixed `domain` whose lower bound is above 0). A logarithmic axis
89
+ has no zero. Without a lower edge the axis **stays linear** and `chart.warnings()` says so —
90
+ the chart does not throw.
91
+ - **Readings below `min` — also 0 and negative ones — are drawn on the edge.** `warnings()`
92
+ reports how many. The edge does not move with the data, so tiles with the same `min` line up;
93
+ the upper edge follows the largest reading unless `domain` fixes it.
94
+ - **Only the picture changes.** Overlays (`movingAverage`, `stdDevBand`, `movingMkt`), aggregated
95
+ min/max/avg and everything in `ml-time-graph/analyze` still compute on the readings. Do not
96
+ take logarithms of your data first — the average of logarithms is not the logarithm of the
97
+ average.
98
+ - **Ticks:** one labelled tick per decade (0.1, 1, 10, 100, 1k, 10k); with far more decades than
99
+ `ticks.major` (default 6) every second or third. Under three decades: 1, 2 and 5 per decade.
100
+ Any `ticks.minor` above 0 (or a `grid.minor`) adds the unlabelled ticks at 2…9 of each decade —
101
+ the count is not used, they are never evenly spaced.
102
+ - **Labels are yours as on any axis:** `format: (v) => …` or `tickFormat: { unit, decimals }`.
103
+ The default writes `0.1`, `1`, `10`, `1k`, `1M`, and `1e-7` below a thousandth. `tickFormat`
104
+ applies the same `decimals` to every tick, so prefer `decimals: 0` or `format` on an axis
105
+ that runs from 0.1 to 100,000.
106
+ - Thresholds, zone colours, fills and markers work unchanged and sit on the drawn line. One
107
+ exception to know: `fill.where.exceeds` compares in units of the reading ("more than 50 lx
108
+ apart"), not in ratios.
109
+ - Per axis, not per chart: `axes.y[i].scale`. An axis whose series carry an `enumMap` ignores it
110
+ (`warnings()` reports that too). Same option in JSON for the Go port, the CLI and the PDF.
111
+
71
112
  ## Grid
72
113
  `axes: { x: { grid: true } }` — a grid in both directions; one axis is enough. `grid: false` on
73
114
  the other axis leaves that direction out; a `false` alone switches nothing on. `true` is short for