Data in the Browser
Move to your own computer with Node, Vite and npm, then load, parse, date-check, clean and summarise Lumen's real CSV and JSON, with loading, empty and error states.
Until now your numbers were typed into the code. Real dashboards read files: CSV exports, JSON from a server, data in the cloud. This phase moves you to your own computer, where a small development server lets your page fetch files the way a real website does.
Then you learn what really happens to data on its way in: every CSV cell arrives as text, dates hide time zones, and real files have blanks, comma numbers and impossible days. You load the data, check it, clean it without inventing anything, and summarise it with d3-array.
At the end the Lumen Bikes dashboard reads its own data. It shows a loading message while it waits, a clear error box when something is wrong, and a few key numbers when it works. Every later chart builds on this loader.
Phase 4 · the story
Priya, operations lead
“I exported last year's rides from our system, and some of the rows are a mess: can your dashboard read them anyway?”
Priya runs operations at Lumen Bikes. Until now the dashboard has used numbers the team typed in by hand. This week she sends two files from the booking system: a clean export of 365 days, and a March file she calls "the one that made me cry".
In the March file one day has no rides, one has "2,016" with a comma, one is dated 13/03/2025 and another 2025-03-32. A temperature says "n/a", the rain says -1, and one ride lasts 1,240 minutes. She does not want the mess hidden, and she does not want invented numbers either.
By the end of this phase you will be able to read her files on your own computer, tell her exactly which rows were wrong and what you did about each, and give the dashboard a loader that says "loading", "no data" or "could not load" instead of showing a blank page.
In this phase
You will learn
- Set up Node, npm and Vite on your computer and run the dashboard from a local server
- Load CSV and JSON with fetch and D3, and handle a wrong path, bad JSON and a network failure
- Check dates and time zones, clean a messy file with a log, and summarise numbers with d3-array
- Add a loading message and an error box to the dashboard
You write code in
In your Vite project lumen-dashboard/ (run npm run dev), and in the editor on this page
Files you touch
- package.json
- index.html
- src/main.js
- src/data/load.js
- src/data/clean.js
- src/utils/config.js
- src/utils/format.js
- src/charts/rides-line.js
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.