Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 15.2 — Short and Long Descriptions
Data Visualization · Example 1 of 2

Descriptions written from the data, edge cases included

describeRides is the function the dashboard uses (src/parts/describe.js). The first four cases are made-up rows. The last line reads the real daily.csv. Dates are UTC midnight, like d3.autoType makes them (Topics 4.2 and 4.3).

A chart needs a short name that says the finding and a longer description that gives the shape, the extremes and the exceptions. Write both from the data, so they cannot disagree with the picture.

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 5 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 describeBars(rows) for rows { name, rides } that returns one sentence naming the top station and its rides, and "No stations" for an empty list.

02

Change the second example so the description paragraph is a <figcaption> inside a <figure>. What changes in the accessible tree and in the code?

Explain it without notes

01

Why write a short description and a long description?

02

Why generate the description from the data?

03

What does aria-describedby do?

04

Which edge cases should a description function handle?

Descriptions written from the data, edge cases included

Console

(nothing was printed)

Expected console output

empty: Line chart of rides per day: no data. There are no rides to show.
one day: Line chart of rides per day. One day with a number: 2 Jun 2025, 2,979 rides.
all equal: Line chart of rides per day. 2 days, from 2 Jun 2025 to 3 Jun 2025. Every day had 100 rides.
a gap: Line chart of rides per day. 3 days, from 2 Jun 2025 to 4 Jun 2025 (1 day has no number and shows as a gap). It starts at 2,979 rides, peaks at 3,759 on 4 Jun 2025 and ends at 3,759. The quietest day is 2 Jun 2025, with 2,979 rides.
full year: Line chart of rides per day. 365 days, from 1 Jan 2025 to 31 Dec 2025. It starts at 1,193 rides, peaks at 4,380 on 18 Jul 2025 and ends at 910. The quietest day is 14 Aug 2025, with 439 rides (app down).