Ophir_Buchman
04-20-2022Data Integration
Bar Chart - Add Percentage to the Value Label
When creating a column chart you might want to add a percentage value next to the actual value
Add the following script to your widget:
widget.on('processresult', function(widget,result) {
result.result.plotOptions.series.dataLabels.formatter = function() {
total = 0
this.series.data.forEach(function(datapoint) { total += datapoint.y })
percent = (100 * this.y) / (total);
percent = percent.toFixed(1);
return this.y + '<br/>(' + percent + '%)'
}
})
Before | After |