Command Palette

Search for a command to run...

Hectal
Phase 5: D3 Core: Selections and the Data Join
Data Visualization · Exercise 2 of 5 PreviousNext
Intermediate

A chart that can shrink

Two buttons redraw the chart: 7 days and 3 days. The page starts with 5. The starter only handles growing: after 3 days it still shows the old bars.

Fix draw with a full join, so each click leaves exactly as many bars as there are values, and clicking 7 days again does not add more.

What Check tests

  1. The page starts with 5 bars
  2. After 7 days there are 7 bars
  3. After 3 days there are 3 bars, with the new values
  4. Going back to 7 days gives 7, not 10
  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.