Highcharts test tool
by anikettiwari
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
CSS
#container {
min-width: 300px;
max-width: 800px;
height: 400px;
margin: 1em auto;
}
JavaScript
(function (H) {
H.seriesTypes.column.prototype.modifyValue = function (val) {
var minPointVal = this.options.minPointVal;
console.log(val)
if (minPointVal) {
if (val >= 0 && val < minPointVal) {
return minPointVal;
} else if (val < 0 && val > -minPointVal) {
return -minPointVal;
}
}
return val;
};
// Modify the values used in stacks. If impemented in the core, just do this
// inline where y = yData[i] is set.
H.wrap(H.Series.prototype, 'setStackedPoints', function (proceed) {
console.log(this.processedYData)
var yData = this.processedYData,
i = this.processedYData.length;
while(i--) {
if (this.modifyValue) {
yData[i] = this.modifyValue(yData[i]);
}
}
proceed.call(this);
});
}(Highcharts));
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Highcharts issue 1776 summary'
},
xAxis: {
categories: [
'Small positive values',
'Small negative values',
'Positive with a large value in between',
'Mixed pos/neg values',
'Normal values'
]
},
plotOptions: {
column: {
stacking: 'normal',
showInLegend: false,
minPointVal: 100,
dataLabels: {
enabled: true,
}
}
},
series: [{
data: [1, -1, 1, 1, 100]
}, {
data: [1, -1, 1, 1, 100]
}, {
data: [1, -1, 1, 1, 100]
}, {
data: [1, -1, 1, 1, 100]
}, {
data: [1, -1, 1, 1, 100]
}, {
data: [1, -1, 500, -1, 100]
}, {
data: [1, -1, 1, -1, 100]
}, {
data: [1, -1, 1, -1, 100]
}, {
data: [1, -1, 1, -1, 100]
}, {
data: [1, -1, 1,...