当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - nvd3: How highlight bar on click event?

问题描述:

Like mousehover does, when the mouse goes hover the element (bar), it gets highlighted and drops that highlight when mouse leaves.

I'm wondering how to use that behavior but for a click event: highlight the bar when click.

网友答案:

You can always bind event listeners with d3. You select the element and you bind the event. In your concrete element, check the class of the bars and bind it.

Something like this:

d3.selectAll(".nv-bar").on('click',
  function(){
    // add the effects or the class that enlarge the bar
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: