Pie demo composition

author(s): Mustapha Mekhatri

by mustapha mekhatria

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>

JavaScript

$(document).ready(function() {

  // Build the chart
  Highcharts.chart('container', {
    chart: {
      plotBackgroundColor: null,
      plotBorderWidth: null,
      plotShadow: false,
      type: 'pie'
    },
    title: {
      text: 'Composition of Air'
    },
    tooltip: {
      pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    plotOptions: {
      pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
          enabled: false
        },
        showInLegend: true
      }
    },
    series: [{
      name: 'Brands',
      colorByPoint: true,
      data: [{
        name: 'Nitrogen',
        color: '#01BAF2',
        y: 78,
      }, {
        name: 'Oxygen',
        color: '#71BF45',
        y: 20.9,
        sliced: true,
        selected: true
      }, {
        name: 'Other gases',
        color: '#FAA74B',
        y: 1.1
      }]
    }]
  });
});