How to properly rotate text labels in a D3 sunburst diagram(如何在 D3 旭日形图中正确旋转文本标签)
问题描述
在以下 D3 旭日:
http://jsfiddle.net/maxl/eabFC/
.attr("transform", function(d) {
return "rotate(" + (d.x + d.dx / 2 - Math.PI / 2) / Math.PI * 180 + ")";
});
左象限中的标签是倒置的,我想对它们进行旋转,以便文本从左到右阅读.
The labels in the left quadrants are upside down, I would like to perform a rotation on them so that the text reads from left to right.
转换应该只适用于从大约 100 度到 270 度的弧.
The transformation should only apply to the arcs from approximately 100 degree to 270 degree.
推荐答案
如下示例:http:///www.jasondavies.com/coffee-wheel/
我在这里编辑了你的 jsfiddle:http://tributary.io/inlet/4127332/
I've edited your jsfiddle here: http://tributary.io/inlet/4127332/
你将不得不处理你的长标签,上面的例子展示了如何做多行.
You are going to have to deal with your long labels and the above example shows how to do multi-line.
另外请注意,您使用的是旧版本的 d3,不再需要单独调用 d3.layout.这是 d3 的新闪亮版本的链接:
Also note that you are using an old version of d3, it is no longer necessary to call d3.layout separately. Here is the link to new shiny version of d3:
<script src="aHR0cDovL2QzanMub3JnL2QzLnYzLmpz"></script>
这篇关于如何在 D3 旭日形图中正确旋转文本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 D3 旭日形图中正确旋转文本标签


- 如何显示带有换行符的文本标签? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01