Command Palette

Search for a command to run...

Hectal
Phase 10: Colour, Typography and Responsive Charts
Data Visualization · Exercise 4 of 4 Previous
Advanced

Fewer labels when the box is narrow

#box is 300 pixels wide. Draw the twelve months so that a box under 480 pixels gets 4 labels (Jan, Apr, Jul, Oct) and a wider box gets all 12 labels.

The chart must redraw when the box width changes: use a ResizeObserver on #box. The starter draws 12 labels once.

What Check tests

  1. At 300 pixels there are 4 labels
  2. The labels are Jan, Apr, Jul and Oct
  3. After the box is widened to 700 pixels there are 12 labels
  4. Narrowing it again goes back to 4 labels
  5. No attribute holds NaN

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.