gpt4 book ai didi

d3.js - 使用 d3.tip 的多个鼠标悬停事件

转载 作者:行者123 更新时间:2023-12-04 03:20:42 24 4
gpt4 key购买 nike

我正在尝试更改也调用了 d3.tip 的 svg 元素的笔画。

我的代码的相关部分如下所示:

    map.call(tip);

map.on("mouseover", function(){ d3.select(this).style({stroke:"#7bd362"}); tip.show; });

map.on("mouseout",tip.hide);

我能够让我的代码执行一个事件:在鼠标悬停时更改其笔划,或显示工具提示。但我不能让这两个事件同时发生。

有没有人在 d3 tip 之前和其他鼠标事件方面取得过成功?

最佳答案

我最终需要将数据对象传递给 tip.show() 函数。

最终代码:

map.on("mouseover", function(d){ 
tip.show(d);
})
.on("mouseout", function(d){
tip.hide(d);
});

我还没有尝试过,但这也可能有效:
map.on("mouseover", tip.show).on("mouseout", tip.hide);

关于d3.js - 使用 d3.tip 的多个鼠标悬停事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26696251/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com