susielu / d3-legend

A reusable d3 legend component.
http://d3-legend.susielu.com/
Apache License 2.0
727 stars 104 forks source link

Custom shape not working ? #63

Closed lapsus63 closed 7 years ago

lapsus63 commented 7 years ago

Hello, I can't manage to customize shape of my legend using your example. Here is my HTML: <svg id="d3legend"></svg> And my Javascript: var colorPalette = d3.scaleLinear().domain(steps).range(shades); var legend = d3.legendColor() .shape("path", d3.symbol().type(d3.symbolTriangle).size(150)) /* doesn't work */ .scale(colorPalette); var svg = d3.select("#d3legend"); svg.empty(); svg.append("g") .attr("class", "legend") .attr("transform", "translate(20, 20)"); svg.select(".legend").call(window.legend);

Generated output: output

lapsus63 commented 7 years ago

I could make it work calling directly .shape("circle")

susielu commented 7 years ago

Here's a jsfiddle with the code from the website working, can you try it out there? I can't seem to reproduce the error you're talking about: https://jsfiddle.net/maL4L7ky/

susielu commented 7 years ago

@lapsus63 do you have any updates on this? Did the example help?

susielu commented 7 years ago

Closing this for now.