Using the Refresh Data API

By leveraging the refresh data API, you can allow end users to trigger a data refresh for a widget associated with a data source.

You can also allow end users to trigger a data refresh for data sources of the application, which updates the widgets associated with these refreshed data sources. The supported widgets are chart and table.
Note

Currently, the R visualization widget is not supported.

Refresh Data of All Widgets Related to Data Sources of an Application
You can refresh all data sources of an application, which updates the widget associated with each data source, with the following API:

Application.refreshData();

Refresh Data for a Specific Data Source

You can refresh specific data sources, which updates the widget associated with each specified data source, with the following API:

Application.refreshData(datasources: [DataSource]);
Refresh Data of a Specific Widget

You can refresh the data source of a widget, which updates the widget, with the following API: Widget.getDataSource().refreshData();

Sample Code

//Example 1, write the script for the onClick event of a button to refresh all data sources when the button is clicked.

Application.refreshData();

// Example 2, write the script for the onClick event of a button to refresh the data sources of chart_1 and table_1 when the button is clicked. This updates chart_1 and table_1.

var ds1 = Chart_1.getDataSource();
var ds2 = Table_1.getDataSource();
Application.refreshData([ds1, ds2]);


// Example 3, Use the refresh API together with timer API to refresh a widget in a certain interval. 
// Write the script for the onTimeout event of Timer_1 to refresh data of Chart_1 and Chart_2 every one minute.

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

For more information about how to set up and use a timer, you can refer to Using Timer.