Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JavaScript
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['CEO', 'COO', 'CFO', 'CTO', 'SVP'],
labels: {
useHTML: true,
formatter: function () {
console.log(this.pos);
var tip = '<div class="hastip" title="' + this.value + ' abbreviated tooltip">' + this.value + '</div>';
return tip;
}
}
},
yAxis: {
min: 0,
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}',
formatter: function () {
var __value = '';
switch(this.x){
case 'CEO':
__value = 'Chief Executive Officer';
break;
case 'COO':
__value = 'Chief Operations Officer';
break;
case 'CFO':
__value = 'Chief Financial Officer';
break;
case 'CTO':
__value = 'Chief Technology Officer';
break;
case 'SVP':
__value = 'Senior Vice President';
break;
}
var tooltip = '<b>' + __value + '</b>';
return tooltip;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'Low',
data: [5, 3, 4, 7, 2]
}, {
name: 'Medium',
data: [2, 2, 3, 2, 1]
}, {
name: 'High',
data: [3, 4, 4, 2, 5]
}]
});