Skip to content

Add per-service savings-range bar chart on Home page (solid floor + lighter range, surface ByService data already on the wire) #765

Description

@cristim

Summary

Add a per-service savings-range bar chart to the Home page, supplementing the existing cumulative savings-over-time line chart. The backend already exposes the necessary data via HistoryDataPoint.ByService map[string]float64 on /api/dashboard/savings-over-time; the frontend currently drops that field on the floor.

Design

  • Layout: one vertical bar per service (EC2/RDS/ElastiCache/OpenSearch/Compute/Database/Cache/... — whatever services appear in the response over the selected timeframe).
  • Bar composition: the bar runs from 0 to max(savings) for that service across the selected timeframe, split into two shades:
    • Solid base from 0 to min(savings) for that service — the "guaranteed floor": this service has consistently delivered at least this much across the window.
    • Lighter shade from min to max(savings) — the "range upside": how much the savings can swing over the window.
  • Y-axis: dollars (same units as the existing chart).
  • X-axis: service names (sorted by max desc so the largest service is leftmost).
  • Hover tooltip: per service, show min / median / max / count-of-points, and the percentage of total realized savings the service contributed.
  • Empty state: when no service has positive savings in the window, mirror the line chart's friendly empty-state message.
  • Filter coupling: the new bar chart honours the same account / provider / timeframe filter chips as the line chart and KPI cards (see Home chart drifts from KPIs when a provider filter is active (analytics endpoint missing provider param) #764 for the provider filter gap that affects all three).

Data path

HistoryDataPoint.ByService is already returned per data point by the analytics handler. Frontend just needs to:

  1. Iterate the data_points array, accumulate per-service min/max/sum/count over the window.
  2. Render two-stacked bars: [0 -> min] solid, [min -> max] light.

No backend change required unless by_service is missing on some data points (in which case the analytics aggregator needs to populate it consistently — verify).

Placement

Below the existing cumulative line chart in the Home page Savings section. Same width, same range-selector controls (1d/7d/30d/90d/all) reused.

Test plan

  • Unit test: synthetic data_points with known per-service values produces correct min/max bars.
  • Empty state when zero positive-savings services.
  • Multi-account filter shrinks bars to the filtered subset.
  • Hover tooltip values match the bar geometry.
  • Regression: existing cumulative chart still renders correctly above the new bars.

Out of scope (separate issues)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions