cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
When choosing  “Stacked Bar Chart” and select “totals” and we have positive and negative values, we get two totals. 
  1. Totals for the positive numbers at the top
  2. Totals for the negative values at the bottom.
If we want to get only one total that sums both totals we can use the following widget script:
widget.on('beforeviewloaded', function(scope, args){

var yAxis = args.options.yAxis[0];

var chartType = args.options.chart.type;

yAxis.stackLabels.formatter = function() {

var stackType = '-'+chartType;

var negativeStack = this.axis.stacks[stackType][this.x];

var value = this.isNegative ? '' : this.total + (negativeStack ? negativeStack.total : 0);

var formattedValue;

var func = $$get(this, 'axis.options.mask');

var isPercent = $$get(this, 'axis.options.isPercent');

if (isPercent)

{ formattedValue = value + '%'; }

else

{ formattedValue = defined(func) ? func(value) : formatWithCommas(value); }

var result = !angular.isNumber(value) ? value : formattedValue;

return this.isNegative ? '' : result;

};

})

Rate this article:
Version history
Last update:
‎03-02-2023 09:14 AM
Updated by:
Contributors