# `ixfx-data-display`

A debug data display component that renders key-value pairs from a plain object. Supports 7 inline render modes (`led`, `plot`, `plot-xy`, `plot-heat`, `plot-histogram`, `time-elapsed`, `hide`) via `configure()`, automatic mode assignment via `automap`, and recursive nested objects.

```html
<ixfx-data-display></ixfx-data-display>
```

```js
const display = document.querySelector('ixfx-data-display');
display.updateData({
  temperature: 23.45,
  humidity: 0.62,
  status: 'active',
});
```

### Usage modes

**Text-only** (default, no config): renders all values as text. Nested objects create child `<ixfx-data-display>` elements.

**`automap` attribute**: boolean values → LED, numbers → plot, objects → recursive child display, everything else → text.

**`configure(config)`**: explicit render style per dot-path. Replaces any previous config and re-renders.

```js
display.configure([
  ['flag', 'led'],
  ['position', 'plot-xy'],
  ['timestamp', 'time-elapsed'],
  ['sensor.gyro', 'plot'],
  ['sensor.accel', 'hide'],
]);
```

### Methods

| Method | Arguments | Description |
|--------|-----------|-------------|
| `updateData(value)` | `Record<string, unknown> \| unknown[]` | Store full data and update all renderers; plot values accumulate only on change |
| `displayData(o)` | `Record<string, unknown> \| unknown[]` | Update data without change tracking |
| `formatValue(v, options?)` | `unknown, FormattingOptions?` | Format a single value to string |
| `configure(config)` | `[path: string, style: RendererStyle, options?: Record<string, unknown>][]` | Set render styles per path |

### Properties / attributes

| Attribute / Property | Type | Default | Description |
|----------------------|------|---------|-------------|
| `automap` | `boolean` | `false` | Auto-assign render styles: boolean→led, number→plot |
| `configure()` | method | — | Explicit render style config |

### Render styles

| Style | Tag | Value types | Behaviour |
|-------|-----|-------------|-----------|
| `led` | `ixfx-led` | `boolean`, `number` | Toggle or proportional brightness (number mapped 0..1) |
| `plot` | `ixfx-plot-single-axis` / `ixfx-plot-multi-axis` | `number`, `number[]`, `Record<string, number>` | Accumulated time-series |
| `plot-xy` | `ixfx-plot-xy-axis` | `[x, y]`, `{ x, y }`, object with 2 numeric properties | XY scatter |
| `plot-heat` | `ixfx-plot-histogram` | `number` | Heatmap (full-height bars, density via opacity) |
| `plot-histogram` | `ixfx-plot-histogram` | `number` | Histogram (variable bar lengths) |
| `time-elapsed` | `span` | `Date`, `number` (ms/ISO) | Relative time from value to now |
| `hide` | — | any | Row not rendered |

### Options (third element of configure tuple)

| Option | Type | Applies to | Description |
|--------|------|------------|-------------|
| `capacity` | `number` | all plots | Max data points (default: varies by plot) |
| `resolution` | `number` | `plot-heat`, `plot-histogram` | Bucket size (default: `0.1`) |
| `drawStyle` | `string` | `plot` (single-axis), `plot-xy` | Render style (`line-sharp`, `line-round`, `dots`, `circles`, etc.) |
| `orientation` | `string` | `plot-heat`, `plot-histogram` | `horizontal` or `vertical` |
| `layout` | `string` | `plot` (multi-axis) | `overlap`, `horizontal`, `vertical`, `grid` |

### Formatting options

Passed to `formatValue()`:

| Option | Type | Description |
|--------|------|-------------|
| `precision` | `number` | Fixed decimal places |
| `roundNumbers` | `number` | Round to N significant figures |

### CSS custom properties

Renders rows in a CSS grid (`auto auto` columns). Uses standard surface variables:

- `--surface-3` — component background
- `--surface-2-text` — label text colour
- `--border` — row separator
- `--space-m`, `--space-s` — spacing
- `--font-mono` — monospace font for values
- `--size` — LED size (via ixfx-led default of `1ex`)

### TypeScript types

```ts
import type { RendererStyle, FormattingOptions } from 'ixfxfun-components';
```
