Roy*_*Roy 3 javascript svg d3.js
我通过d3创建了多线图。
我正在尝试为每条线(路径)创建一个处理程序,但是它不起作用。
这是创建路径的代码:
var line2 = d3.svg.line()
.x(function(d, i){return x(AXValues[i])})
.y(function(d, i){return y(AYValues[i])});
p2 = svg.append("path")
.datum(ArticleData)
.transition()
.delay(1100)
.attr("id", "p"+i)
.attr("class", "p"+i)
.attr("d", line2(AXValues, AYValues))
.style("stroke", "Brown")
.style("stroke-width", 2)
.style("fill", "none");
Run Code Online (Sandbox Code Playgroud)
我试图做这样的事情:
.on("mouseover", this.style("stroke-width", 5));
Run Code Online (Sandbox Code Playgroud)
您需要将侦听器附加到附加对象:
p2.on("mouseover", function () {
d3.select(this).style("stroke-width", 5);
});
Run Code Online (Sandbox Code Playgroud)
感谢@Lars Kotthoff的更正
| 归档时间: |
|
| 查看次数: |
3863 次 |
| 最近记录: |