Get path for the active slice in amchart sunburst

168 Views Asked by At

I am trying to implement sequence sunburst like https://observablehq.com/@kerryrodden/sequences-sunburst in amcharts. I am able to achieve the desired behavior but unable to get the path of the currently active slice. For example if I mouse over on a slice at 4th level, I need to get the path (hierarchy till this slice) Level1 --> Level2 --> Level3 --> Level4 as shown in the d3.js based sequence sunburst.

Following is the code I used to capture the value and category on mouseover events:

var chart = am4core.create("chartdiv", am4plugins_sunburst.Sunburst);

chart.events.on("inited", () => {
  chart.series.each((myseries, i) => {
    myseries.events.on("over", (e) => {
      let pieSerie = myseries;
      pieSerie.slices.each((slice, i) => {
        slice.events.on("over", (e) => {
          const currentValue = e.target.dataItem.category + ": " + e.target.dataItem.value;
          console.log(currentValue)
        });
      });
    });
  });
});

Appreciate your inputs.

0

There are 0 best solutions below