Skip to content

Instantly share code, notes, and snippets.

@kaleguy
kaleguy / .block
Created June 11, 2017 19:14 — forked from mbostock/.block
Area Chart
license: gpl-3.0
@kaleguy
kaleguy / .block
Last active March 6, 2017 09:56 — forked from d3noob/.block
Collapsible tree diagram in v4 from Leo file
license: MIT
height: 480
border: yes
@kaleguy
kaleguy / README.md
Last active March 1, 2017 04:10 — forked from louking/README.md
d3.legend example (d3 v4)

d3.legend

Forked from d3 legend, updated to work with d3 v4.

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"