cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Introduction
Using the following script we can set column chart values to their absolute values
Before:
After:
Script
Place the following script in the column charts script:
widget.on('processresult', function(w,e) {

 var s = e.result.series[0].data;

 
 for (var i = 0 ; i < s.length ; i++) {


  if(s[i].y<0){
   s[i].y = s[i].y*-1;
  }
  else{
   s[i].y = s[i].y;
  }
  
 }
  
});
For cases when more than one value is plotted, one can apply the following script for both measures:
Before:
After:

Script for two measures:
widget.on('processresult', function(w,e) {

 var s = e.result.series[0].data;
 var t = e.result.series[1].data;
 
 for (var i = 0 ; i < s.length ; i++) {
  debugger

  if(s[i].y<0){
   s[i].y = s[i].y*-1;
  }
  else{
   s[i].y = s[i].y;
  }
  
 }
  for (var j = 0 ; j < t.length ; j++) {
  debugger

  if(t[j].y<0){
   t[j].y = t[j].y*-1;
  }
  else{
   t[j].y = t[j].y;
  }
  
 }
});
Here's for instances where you have more than 1 or 2 series/measures.
widget.on('processresult', function(w,e) {
var leng = e.result.series.length;
for (var k = 0; k < leng; k++) {
var s = e.result.series[k].data;
for (var i = 0 ; i < s.length ; i++) {
debugger
if(s[i].y<0){
s[i].y = s[i].y*-1;
}
else{
s[i].y = s[i].y;
}
}
}});
Rate this article:
Version history
Last update:
‎03-02-2023 09:25 AM
Updated by:
Contributors