Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

jquery - D3 chord diagram - How do I select a chord?

I am a beginner in D3 . I have to realize a task: I have to color the chords according to a condition. At the moment I just know how to select and modify all the chords. I would like to know if it is possible to select a particular chord?

Thank you.

question from:https://stackoverflow.com/questions/65915307/d3-chord-diagram-how-do-i-select-a-chord

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

while working with chords you have to keep in mind that each chord data object has a source and a tagert with the exact same structure and these properties have information about the link to another group, this link is one-way which mean for every chord you have to change the style of the group to achieve your request, and that can be done with something like :

var colorlist = [ "#d7d50bff", "#2876b9ff", "#37b578ff", "#64d882ff"] 
svg.selectAll("name of your group").append("path")
   .style("fill", function(d,i){ return colorslist[i] })

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...