1
我有一個強制定向圖,我喜歡強調它的父母並使它們比其他人大一些我可以讓它們變成新顏色並使它們變大但我無法返回他們到他們的默認大小和顏色。 每當我將鼠標移動到元素上時,它將所有元素都改變爲綠色,但是當我移出鼠標時,只有中心元素改變顏色,但它不會返回到它自己的顏色,它會返回到我將鼠標放在其上的顏色。如何在鼠標移出後在元素上設置默認顏色D3
function highlightParents(d) {
var colour = d3.event.type === 'mouseover' ? 'green' : color(d.group);
d3.select('#id-' + parseInt(d.id)).style('fill', colour);
var bid = "";
for (var i = 0; i < link._groups[0].length; i++) {
if (link._groups[0][i].attributes[0].value.replace("t-", "") == d.id) //target
{
bid += link._groups[0][i].attributes[1].value.replace("s-", ""); //source
d.id = link._groups[0][i].attributes[1].value.replace("s-", ""); //source
var colour = d3.event.type === 'mouseover' ? 'green' : color(d.group);
d3.select('#id-' + parseInt(d.id)).style('fill', colour);
var setr = d3.event.type === 'mouseover' ? '7' : 5;
d3.select('#id-' + parseInt(d.id)).style('r', setr);
i = 0;
if (link._groups[0][i].attributes[1].value == "304410") {
break;
d3.selectAll('#id-' + parseInt(d.id)).style('fill', (d.group));
}
}
}
}
變種顏色= d3.event.type === '鼠標懸停'? 'green':color(d.group); 我認爲這問問已經超出或超出,但謝謝你的答案 –