Skip to content

Conversation

@TylonHH
Copy link
Owner

@TylonHH TylonHH commented Jan 2, 2026

Motivation

  • Provide a user-controllable chart scale so bars can be shown from 0–max or from the observed min–max to avoid misleading visuals when values are tightly clustered.
  • Round min/max to sensible steps for price and CO₂ so axis bounds are clean and predictable.
  • Preserve a neutral fallback when data is empty or has zero range to avoid exaggerated heights.

Description

  • Add scaleMode ("zero" | "range") and scaleStep props to TariffChart and wire them from SmartTariffBase via :scale-mode and :scale-step bindings.
  • Implement min/max computation in valueInfo to support the two modes, using Math.min(0,min)/Math.max(0,max) for zero mode and stepped roundDown/roundUp for range mode.
  • Normalize and clamp bar heights in valueStyle using (val - min) / range, and return a 50% neutral height when the range is 0 or value is invalid.
  • Add UI toggle buttons in SmartTariffBase with translations and a chartScaleStep computed value that returns 1 for CO₂ and 0.01 for price.

Testing

  • Started the dev server with npm run dev and the Vite server reported ready, which succeeded.
  • Ran a Playwright script to load the page and capture a screenshot, producing artifacts/tariff-chart-scale-toggle.png, which completed successfully.
  • No unit or integration test suites were executed for this change.

Codex Task

@TylonHH TylonHH merged commit 152012c into master Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants