How to get last level element on click anychart sunburst

Viewed 16

How can I get last level element clicked on anychart sunburst chart. I can get inner levels by using chart.getDrilldownPath(), but not able to identify the how to get last level. below is my code sample

  <html>
  <body>
    <div id="container"></div>

    <script>
      anychart.onDocumentReady(function () {
        // create data
        var data = [
          {
            name: "Company A",
            children: [
              {
                name: "Technical",
                children: [
                  { name: "Team Leaders" },
                  { name: "Architects" },
                  { name: "Developers" },
                  { name: "Testers" },
                ],
              },
              {
                name: "Sales",
                children: [{ name: "Analysts" }, { name: "Executives" }],
              },
              { name: "HR" },
              { name: "Management" },
            ],
          },
        ];

        // create a chart and set the data
        var chart = anychart.sunburst(data, "as-tree");

        // set the calculation mode
        chart.calculationMode("ordinal-from-root");

        // set the chart title
        chart.title().useHtml(true);
        chart.title(
          "Sunburst: Calculation Mode (ordinal-from-root)<br><br>" +
            "<span style='font-size:12; font-style:italic'>" +
            "Corporate Structure</span>"
        );
        chart.listen('chartDraw', function () {
          printPath(chart.getDrilldownPath());
        });

        // set the container id
        chart.container("container");

        // initiate drawing the chart
        chart.draw();
      });

    </script>
  </body>
</html>

There is a click listen event available, but I am unable to identify which element was clicked.

0 Answers
Related