Skip to content

Instantly share code, notes, and snippets.

View louking's full-sized avatar

Lou King louking

  • Ijamsville, MD
  • 15:41 (UTC -05:00)
View GitHub Profile
@louking
louking / README.md
Last active January 31, 2017 10:33 — forked from ZJONSSON/README.md
d3.legend example (d3 v4)

d3.legend

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"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

@louking
louking / .block
Last active October 31, 2017 20:57 — forked from mbostock/.block
Google Maps + D3
license: gpl-3.0