Stacked Column with Custom Stack Label Calculation
Shows custom stack label formatter. This chart for example calculates the max of all available values in the stack.
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
CSS
/* Custom Styling used */
.highcharts-stack-labels span {
}
JavaScript
$(function () {
$('#container').highcharts({
chart: {
type: 'column',
events: {
load: function() {
var $labels = $(".highcharts-stack-labels");
$.each($labels, function(index, label) {
var top = $(label).offset().top;
$(label).css({top: (top - 30) + 'px'});
});
}
}
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Quarter 1', 'Quarter 2', 'Quarter 3', 'Quarter 4', 'Quarter 5']
},
yAxis: {
min: 0,
title: {
text: 'P&I'
},
stackLabels: {
enabled: true,
useHTML: true,
style: {
fontWeight: 'bold',
//color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray',
color: 'black',
//backgroundColor: 'rgba(252, 255, 197, 0.7)',
},
}
},
legend: {
borderColor: '#CCC',
borderWidth: 0,
shadow: false
},
tooltip: {
formatter: function () {
/*return '<b>' + this.x + '</b><br/><span style=\'color:' + this.series.color + '\'>' + this.series.name + '</span>: ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;*/
var tip = "<b>" + this.x + "</b>";
tip += "<br/><span>" + this.series.name + "</span>: " + this.y + "<br/>";
tip += "Total: " + this.point.stackTotal;
return tip;
},
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme &&...