[英]append a element svg inside another svg in d3.js
I currently have a svg that is the main one that contains all my elements. 我目前有一个svg,它是包含所有元素的主要版本。 then I have another svg that corresponds to the drawing of a marker.
那么我有另一个SVG对应于标记的绘图。 Is it possible within my main svg to add the second svg?
是否可以在我的主要svg中添加第二个svg? If so, what is the correct/best way to add 2 of my markers and modify their size?
如果是这样,添加2个标记并修改其大小的正确/最佳方法是什么?
the first svg is being created in this line: 在此行中创建第一个svg:
const svg = d3.select("body").append("svg").attr("width",250).attr("height",250);
the second is the marker.. 第二个是标记。
this is my code: 这是我的代码:
<body>
<div id="circles" style="width:100%; height:100%x; border: 2px solid blue"></div>
<svg viewBox="0 0 26900 35810" xmlns="http://www.w3.org/2000/svg">
<path fill="#D82C62" d="m13406 35810c424-340 9325-12335 10071-13340 1180-1589 2146-2848 2818-5086 2756-9189-4320-17352-12785-17384-9099-34-15490 8788-12948 17248 980 3261 3947 6682 6125 9588l5018 6693c517 689 1266 1582 1701 2281z"/>
</svg>
<script type="text/javascript">
const svg = d3.select("body").append("svg").attr("width",250).attr("height",250);
</script>
</body>
http://plnkr.co/edit/aDEo6wSsDVcv4qUIdHVw?p=preview http://plnkr.co/edit/aDEo6wSsDVcv4qUIdHVw?p=preview
Or you can actually embed child svg in parent svg like this without d3.js: 或者,您实际上可以在不使用d3.js的情况下将子级svg嵌入父级svg中:
<svg>
<g>
<svg>
...
</svg>
</g>
</svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.