[英]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.