SAP Knowledge Base Article - Public

3625849 - How to make a chart to be auto-hidden when there is no data existing in SAP Analytics Cloud

Symptom

  • The requirement is creating many charts for different datasets with different filter. 
  • And when the special chart contains no data, user want to make it be hidden but not shown with no data information.

Environment

SAP Analytics Cloud 2025.08

Resolution

The requirement can be done by using scripting in Optimized Experience Design of stories. The following can be an example method.

  1. Go to Edit mode to modify the Optimized Experience Design of story
  2. Go to Outline panel and find the chart object.
  3. Click fx button and edit the onResultChanged function
  4. Add one line code as below and save the story.

    Chart_1.setVisible(!Chart_1.getDataSource().isResultEmpty());

    * User needs to change Chart_1 to be the actual chart id for the above sample code.
    * The code logic is first examine the chart data source. And set with the opposite value for the visible properties. E.g. when data source empty is true, then set visible as opposite value false. 
    * This sample code needs to be used when there is some action which can trigger the result change for the chart. E.g. there is other page filter, or input control which can used for changing the data for the chart to trigger this onResultChanged function.

See Also

Your feedback is important to help us improve our knowledge base.

Keywords

waterfall chart, sap analytics cloud, independent display, multiple companies, chart customization, data visualization, sap sac, story filters, charting limitations, sap analytics charting, hide, invisible, program, sdk, script , KBA , LOD-ANA-DES , Story Design & Visualizations , LOD-ANA-UNS-SDK , Unified Story Custom Widget and Hosting , LOD-ANA-UNS-SCR , Unified Story Scripting related Issues , How To

Product

SAP Analytics Cloud 1.0