Swatches as SVG

Color-legend uses SVG for Legends and HTML for Swatches. @mbostock, would it possible to use SVG also for Swatches? It would be easier to combine Swatches with Plots in an external applications if I have to use PDF as an output format. I know that @bayre has done SVG swatches but It can’t handle multiple rows - at least not yet. :wink:

1 Like

I agree that SVG swatches would be nice. I had exactly this issue when building a site for a client who wanted the use to have the ability to save any graphics they generated - including the swatch. I ended up writing a custom swatch for just that one case.

The downside of SVG is that it doesn’t have the easy auto wrap to deal with long rows, like DIV elements in HTML do. I guess that SVG text elements have a getBBox method that you could use to implement that.