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
- At 300 pixels there are 4 labels
- The labels are Jan, Apr, Jul and Oct
- After the box is widened to 700 pixels there are 12 labels
- Narrowing it again goes back to 4 labels
- 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.