Interface DataSource
extractUpdateTime: undefined | string;
fields: Field[];
id: string;
isExtract: boolean;
isPublished: undefined | boolean;
name: string;
getActiveTablesAsync(): Promise<TableSummary[]>;
getConnectionSummariesAsync(): Promise<ConnectionSummary[]>;
getLogicalTableDataAsync(
logicalTableId: string,
options?: DataSourceUnderlyingDataOptions,
): Promise<DataTable>;
getLogicalTablesAsync(): Promise<LogicalTable[]>;
getUnderlyingDataAsync(
options?: DataSourceUnderlyingDataOptions,
): Promise<DataTable>;
refreshAsync(): Promise<void>;
}
Methods
getActiveTablesAsync
Returns Promise<TableSummary[]>
An array of table summary objects that are currently used in the data source.
getConnectionSummariesAsync
Returns Promise<ConnectionSummary[]>
An array of descriptions of the connections within this data source.
getLogicalTableDataAsync
- getLogicalTableDataAsync(
logicalTableId: string,
options?: DataSourceUnderlyingDataOptions,
): Promise<DataTable>Gets the underlying data table for the given logical table id.
Parameters
- logicalTableId: string
Optionaloptions: DataSourceUnderlyingDataOptionsCollection of options to change the behavior of the call.
Returns Promise<DataTable>
A data table containing the underlying data of the data source.
See
getLogicalTableDataReaderAsync to read more than 10,000 rows.
You can use the
getUnderlyingDataOptions.maxRowsproperty to request the number of rows of data to return. If unspecified (maxRows == '0'), the call togetLogicalTableDataAsyncrequests all rows in the logical table. Note that the maximum number of rows returned from thegetLogicalTableDataAsync()method is limited to 10,000 rows. You can use theDataTableproperty,isTotalRowCountLimited, to test whether there is more data. A value of true indicates that the calling function requested more rows than the limit (10,000) and the underlying data source contains more rows than can be returned.The following example shows use of the getLogicalTableDataAsync() method to get the data from a specific logical table in a data source. The example uses the JavaScript find() method to select the workbook, and uses the getLogicalTablesAsync method to identify the logical table id.
const dataSources = await worksheet.getDataSourcesAsync();
const dataSource = dataSources.find(datasource => datasource.name === "Sample - Superstore");
const logicalTables = await dataSource.getLogicalTablesAsync()
const dataTable = await dataSource.getLogicalTableDataAsync(logicalTables[0].id);
console.log(dataTable);
getLogicalTablesAsync
Gets the underlying logical tables used in the data source.
Returns Promise<LogicalTable[]>
An array of logical tables that are currently used in the data source.
The following example uses the
getLogicalTablesAsyncmethod to print the names of the the logical tables to the console.dataSource.getLogicalTablesAsync().then(function (logicalTables) {
// Loop through each table that was used in creating this data source
logicalTables.forEach(function (table) {
console.log(table.caption);
});
});
getUnderlyingDataAsync
Parameters
Optionaloptions: DataSourceUnderlyingDataOptionsCollection of options to change the behavior of the call.
Returns Promise<DataTable>
Returns a promise containing a page of data from the underlying data of the data source.
The following example shows use of the
getUnderlyingDataAsync()method to get the underlying data from a specific data source. The example uses the JavaScriptfind()method to select the workbook and data source.const dataSources = await worksheet.getDataSourcesAsync();
const dataSource = dataSources.find(datasource => datasource.name === "Sample - Superstore");
const dataTable = await dataSource.getUnderlyingDataAsync();
let field = dataTable.columns.find(column => column.fieldName === "Sub-Category");
let list = [];
for (let row of dataTable.data) {
list.push(row[field.index].value);
}
let values = list.filter((el, i, arr) => arr.indexOf(el) === i);
console.log(values);
refreshAsync
This call has the same functionality as clicking the Refresh option on a data source in Tableau. This does not refresh an extract.
NoteThe
refreshAsync()method is intended to be used in scenarios where manual interaction causes a need to refresh the data in the Tableau visualization. The method is not, as currently designed, meant to support or emulate streaming or live visualizations. Extensions that use the method to refresh aggressively or automatically can cause issues on Tableau Server and Tableau Online and are subject to being blocked by the Tableau Online administrator.This call does not currently support refreshing live Google Sheet data sources.
Returns Promise<void>
Promise that resolves when the data source has finished refreshing.
Represents the data source used by a Worksheet.