javascript - D3.js Highlight an element when hovering over another -


i have donut chart made using d3.js. change color of arc when hovering on corresponding text.

i know how change color of first, or all, corresponding one.

here's code far. lines highlighting following:

           .on("mouseover", function(d,i){               //d3.select(".donutarcslices").transition().style("fill", "#007dbc");               //d3.selectall(".donutarcslices").transition().style("fill", "#007dbc");               div.transition()                       .duration(200)                       .style("opacity", .9);                   div .html(d.name)                    .style("left", (d3.event.pagex) + "px")                      .style("top", (d3.event.pagey - 28) + "px");             })             .on("mouseout", function(d) {                      d3.select(".donutarcslices").transition().style("fill", "#3e4750");               div.transition()                       .duration(500)                       .style("opacity", 0);                }); 

if add first commented line, when hover on of texts in arcs, first arc changes colors. if remove comments on second line, of arcs change colors upon hovering on of texts.

give each path unique id:

.attr("id", function(d,i){ return "donut"+i}) 

and use when hovering:

d3.select("#donut" + i).transition().style("fill", "#007dbc"); 

here fiddle: https://jsfiddle.net/d6839s03/

ps: mouseout function making gray.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -