Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.6 — Build: Pick and Sketch the Dashboard's Charts
Data Visualization · Example 1 of 2

From 25 stations to five bars

Rope Walk and West Gate tie at 35% (and Station Road and Hill at 36.7%): the stable sort keeps them in station-number order every time.

Write a chart plan into your dashboard (which chart answers which team question), then replace the pie idea with a hand-made, sorted picture of the five emptiest stations. It answers Priya's question: which stations run out of bikes?

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write bar(x0, y, share, scale) that returns the SVG string for a bar and returns an empty string for a missing or negative share. Test (110, 30, 0.2, 240) and (110, 30, -0.1, 240).

02

Name two situations where a pie chart cannot show the data, and the chart you use instead.

Explain it without notes

01

Why is the five-station chart sorted and measured as bikes ÷ docks rather than listed by station number with raw bike counts?

02

How is each bar's width worked out, and why is Clock Tower's 48?

03

What did the plan decide for Meera's question, and why isn't it a chart?

From 25 stations to five bars

Console

(nothing was printed)

Expected console output

Clock Tower    6 of 30  20.0% width 48 y 30
Rope Walk      7 of 20  35.0% width 84 y 58
West Gate      7 of 20  35.0% width 84 y 86
Station Road  11 of 30  36.7% width 88 y 114
Hill          11 of 30  36.7% width 88 y 142
sixth emptiest: Chapel 41.7%
100% full: Quay, Market, Mill, Harbour Gate, Ferry
stations below 20%: none: show a message, not an empty box
station with 0 docks is skipped: true