简体   繁体   English

javascript svg onmouseover效果

[英]javascript svg onmouseover effect

how do I have popups boxes when moving the mouse over the circle? 将鼠标移到圆圈上时,如何显示弹出框?

I have been trying hours to figure this out. 我一直在努力解决这个问题。 Is it possible to only work on the code in javascript file here without changing anything in the html file? 是否可以仅在此处处理javascript文件中的代码而不更改html文件中的任何内容?

javascript: javascript:

 svg.selectAll("circle")
 .data(sales)
 .enter()

 .....//other circle attributes

 .onmouseover = function(d,i){
    alert("haha");
}

Even the simple alert function didn't work. 即使是简单的警报功能也无法正常工作。 Nothing showed up when I moved over the circle. 当我越过圆圈时,什么也没出现。 this is my first day learning data visualization please help out a newbie thanks! 这是我学习数据可视化的第一天,请帮忙一个新手,谢谢!

Bind event handler by using selection. 通过使用选择绑定事件处理程序 on

 svg.selectAll("circle")
 .data(sales)
 .enter()

 .....//other circle attributes

 .on('mouseover', function(){
     d3.select(this).style('fill', 'red');
  })

JSFiddle Demo: http://jsfiddle.net/sj8gLopz/ JSFiddle演示: http : //jsfiddle.net/sj8gLopz/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM