[英]Modifying svg:path using d3
I've been working on this problem for a while, and i'm stumped :( 我已经在这个问题上工作了一段时间了,我很沮丧:(
I have one svg which contains some buttons i've made. 我有一个svg,其中包含我已创建的一些按钮。 Then in another svg I have a chart with various lines or svg:path's.
然后在另一个svg中,我有一张包含各种线条或svg:path的图表。 When I click a button, I want a specific line to change color.
单击按钮时,我希望特定的行更改颜色。 I have the following code:
我有以下代码:
buttons.selectAll("#infoBox")
.data(mydata)
.enter()
.append("svg:image")
... some attributes here ...
.on("click", function()
{
linechart.selectAll("svg.path")
//right now i'm just selecting all the paths
//because i want to check to see if it works
.style("stroke", "red");
}
Any ideas why this doesn't work? 任何想法为什么这不起作用? You can view my code here if you need more info about how i'm structuring everything (i'm a beginner at javascript, html and css so sorry if my code isn't very clear or concise)
如果您需要有关我如何构造所有内容的更多信息,可以在这里查看我的代码(我是javascript,html和css的初学者,如果我的代码不太清楚或简洁,请对不起)
Thanks for any and all help :) 感谢您提供的所有帮助:)
selectAll("svg.path")
selects all svg
elements that have a class path
. selectAll("svg.path")
选择所有具有类path
svg
元素。 Not sure if that is what you really want. 不确定那是否是您真正想要的。 If you want to select all
path
elements within the svg
elements, you should say: selectAll("svg path")
. 如果要选择
svg
元素内的所有path
元素,应说: selectAll("svg path")
。
I couldn't find the variable linechart
in the link you provided. 我在您提供的链接中找不到变量
linechart
。 If linechart
refers to the selection of svg
elements, than simply saying linechart.selectAll("path")
would be sufficient. 如果
linechart
引用了svg
元素的选择,则仅简单地说linechart.selectAll("path")
就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.