Sunburst - Default behav

Single top node

by amrutaJgtp

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/sunburst.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

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

CSS

#container {
  min-width: 310px;
  max-width: 600px;
  margin: 0 auto
}

JavaScript

var colors = Highcharts.getOptions().colors;
// Splice in transparent for the center circle
Highcharts.getOptions().colors.splice(0, 0, 'transparent');

Highcharts.chart('container', {

  chart: {
    height: '100%'
  },

  title: {
    text: 'Sales for Product Category by Region'
  },
  plotOptions: {
    sunburst: {}
  },
  series: [{
    type: "sunburst",
    data: [{
      id: '1.0',
      name: 'East'
    }, {
      id: '1.1',
      parent: '1.0',
      name: 'Furniture',
      value: 400,
      color: colors[1]
    }, {
      id: '1.2',
      parent: '1.0',
      name: 'Apparel',
      value: 100,
      color: colors[2]
    },{
      id: '1.3',
      parent: '1.0',
      name: 'Technology',
      value: 200,
      color: colors[3]
    }],
    allowDrillToNode: true,
    cursor: 'pointer',
    dataLabels: {
      /**
       * A custom formatter that returns the name only if the inner arc
       * is longer than a certain pixel size, so the shape has place for
       * the label.
       */
      formatter: function() {
        var shape = this.point.node.shapeArgs;

        var innerArcFraction = (shape.end - shape.start) / (2 * Math.PI);
        var perimeter = 2 * Math.PI * shape.innerR;

        var innerArcPixels = innerArcFraction * perimeter;

        if (innerArcPixels > 16) {
          return this.point.name;
        }
      }
    }
  }],
  tooltip: {
    headerFormat: "",
    pointFormat: 'Sales of <b>{point.name}</b> is <b>{point.value}</b>'
  }
});