简体   繁体   English

将形状加载到d3中

[英]Loading shapes into d3

I have a set of shapes that I want to use in D3. 我有一组我想在D3中使用的形状。 They have defined borders and are in png format. 他们定义了边框并采用png格式。 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. 这似乎应该得到支持,但我已经在网上和SO上搜索,似乎无法找到如何做到这一点。 Can someone point me in the right direction please? 有人能指出我正确的方向吗?

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. SVG形状作为路径加载,或者在预定义形状(如圆形,椭圆形和矩形)的情况下加载,具有确定其大小的属性的那些形状。

If you're loading pngs, you need to load an image, like this: 如果你正在加载png,你需要加载一个图像,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM