Packed bubble chart

author(s): Sebastian Bochan

by Umair Rafiq

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/coloraxis.js"></script>

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

CSS

.highcharts-figure, .highcharts-data-table table {
    min-width: 320px; 
    max-width: 800px;
    margin: 1em auto;
}

.highcharts-data-table table {
	font-family: Verdana, sans-serif;
	border-collapse: collapse;
	border: 1px solid #EBEBEB;
	margin: 10px auto;
	text-align: center;
	width: 100%;
	max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    type: 'packedbubble',
    height: '100%'
  },
  title: {
    text: 'Carbon emissions around the world (2014)'
  },
  tooltip: {
    useHTML: true,
    pointFormat: '<b>{point.name}:</b> {point.value}m CO<sub>2</sub>'
  },
  plotOptions: {
    packedbubble: {
      minSize: '30%',
      maxSize: '120%',
      zMin: 0,
      zMax: 1000,
      layoutAlgorithm: {
        splitSeries: false,
        gravitationalConstant: 0.02
      },
      dataLabels: {
        enabled: true,
        format: '{point.name}',
        filter: {
          property: 'y',
          operator: '>',
          value: 250
        },
        style: {
          color: 'black',
          textOutline: 'none',
          fontWeight: 'normal'
        }
      }
    }
  },
	legend: {
		align: 'right',
		verticalAlign: 'middle',
		layout: 'vertical'
	},
	colorAxis: {
		reversed: false
	},
  series: [{
    name: 'Europe',
    data: [{
        name: 'Germany',
        value: 767.1
      }, {
        name: 'Croatia',
        value: 20.7
      },
      {
        name: "Belgium",
        value: 97.2
      },
      {
        name: "Czech Republic",
        value: 111.7
      },
      {
        name: "Netherlands",
        value: 158.1
      },
      {
        name: "Spain",
        value: 241.6
      },
      {
        name: "Ukraine",
        value: 249.1
      },
      {
        name: "Poland",
        value: 298.1
      },
      {
        name: "France",
        value: 323.7
      },
      {
        name: "Romania",
        value: 78.3
      },
      {
        name: "United Kingdom",
        value: 415.4
      }, {
        name: "Turkey",
        value: 353.2
      }, {
        name: "Italy",
        value: 337.6
      },
      {
        name: "Greece",
        value: 71.1
      },
      {
        name: "Austria",
        value: 69.8
      },
      {
        name: "Belarus",
        value: 67.7
      },
      {
        name: "Serbia",
        value: 59.3
     ...