Search code examples
javascriptamchartsamcharts4

How to add custom event on bubble in ForceDirectedTree amcharts


How to change color of the child bubble on click or add hover effect on child bubble. I tried like this:

networkSeries.nodes.template.events.on('hit', e=> {
  e.target.dataItem.color = e.target.dataItem.color.lighten(-0.2)
  //networkSeries.deepInvalidate()
  //networkSeries.invalidate()
})

but it does not refreshing. Here is example code: http://jsfiddle.net/gasnvf0j/


Solution

  • You should assign the color to fill or stroke to see the result:

    const newColor = e.target.dataItem.color.lighten(-0.2)
    e.target.dataItem.color = newColor
    e.target.fill = newColor