Intermediate
Flip the label near the edge
labelSide(pointX, textWidth, chartWidth) decides whether a label goes to the right or the left of its point. It always says "right", so labels near the right edge run off the chart.
Return "left" when pointX + 8 + textWidth would be wider than chartWidth - 4. Otherwise return "right".
What Check tests
- A point far from the edge gets a label on the right
- A point near the right edge gets a label on the left
- A label that fits exactly stays on the right
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.
Press Run to see the page.
Console
Nothing printed yet.