Search code examples
javascriptd3.jsd3plus

How to change color of edge on mouse hover in a ring network?


How do I change the color of the edges when I hover my mouse over a node in a ring network?

For example, in this example: http://d3plus.org/examples/basic/9034389/

Mouseover shows default color

whenever we hover over Alpha, the default color is shown. Is it possible to change it to any other color like blue, green, etc.?


Solution

  • You can change the color on hover using .color(). For example, to change to blue, use:

    var visualization = d3plus.viz()
        .color({primary: "#0000ff"}) // <--- change color on hover to blue!
        .container("#viz")  // container DIV to hold the visualization
        .type("rings")      // visualization type
        .edges(connections) // list of node connections
        .focus("alpha")     // ID of the initial center node
        .draw()             // finally, draw the visualization!