Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 17.1 — Exploring vs Explaining
Data Visualization · Example 2 of 2

Lina's three findings, and a headline writer that can say nothing

Failure and edge cases that print no error: without the guards, an empty side, a base of 0 or equal groups would still produce a confident sentence.

A dashboard is for exploring: many questions, asked by someone who wants to ask them. A story is for explaining: one point, told to someone who did not ask. The finding comes first, and the audience decides how much you must say.

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 6 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 ebikeFinding(rows) that returns "E-bikes grew from X% of rides in January to Y% in December" with one decimal, or null when either month has no rides. Test it on the real daily rows and on an array with no January days.

02

Lina's page must also say something about the busiest day. Write the headline for it from the data and check it against the chart's tallest point.

Explain it without notes

01

What is the difference between an exploratory and an explanatory visualization? Give an example of each at Lumen Bikes.

02

Why should the headline state the finding, rather than name the chart?

03

Why does the audience change what you build? Compare the city website visitor with Priya.

04

Why can a headline writer fail without any error, and how do you guard against it?

Lina's three findings, and a headline writer that can say nothing

Console

(nothing was printed)

Expected console output

Seasons: summer 3634 vs winter 1480 rides a day
Outage: 14 Aug had 439 rides, other August days averaged 3612
E-bikes: 28.3% of January rides, 37.7% of December rides
--- the same function on awkward input ---
real data      : Summer days carry 2.5 times the rides of winter days
empty winter   : no headline: one side has no data
three days     : no headline: fewer than 7 days is too few to call a pattern
all equal      : no headline: within 5%, no difference worth a title
winter all zero: no headline: the base is 0, so a ratio would be infinite
a NaN in the data: Summer days carry 2.5 times the rides of winter days