Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 15.5 — Contrast, Motion, Zoom and Sound
Data Visualization · Example 3 of 3

Sonification: plan the notes, play on a click

The checker cannot hear, so this example only logs the planned frequencies. play() is the real code path: it runs when a person presses the button.

Accessibility is not only for screen readers. Check that marks have enough contrast in both themes, that the page reflows at high zoom, that motion respects the reader's setting, and consider sound as another way to hear a trend.

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

Compute the contrast of #767676 text on white. Is it enough for body text?

02

Write a function playOne(hz) that plays one half-second note and fades it out.

Explain it without notes

01

What are the two contrast rules for a chart and what ratios do they need?

02

Why can colour not be the only signal?

03

How does the dashboard respect reduced motion in one place?

04

Why does sonification wait for a click?

Sonification: plan the notes, play on a click

Console

(nothing was printed)

Expected console output

Mon  2979 -> 220 Hz
Tue  3992 -> 880 Hz
Wed  3759 -> 728 Hz
Thu  3742 -> 717 Hz
Fri  3648 -> 656 Hz
Sat  3013 -> 242 Hz
Sun  3451 -> 528 Hz
with a gap: 220, rest, 880
all equal: 550, 550
Button added; play() is defined and has not been called.