SAP Knowledge Base Article - Public

3748038 - getNumberFormat().setScaleUnit() does not work for the numeric point chart when data refresh is “refresh active widgets only” in SAP Analytics Cloud (SAC)

Symptom

  • In a story or a composite used in a story, the initialization script sets the numeric point scale via getNumberFormat().setScaleUnit(...).
  • With Data Refresh set to “Always Refresh”, the scale is applied in the story as expected.
  • With Data Refresh set to “Refresh Active Widgets Only”, the scale is not applied in the story.
  • No error messages are displayed.

Environment

SAP Analytics Cloud

Reproducing the Issue

  1. Create a composite containing a Numeric Point widget and place it in a story.
  2. In the composite’s onInitialization script, call the Numeric Point API to set the scale (for example, getNumberFormat().setScaleUnit(...)).
  3. Set the Numeric Point’s Data Refresh option to “Always Refresh”.
  4. Run the story and observe that the Numeric Point displays the value with the configured scale.
  5. Change the Numeric Point’s Data Refresh option to “Refresh Active Widgets Only” and save.
  6. Run the story again and observe that the Numeric Point no longer applies the configured scale.

Cause

  • Numeric Point charts require the actual measure data to apply scale settings correctly, unlike Bar/Column charts that can apply scale settings based on axis configuration alone. 
  • When the "Refresh Active Widget Only" option is enabled, the chart initiates the first query before the onInitialization script or any data-related API is executed, resulting in empty data when the setScaleUnit script runs. 

Resolution

There are 4 possible solutions:

  1. Move the setScaleUnit script into the onResultChanged event to ensure the scaleUnit API runs on the latest data.
  2. Add getResultSet before setScaleUnit to fetch the latest data.
    • Without getResultSet, the sequence is: Page_1.onInitialization start -> remove/addMember -> setScaleUnit -> Page_1.onInitialization end -> chart fetch data. Chart fetch data is not included in the "Run script Page_1.onInitialization" time.
    • With getResultSet, the sequence changes to: Page_1.onInitialization start -> remove/addMember -> getResultSet(fetchData) -> setScaleUnit -> Page_1.onInitialization end. 
  3. Use the refreshData API to clear server-side and client cache, forcing the chart to fetch the latest data. 
  4. Switch DataRefresh setting from "Refresh Active Widgets Only" to "Always Refresh". In the onInitialization script, call setScaleUnit as before, and then call DataSource.setRefreshPaused(PauseMode.Auto). "Always Refresh" will trigger the widget's data query on the initial page load, and this query will run in parallel with other initial queries. 

Keywords

numeric point, scale unit, setScaleUnit, composite, data refresh, refresh active widgets only, always refresh, onInitialization, onResultChanged, getResultSet, refreshData, number format, k m bn, scripting api, story , KBA , LOD-ANA-AD-INF , Analytics Designer Infrastructure , LOD-ANA-UNS-SCR , Unified Story Scripting related Issues , Problem

Product

SAP Analytics Cloud 1.0