[英]How can I set the background color of a svg element which contains a D3 heat map?
[英]How can i set default color on element after mouse out 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));
}
}
}
}
你能用'mouseout'活動嗎?
例如:
function highlightParents(d) {
var colour = color(d.group);
if (d3.event.type === 'mouseover') colour = 'green';
if (d3.event.type === 'mouseout') colour = 'red';
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.