Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

D3 Course 9: Color and Size Legends

Public visualization

Viewing a saved revision (read-only)

f404d414ea7a40129b704fd7cc2f5dad

D3 Course 9: Color and Size Legends

0 stars0🌍 Public
GGabrz
Last edited Apr 7, 2020
Created on Apr 6, 2020

This example demonstrates interactive color and size legends built with D3 v5, rendered as SVG. It shows categorical color encoding for fruit types (apple, lemon, lime, orange) using `scaleOrdinal`, and quantitative size encoding for values 0–10 using `scaleSqrt`. The legends are created as reusable components via `colorLegend` and `sizeLegend` functions, which compute tick values from the size scale and position circles with text labels. Styling is applied through external CSS, with the SVG canvas sized at 960×500.

AI-generated description

Data Visualization with D3 Course; <b>Color and Size Legends</b><br>

<table> <th align="left">Topics</th> <tr> <td> <ul> <li><b>Create a color lengend component</b></li> <li><b>Encoding area using a square root scale</b></li> <li><b>Computing ticks from size scale</b></li> <li><b>Creating a size legend component</b></li> <li><b>Tweaking the styles</b></li> </ul> </td> </tr> </table>