user592419
user592419

Reputation: 5233

Loading shapes into d3

I have a set of shapes that I want to use in D3. They have defined borders and are in png format. I can't figure out how to use them though. This seems like it should be supported, but I've searched around the web and on SO and can't seem to find out how to do so. Can someone point me in the right direction please?

Upvotes: 1

Views: 171

Answers (1)

Elijah
Elijah

Reputation: 4639

SVG shapes are loaded as paths or, in the case of predefined shapes like circles, ellipses and rectangles, as those shapes with attributes that determine their size.

If you're loading pngs, you need to load an image, like this:

newImage = svg.append("svg:image")
.attr("xlink:href", "../yourImageNameAndPath.png")
.attr("width", 280)
.attr("height", 280);

Upvotes: 4

Related Questions