Skip to main content

True Cost of Water

A dashboard that breaks the cost of water into Raw Water, Energy, and Chemicals & Consumables, with KPI cards, a cost trend line, a cost-distribution donut, and a per-category detail table.

Demo-only prototype — no live data

True Cost is a demonstration prototype. It runs entirely on static dummy data (dummyData/trueCostDummyData.js), makes no API calls, and is routed only in the demo app (/true_cost). There is no production route, no TRUE_COST permission, and no dataSource/controller/store layer. Every figure on the page (₹ amounts, percentages, totals) is illustrative, not real.

  • Reached at: /true_cost in the demo app only → TrueCostPage (libs/trueCost/src/TrueCostPage.jsx)
  • Data: libs/trueCost/src/dummyData/trueCostDummyData.js (imported directly)
  • Library: libs/trueCost/ — components + helper only (no data layer)

What's on the page

Selecting a period (Current presets or a Custom day/month/year) swaps which slice of the dummy dataset is shown.

AreaComponentWhat it showsOn click / action
Filter barTrueCostFormControlCurrent/Custom selector, the period sub-menu, and a date picker for custom day/monthChanging a selector swaps the period. (The "+ Edit expense" button has no handler.)
KPI cardsTrueCostHeaderCardsTotal Water Cost (₹), Average Water Cost (₹/kl), Total Water Used (kl)
Cost trendTrueCostCardSplitGraphView / TotalViewGraphA line chart, Total or Split by categoryTotal/Split radio toggle; in Split, three category checkboxes (unchecking all reverts to Total)
Cost distributionTrueCostPiechartA donut of the three categories with a centred total
Category detailTrueCostTableComponent + TrueCostTableA table of cost lines for the selected categoryTabs switch category (Raw Water / Energy / Chemicals); Sort menu (A–Z or Cost high→low)

Data (dummy)

trueCostDummyData is one static object keyed current (presets: last 7 days, month, last month, last 3 months, year, last year) and custom (days / months / years). Each period holds the same five blocks:

BlockFeeds
headercardThe three KPI cards
tableCardThe per-category detail table (rawWater, energy, chemicals)
pieChartDataThe distribution donut
splitGraph / totalGraphThe trend line chart

Date labels are generated with moment() at import time, so they are always relative to today. helper/trueCostHelper.js provides the period enum and small change handlers — it does no data fetching.


Charts & libraries

PurposeLibrary
Line + pie chartsrecharts
UI / theming@mui/material (MUI 7)
Datesmoment

Charts use Recharts (consistent with the app standard). Exact versions live in package.json.


Edge cases & state

Because the data is a synchronous local object, there is no loading, empty, or error state — only local component state:

  • Total vs Split trend toggle (Split adds per-category checkboxes; all-off reverts to Total).
  • Category tabs + sort (A–Z / cost descending) on the detail table.
  • Defensive guards only (e.g. the donut returns nothing for non-array data).

Code reference

FileRole
TrueCostPage.jsxOrchestrator; selects the dummy-data slice
dummyData/trueCostDummyData.jsAll figures (static)
helper/trueCostHelper.jsPeriod enum + change handlers
components/TrueCostFormControl.jsxPeriod filter bar
components/TrueCostHeaderCards.jsxKPI cards
components/TrueCostCard.jsxTrend card (Total/Split) + distribution
components/TrueCostPiechart.jsxRecharts donut
components/SplitGraphView.jsx · TotalViewGraph.jsxRecharts line charts
components/TrueCostTableComponent.jsx · TrueCostTable.jsxCategory tabs/sort + detail table