Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.3 — Choose the Chart from the Question
Data Visualization · Example 2 of 2

One data set, three questions, three charts

A correlation near 1 says the dots follow a line. It does not say warm weather causes rides: summer also has longer days and more tourists.

Start from the question, not from the chart type. Each kind of question (compare, change over time, part of a whole, distribution, relationship, ranking, where, flow) has a chart that answers it fastest, and sometimes the best answer is a table or one big number.

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 bikesNeeded(station) that returns how many bikes a station needs to reach 50% full, and 0 if it is already above 50%. Use it for { name: "Clock Tower", bikes: 6, docks: 30 } and { name: "Quay", bikes: 12, docks: 12 }.

02

Rides on 2 June and 3 June are 2,979 and 3,992. Which element do you draw, and what shows before the data loads?

Explain it without notes

01

Priya asks which stations run out of bikes. Which chart do you draw, how do you sort it, and what measure do you use?

02

When is a table or a single number better than a chart?

03

Why is a line chart wrong for the 25 stations' ride totals?

One data set, three questions, three charts

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

busiest weekday on average: Fri 2771
busiest day of the year: 2025-07-18 4380
temperature vs rides, correlation: 0.84