【发布时间】:2020-10-16 17:27:12
【问题描述】:
我的图表需要在甜甜圈的中心有一个标签,点击时不应旋转。
https://codepen.io/scratchy303/pen/dyXMzrz
我可以在同级“g”组中附加标签并旋转弧组吗? 我可以只翻译圆弧而不是旋转整个 SVG 吗? 最简单的解决方案是什么?
var svg = d3.select("#pieChart").append("svg")
.attr("width", '100%')
.attr("height", '100%')
.attr('viewBox', '0 0 ' + Math.min(width, height) + ' ' + Math.min(width, height))
.attr('preserveAspectRatio', 'xMinYMin')
.append("g")
.attr("transform", "translate(" + radius + "," + height / 2 + ")")
.style("filter", "url(#drop-shadow)");
svg.append("g")
.append("text")
.attr("text-anchor", "middle")
.text("Donut Name");
【问题讨论】:
标签: d3.js