Highcharts Demo
author(s): Torstein Hønsi
by E D
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/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px; max-width: 600px; margin: 0 auto"></div>
CSS
.highcharts-tooltip h3 {
margin: 0.3em 0;
}
JavaScript
Highcharts.chart('container', {
chart: {
type: 'bubble',
plotBorderWidth: 1,
zoomType: 'xy'
},
legend: {
enabled: false
},
title: {
text: 'Poverty and cassava dependence (2014)'
},
subtitle: {
text: 'Sources: FAO, WB'
},
xAxis: {
gridLineWidth: 1,
title: {
text: 'Rural poverty'
},
labels: {
format: '{value} %'
},
},
yAxis: {
startOnTick: false,
endOnTick: false,
title: {
text: 'Fraction arable land under cassava'
},
labels: {
format: '{value}'
},
maxPadding: 0.2,
plotLines: [{
color: 'black',
dashStyle: 'dot',
width: 2,
value: 50,
label: {
align: 'right',
style: {
fontStyle: 'italic'
},
text: 'Fraction arable land under cassava',
x: 0
},
zIndex: 3
}]
},
tooltip: {
useHTML: true,
headerFormat: '<table>',
pointFormat: '<tr><th colspan="2"><h3>{point.country}</h3></th></tr>' +
'<tr><th>Rural Poverty:</th><td>{point.x} %</td></tr>' +
'<tr><th>Fraction arable land under cassava:</th><td>{point.y}</td></tr>' +
'<tr><th>Production:</th><td>{point.z} t</td></tr>',
footerFormat: '</table>',
followPointer: true
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}'
}
}
},
series: [{
data: [{
x: 58.3,
y: 0.155461495,
z: 7638880,
name: 'AO',
country: 'Angola'
}, {
x: 39.7,
y: 0.110,
z: 4066711,
name: 'BJ',
country: 'Benin'
}, {
x: 56.8,
y: 0.053,
z: 4914610,
name: 'CM',
country: 'Cameroon'
}, {
x: 69.4,
y: 0.140,
z: 709930,
name: 'CAR',
country: 'Central African Rep.'
}, {
x: 74.8,
y: 0.300,
z: 1296660,
name: 'CR',
country: 'Congo, Rep.'
}, {
x: 56.8,
y: 0.173,
...