KMPCharts/.paul/phases/v0.2.0-plan.md
dtrentin b9ee5ddfa3 Initial commit: chart-realtime KMP library v0.4.1-SNAPSHOT
- RealtimeChart composable with Canvas-based rendering
- TieredBuffer: 3-tier ring buffer (5min full-rate, 10min @10Hz, 45min @1Hz) for 1h data support with ~5MB footprint
- LodDecimator: MEAN / MIN_MAX / MIN_MAX(default) / LTTB render-time decimation
- AxisRenderer: X/Y axis with INSIDE/BESIDE/HIDDEN label modes, T0-relative timestamps, scientific notation
- SignalRenderer: clipRect-bounded path rendering with LoD
- ChartTheme: Material3-compatible dynamic theming (light/dark)
- package: dev.dtrentin.chart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 01:48:51 +02:00

2.3 KiB

v0.2.0 — Bug Fix + Polish

Milestone Goal

Fix axis visibility, add Material3 theme support, dynamic X-window, and scratch-array optimization.

Bugs (from user, 2026-05-20)

  1. Axis not visible — AxisRenderer draws only lines, no text labels
  2. X-axis length not dynamically adjustable from UI
  3. Chart colors must follow Material3 theme (primary, onPrimary, surface, etc.)
  4. Signal colors user-decided (already in SignalConfig.color — document + default fix)

Deferred from v0.1.0

  • LodDecimator scratch array allocation per frame
  • Double snapshot per frame in RealtimeChart

Phases

Phase Name Status
1 Material3 ChartTheme factory Not started
2 Axis text labels (TextMeasurer) Not started
3 Dynamic xWindowSeconds param Not started
4 LodDecimator scratch optimization Not started

Phase Details

Phase 1: Material3 ChartTheme factory

File: chart-realtime/src/commonMain/kotlin/eu/henesis/chart/model/ChartTheme.kt Add @Composable fun rememberMaterialChartTheme(): ChartTheme that reads from MaterialTheme.colorScheme:

  • backgroundColor = colorScheme.surface
  • gridColor = colorScheme.outlineVariant.copy(alpha = 0.4f)
  • axisColor = colorScheme.outline
  • labelColor = colorScheme.onSurface
  • Add labelColor: Color field to ChartTheme (for axis text) Signal colors remain in SignalConfig.color — user-decided.

Phase 2: Axis text labels

File: chart-realtime/src/commonMain/kotlin/eu/henesis/chart/render/AxisRenderer.kt

  • Add TextMeasurer param to drawXAxis / drawYAxis
  • Draw tick values as text at each grid line
  • Add padding (left ~48dp for Y labels, bottom ~24dp for X labels) — canvas inset via Modifier or internal inset

ChartTheme needs labelColor: Color (Phase 1 prereq).

Phase 3: Dynamic xWindowSeconds

File: chart-realtime/src/commonMain/kotlin/eu/henesis/chart/RealtimeChart.kt Add xWindowSeconds: Float = state.config.xWindowSeconds parameter. Caller can pass by remember { mutableStateOf(10f) } and wire a Slider.

Phase 4: LodDecimator scratch optimization

File: chart-realtime/src/commonMain/kotlin/eu/henesis/chart/buffer/LodDecimator.kt Fix TODO: pass pre-allocated colMin, colMax, colHit arrays as params. RealtimeChart pre-allocates and passes them.