Custom bar color when using custom column

Hello Team Helical,

I am using custom column for a custom calculation and viewing the result in the form of a bar chart. However the problem is the customization scripts does not work when custom column is being used. It works perfectly fine when it is directly coming from the metadata fields but not when being used like this.
Please help

Thank You
Harika

1 Like

Hello Harika,

You can achieve it by passing the color code in a pre-execution script. You can refer to the below script (which will get added into the ad-hoc report JS portion). In the first line the sequence of colors have been specified.

var barcolor = ['#faa811','#14aef3','#e43f43', '#0ad287','#ff44a1'];

hi_container.set("preExecution",function(c){

var viz_Options = c.get("viz_Options");

viz_Options.chartOptions.data = {
colors : {
No_of_Travels: function(d) { //provide the correct name of the column here
return d.value == d.value ? barcolor[d.x] : 'black';
}
}
};
c.set("viz_Options",viz_Options);
});

Thank You
Team Helical