D3JS:放大在悬停的阳光
我将D3.HierArchy与D3.分区一起设置阳光图表。我将值和尺寸设置为erSarchy.count()(将孩子计数并将计数设置为每个节点的值),以便在每个级别上同样尺寸的Sunburst图表。
是否可以在悬停(而不改变其位置)上仅扩大朝阳图表的一部分?如果我使用EG变换量表(1.5),则位置也会向朝阳图的外界移动。
编辑://
我使用此代码来生成阳光弧:
const arc = d3.arc<d3.HierarchyRectangularNode<any>>()
.startAngle(d => d.x0)
.endAngle(d => d.x1)
.padAngle(d => Math.min((d.x1 - d.x0) / 2, 0.005))
.padRadius(width / 4)
.innerRadius(d => d.y0)
.outerRadius(d => d.y1 - 1)
如果我在建议的方法中应用值:
const ringInnerRadius = i.y0;
const ringOuterRadius = i.y1 -1;
const ringMidRadius = (ringInnerRadius + ringOuterRadius) / 2;
const sectorStartAngle = i.x0;
const sectorEndAngle = i.x1;
const sectorMidAngle = (sectorStartAngle + sectorEndAngle) / 2;
const scale = 1.5;
const transX = (1-scale) * ringMidRadius * Math.cos(sectorMidAngle);
const transY = (1-scale) * ringMidRadius * Math.sin(sectorMidAngle);
我提出以下问题。在这里,您可以从中心看到第一个级别,该级别被转移并立即远离中心:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您知道该扇区中心的距离和角度,则可以将扇区缩放1.5,然后将其转换回其所属的位置。
If you know the distance and angle of the center of the sector, then you can scale the sector by 1.5 and then translate it back to where it belongs.
这是无法解决的,我也没有工作。现在,我使用了一种名为Sunburst的不同技术,并突出显示不同的部分。我从 D3JS的阳光与扭曲&gt; v4
This is not resolved, and I do not get it working. Now, I use a different technique named sunburst with distortion to highlight different parts. I updated the code from https://bl.ocks.org/mbostock/1306365 (from the all famous Mike Bostock) for d3 v4 and posted the converted code as an answer to my question here: d3js Sunburst with Distortion > v4