Highcharts Demo
author(s): Torstein Hønsi
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<div id="container"></div>
JavaScript
(function(H) {
const {
correctFloat,
defined,
pick,
isArray,
isNumber,
Series,
StackItem
} = H;
Series.prototype.setStackedPoints = function(stackingParam) {
var stacking = stackingParam || this.options.stacking;
if (!stacking || (this.visible !== true &&
this.chart.options.chart.ignoreHiddenSeries !== false)) {
return;
}
var series = this,
xData = series.processedXData,
yData = series.processedYData,
stackedYData = [],
yDataLength = yData.length,
seriesOptions = series.options,
threshold = seriesOptions.threshold,
stackThreshold = pick(seriesOptions.startFromThreshold && threshold, 0),
stackOption = seriesOptions.stack,
stackKey = stackingParam ? series.type + "," + stacking : series.stackKey,
negKey = '-' + stackKey,
negStacks = series.negStacks,
yAxis = series.yAxis,
stacks = yAxis.stacking.stacks,
oldStacks = yAxis.stacking.oldStacks,
stackIndicator, isNegative, stack, other, key, pointKey, i, x, y;
yAxis.stacking.stacksTouched += 1;
// loop over the non-null y values and read them into a local array
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
pointKey = stackIndicator.key;
// Read stacked values into a stack based on the x value,
// the sign of y and the stack key. Stacking is also handled for null
// values (#739)
isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
key = isNegative ? negKey : stackKey;
// Create empty object for this stack if it doesn't exist yet
if (!stacks[key]) {
stacks[key] = {};
}
// Initialize StackItem for this x
if (!stacks[key][x]) {
if (oldStacks[key] &&
oldStacks[key][x]) {
stacks[key][x] = oldStacks[key][x];
stacks[key][x].total =...