Charts by Hand, No Library
Build bar, line and scatter charts with plain JavaScript and SVG: margins, scales, axes and nice ticks by hand, so you know what every chart library does for you.
Before you trust a chart library, you should know what it does. In this phase you build the three most common charts with no library at all: bars made of HTML boxes, then bar, line and scatter charts made of SVG shapes that plain JavaScript creates from your data.
You write the two ideas every chart needs by hand: the margin convention (a frame with room for axes) and a scale (a rule that turns a number into a position). You meet every awkward input on purpose: empty data, one value, all values equal, zero, negative numbers, missing days. Each one has a real symptom, and you see it.
At the end you draw all 365 days of Lumen's 2025 rides as a line with hand-made axes inside your own index.html. Then you list what hurt, and that list is the reason Phases 5 to 7 teach D3.
Phase 3 · the story
Arjun, engineer
“I want the team to understand what a chart library does for us before we trust one.”
Arjun is the one engineer at Lumen Bikes. Next month he will pick a chart library for the dashboard, and then the team will depend on it for years. Last time he trusted a library without looking inside, a chart showed a flat line, and nobody could say why.
So he asks the team for one afternoon with no library at all. "If we draw a bar, a line and a dot by hand, we will know what the library is doing for us, and we will know what to check when it goes wrong."
In this phase you spend that afternoon. You turn numbers into boxes, bars, a line and dots, you meet the empty, the zero and the negative, and you finish with a year of rides drawn by hand in the dashboard. You will also learn exactly which parts hurt, so every later tool has a reason.
In this phase
You will learn
- Draw a bar chart, a line chart and a scatter plot with plain JavaScript and SVG
- Write the margin convention and a linear scale by hand, with every edge case handled
- Make axes with nice tick values by hand, and say what a library does instead
- Draw all of Lumen's 2025 rides as a hand-made line chart inside your own index.html
You write code in
In the editor on this page, and in your own lumen-dashboard/index.html (no install needed)
Files you touch
- index.html
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.