Variable radius pie
author(s):
Grzegorz Blachliński
by oysteinmoseng
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/variable-pie.js"></script>
<button id="unfold">
Click to unfold
</button>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
CSS
#unfold {
width: 100px;
margin: 10px auto;
display: block;
font-size: 14px;
font-weight: bold;
cursor: pointer;
}
#container {
height: 500px;
}
.unfolded {
transform: scale(1.3) skew(25deg, 25deg) translate(0, 100px);
filter: hue-rotate(-40deg) grayscale(40%);
background-color: #eee;
}
.highcharts-figure, .highcharts-data-table table {
transition: all 2s;
min-width: 320px;
max-width: 700px;
margin: 1em auto;
border: 2px solid #444;
border-radius: 10px;
padding: 10px;
}
.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
const chart = Highcharts.chart('container', {
chart: {
type: 'variablepie',
backgroundColor: 'transparent'
},
title: {
text: 'Countries compared by population density and total area.'
},
tooltip: {
headerFormat: '',
pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {point.name}</b><br/>' +
'Area (square km): <b>{point.y}</b><br/>' +
'Population density (people per square km): <b>{point.z}</b><br/>'
},
series: [{
minPointSize: 10,
innerSize: '20%',
zMin: 0,
name: 'countries',
data: [{
name: 'Spain',
y: 505370,
z: 92.9
}, {
name: 'France',
y: 551500,
z: 118.7
}, {
name: 'Poland',
y: 312685,
z: 124.6
}, {
name: 'Czech Republic',
y: 78867,
z: 137.5
}, {
name: 'Italy',
y: 301340,
z: 201.8
}, {
name: 'Switzerland',
y: 41277,
z: 214.5
}, {
name: 'Germany',
y: 357022,
z: 235.6
}]
}]
});
document.getElementById('unfold').onclick = () => {
setTimeout(() => chart.update({
title: {
text: 'H E L P!'
},
plotOptions: {
series: {
dataLabels: {
format: 'help'
}
}
}
}), 800);
chart.renderTo.parentNode.classList.add('unfolded');
};