Pie with legend

author(s): Torstein Hønsi

by sectioni

HTML

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

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

JavaScript

// Build the chart
Highcharts.chart('container', {

  chart: {
    type: 'pie'
  },

  plotOptions: {
    pie: {
      dataLabels: {
        enabled: false
      },
      showInLegend: true
    }
  },

  legend: {
                      enabled: true,
                        align: 'center',
                        verticalAlign: 'bottom',
                        squareSymbol: false,
                        symbolRadius: 0,
                        symbolPadding: 5,
                        symbolHeight: 13,
                        symbolWidth: 4,
                        margin: 24,
                        itemMarginTop: 5,
                        itemMarginBottom: 10,                        
                        itemStyle: {
                            "cursor": "pointer",
                            "fontSize": "14px",
                            "fontWeight": "400",
                            "textOverflow": "hidden",
                            "color": "#000000"
                        },                        
                        useHTML: false,
                        itemHoverStyle: {
                            color: "#45a7ea",
                        },
                        itemHiddenStyle: {
                            color: "#e0e0e0"
                        }
  },

  series: [{
    data: [{
      name: 'C',
      y: 61.41,
    }, {
      name: 'Internet Explorer',
      y: 11.84
    }, {
      name: 'Firefox',
      y: 10.85
    }, {
      name: 'E',
      y: 4.67
    }, {
      name: 'Safari',
      y: 4.18
    }]
  }]
});