【发布时间】:2020-09-16 09:47:06
【问题描述】:
在帮助的帮助下,我发现了更改径向树状图中元素的方法。 下面的行执行该功能。 但是,我试图猜测我需要用相同的鼠标加粗文本。谁能告诉我我错过了什么?
// 鼠标悬停在节点上时负责改变节点的样式和类型
d3.selectAll('g.node').attr("id", function(d,i){ return "node"+i});
d3.selectAll('path.link').attr("id", function(d,i){ return "link"+i}); //my guess is on the line
below
d3.selectAll('text').attr("id", function(d,i){ return "text"+i});
// 仍在试图弄清楚如何在鼠标悬停时使文本变为粗体
d3.selectAll('g.node').each(function(d, i) {
d3.select('#node'+i).on("mouseover", function() {
d3.select('#link'+(i-1))
.attr('style','stroke-width: 4px','style','font-weight: bold'); // my 2nd guess is on the next
line
d3.select('text').attr("font-weight",function(d,i) {return i*800+800;});
}).on("mouseout", function() { d3.select('#link'+(i-1)).attr('style', 'stroke-width: 1.5px','stroke-opacity: 0.4','stroke: #555'); }); });
【问题讨论】:
标签: d3.js svg dendrogram radial