# Printer Stats Dashboard — Z Position Chart Fix

Date: 2026-08-07

## Problem

On the `/printer-stats` dashboard, the **Z Position (24h)** history chart showed large gaps.

Root cause: `sensor.octoprint_current_z` only publishes when the printer moves (Z position changes). During idle periods there are no new state records, so the native `history-graph` card renders those stretches as a gap. An overnight OctoPrint outage (~19:50–21:33) also produced a long `unavailable` break in the line.

The native `history-graph` card does **not** support `connect_spans` (it is silently ignored), so an initial attempt to bridge the gaps that way was a no-op.

## Fix

Replaced the "Z Position (24h)" card with `custom:apexcharts-card` (v2.2.3, already installed and in use on the dashboard — "Print Outcomes (30 days)").

- `fill_raw: "last"` bridges null/`unavailable` values, so idle freezes and the outage render as a continuous flat line instead of a gap
- ApexCharts connects consecutive history points directly, so periods with no new records draw as a straight line
- Stroke width set to `1` (`apex_config.stroke`) so the line matches the dashboard's other charts
- Card moved to directly below the "Print Activity" section header

## Final Card Config

Located at `/printer-stats` → History view → Print Activity section, `views[1].sections[1].cards[1]`.

```yaml
type: custom:apexcharts-card
header:
  show: true
  title: Z Position (24h)
  show_states: true
  colorize_states: true
graph_span: 24h
series:
  - entity: sensor.octoprint_current_z
    name: Current Z
    color: "#ab47bc"
    type: line
    curve: straight
    fill_raw: "last"
grid_options:
  columns: full
apex_config:
  chart:
    height: 300
  stroke:
    width: 1
```

## Config Hash History

| Action | Config hash |
|---|---|
| Replaced card with apexcharts-card | `4c1f4ac4de6971e9` |
| Thinned stroke to 1px | `deda8faff03c7b8b` |
| Moved card below header | `df9fb734b0cb1562` |

## Related Decisions

See `decisions.yaml`:
- `2026-08-07-octoprint-frozen-sensors-shown-via-idle-2` — why the sensor freezes during idle
- `2026-08-07-octoprint-controls-are-mqtt-via` — print controls go through MQTT/input_boolean, not the old MQTT automation
