javascript - 引用错误: event is not defined firefox d3. js

标签 javascript d3.js error-handling

我在 Firefox 中仅在这一行收到此错误:

.on("mousemove", function() {
    return tooltip.style("top", (event.pageY - 10) + "px").style("left", (event.pageX + 10) + "px");
})

最佳答案

使用d3.eventd3.event 存储当前事件(如果有)。

.on("mousemove", function() {
    return tooltip.style("top", (d3.event.pageY - 10) + "px").style("left", (d3.event.pageX + 10) + "px");
});

Note that the first parameter of the mouse over function is the data bonded to the corresponding element and second parameter is it's index.

关于javascript - 引用错误: event is not defined firefox d3. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33865765/

相关文章:

javascript - 传单折线 SmoothFactor 范围

javascript - 添加文本标签

javascript - 更新链接形状时在 Safari 中使用中断的 SVG clipPath

php - 在Stripe PHP上捕获特定错误以显示自定义消息

javascript - 如何处理前端的标准错误对象?

php - 模块 : failed to open stream: No such file or directory

javascript - 动态调整浏览器窗口大小填充 Canvas

javascript - promise 链如何开始和结束

javascript - 在 asp.net 中使用 javascript 通过客户端重置文本框

javascript - D3.js 线图 pandas dataframe JSON