cancel
Showing results for 
Search instead for 
Did you mean: 

Show "No Data" for data label in vizframe stacked bar chart

0 Kudos

Hello Experts,

I would like to show "No Data" as text if the value is 0 for a dataLabel in a stacked bar chart using vizframe. The data coming from backend is such that the graph is formed with values ranging from 0 to 1.


For example, in the above graph, instead of displaying 0% I want to display "No Data". I have taken the above example from this link -

https://archive.sap.com/discussions/thread/3847251

I have used Chart Formatter to do this. But its not working.

//Chart.controller.js

plotArea: {
dataLabel: {
formatString: CustomerFormat.FIORI_PERCENTAGE_FORMAT_JUST_PERCENT,
visible: true,
}

}

//CustomerFormat.js

chartFormatter.registerCustomFormatter(this.FIORI_PERCENTAGE_FORMAT_JUST_PERCENT,
function(value) {
var percentage = sap.ui.core.format.NumberFormat.getFloatInstance({
style: 'Standard',
maxFractionDigits: 2
});
if (value == 0){
return "NO DATA";
}
return percentage.format(value) + " %";
});

Appreciate all your help.

Thanks,

Prerana

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member196805
Contributor
0 Kudos

You could try define a call back function in plotArea.dataLabel.renderer. Please check this sample http://jsbin.com/mebawagepu/edit?html,output

0 Kudos

Hello Chapman,

Thanks a lot for the reply and apologize for the late reply. I tried your solution but it didn't help. I am able to see the text "No Data" during run time but after the app has finished rendering it disappears. Our customer has escalated this requirement at the moment. If I find another solution, I'll surely share it here. Thanks again!

former_member196805
Contributor
0 Kudos

Are you sure chart was not being re-rendered by any logic between chart initialization and app rendering accomplishment?

0 Kudos

Hi filip.perisic Could you please help me over here? I'm having a similar problem as you had.

Thanks a lot in advance.

- Prerana