Use Refresh Data API

By leveraging the refresh data API in SAP Analytics Cloud, analytics designer, you can let end users trigger data refresh either at widget, data source or application level.

Refresh All or Specific Data Sources of an Application

You can use the following API to refresh all data sources of an application, which updates all the widgets associated with each data source:

Code Syntax
Application.refreshData(dataSources?: DataSource[]): void
You can also specify the data sources, and only the widgets associated with these data sources will be updated. The supported widgets are chart and table.
Note

Currently, R visualization isn't supported.

The script is fully executed without waiting for all the associated widgets to be updated.

Refresh a Specific Data Source

You can use the following API, which triggers the data refresh of a specific data source and updates the widgets associated with it at the same time. The supported widgets are chart, table and geo map.

Code Syntax
DataSource.refreshData(): void

Refresh Data of a Specific Widget

You can use the following API to refresh the data of a specific widget:

Code Syntax
Widget.getDataSource().refreshData();

Example

You can write the following script for the onClick event of a button, so that all the data sources of your analytic application will be refreshed when end users click this button:
Sample Code
Application.refreshData();
In this example, you want to let end users click a button to refresh the data sources of Chart_1 and Table_1. Write the following script for the onClick event of the button:
Sample Code
var ds1 = Chart_1.getDataSource();
var ds2 = Table_1.getDataSource();
Application.refreshData([ds1, ds2]);

In this example, you'd like to refresh data of Chart_1 and Chart_2 every one minute at runtime. You can use refresh data API together with timer API for the onTimeout event of Timer_1:

Sample Code
Chart_1.getDataSource().refreshData();
Chart_2.getDataSource().refreshData();
Timer_1.start(60);

For more information about how to set up and use a timer, see Set up Timers.