Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 20 at 10:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 26 at 03:01 AM

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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!