d3.legend example
This example demonstrates a reusable legend plugin for D3.js, applied to a multi-series line chart of daily average temperatures in New York, San Francisco, and Austin. The legend is generated by adding a `g` element and calling `d3.legend`, which automatically collects items from any SVG element with a `data-legend` attribute. The plugin supports automatic color matching from fill or stroke styles, explicit color overrides via `data-legend-color`, ordering based on bounding-box position or a `data-legend-pos` attribute, and adjustable padding. After one second, the font-size is changed and `d3.legend` is called again to demonstrate how the legend reflows and resizes based on the new font size. The chart itself is a multi-series line chart of daily average temperatures for New York, San Francisco, and Austin, using d3's time scales, linear scales, ordinal color encoding, and SVG line shapes. The legend appears as a boxed set of colored circles with text labels, positioned within the chart's margin area.