Variwide
author(s): Torstein Hønsi
by Pawan Jadhav
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/variwide.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Variwide charts can be used to visualize a second dimension
in a column chart. Each data point is given a weight, in
addition to its value, determining the width of the column.
In this chart, the Y-Axis represents the labor cost of the
country, while the column width is proportional to the
country's GDP.
</p>
</figure>
CSS
#container {
height: 500px;
}
.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: 'variwide'
},
title: {
text: 'Labor Costs in Europe, 2016'
},
subtitle: {
text: 'Source: <a href="http://ec.europa.eu/eurostat/web/' +
'labour-market/labour-costs/main-tables">eurostat</a>'
},
xAxis: {
type: 'linear',
min : 10,
max : 410,
tickPositions: [25, 80, 150,215,262.5,335],
labels: {
formatter: function () {
var label = this.axis.defaultLabelFormatter.call(this);
// Use thousands separator for four-digit numbers too
return label + "-Range";
}
}
},
caption: {
text: 'Column widths are proportional to GDP'
},
legend: {
enabled: false
},
series: [{
name: 'Labor Costs',
data: [
[10,40, 40],
[50, 60, 60],
[110, 80, 80],
[190, 50, 50],
[240, 45, 45],
[285, 10, 100]
],
dataLabels: {
enabled: true,
format: '€{point.y:.0f}'
},
tooltip: {
pointFormat: 'Labor Costs: <b>€ {point.y}/h</b><br>' +
'GDP: <b>€ {point.z} million</b><br>'
}
},{
name :'mys1',
data :[[10,10],
[50,200],
[110,300],
[190,400],
[240,100],
[285,100]]
}]
});