D3路径剪辑到原始区域

时间:2017-01-13 14:08:18

标签: d3.js svg

我正在嵌套一个svg,因为我需要一个随机路径元素在svg设计中居中。当我添加viewBox并重新定位它时,嵌套路径确实与它一起使用,但是可视区域被剪切到它的旧位置。有人可以解释这里发生了什么以及应该如何解决这个问题吗?

原始位置:
enter image description here

搬迁位置:
enter image description here

 let icon = svg.select(".icon")
  .append("svg")
  .attr("width", innerradius * 2)
  .attr("height", innerradius * 2)
  .attr("viewBox", innerradius + " " + innerradius + " 100 100")
  .attr("preserveAspectRatio", "xMidYMid meet")
  .append("path")
  .attr("d", iconpath)

完整代码在这里(第193行) https://jsfiddle.net/dkauwenberg/wjfmLnhu/6/

0 个答案:

没有答案