Chapter 5: Preparing a Donut Chart - Multiple Series (2)

Same as previous chart, both inner and outer series are concentric rings

HTML

<script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
<body>
<div style="margin: 5px 60px 5px 5px; " id='container'></div>
</body>

JavaScript

$(document).ready(function() {

        function formatWithLineBreaks(str) {
            var words = str.split(' ');
            var lines = [];
            var line = ''; 
            $.each(words, function(idx, word) {
                if (line.length + word.length > 35) {
                    lines.push(line); 
                    line = ''; 
                } 
                line += word + ' ';
            });
            lines.push(line);
            return lines.join('<br/>');
        }

  function colorBrightness(color, brightness) {
      return Highcharts.Color(color).brighten(brightness).get();
  }
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                defaultSeriesType: 'pie',
                borderWidth: 1
            },
            title: {
                text: 'Number of Games Sold (in millions) in 2011',
            },
            credits: { 
               position: {
                  align: 'left',
                  x: 20
               },
               text: 'Source: vgchartz'
            },
            plotOptions: {
               pie: {
                   allowPointSelect: true
               }
            },
            series: [{
                name: 'Publishers',
                innerSize: '18%',
                dataLabels : {
                    distance: -70,
                    color: 'white',
                    formatter: function() {
                         return this.point.name + ':<br/> ' + Highcharts.numberFormat(this.y / 1000000, 2);
                    },
                    style: {
                         fontWeight: 'bold'
                    }
                },
                data: [ [ 'Nintendo', 54030288 ], [ 'Electronic Arts', 31367739 ],
                        [ 'Activision', 30230170 ] ]
            }, {
               name: 'Titles',
               innerSize: '60%',
               dataLabels: {
                   formatter: function() {
          ...