Interface VizActions
automaticUpdatesArePaused: boolean;
addEventListener(
type: TableauEventType,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
addFilter(fieldName: string, value: string): void;
displayDialogAsync(dialogType: TableauDialogType): Promise<void>;
exportCrosstabAsync(
sheetName: string,
format: CrosstabFileFormat,
): Promise<void>;
exportDataAsync(
sheetName: string,
options?: ExportDataOptions,
): Promise<void>;
exportImageAsync(): Promise<void>;
exportPDFAsync(
sheetNames?: string[],
options?: ExportPDFOptions,
): Promise<void>;
exportPowerPointAsync(sheetNames?: string[]): Promise<void>;
getCurrentSrcAsync(): Promise<string>;
getVizQLDataServiceSessionInfo(): VizQLDataServiceSessionInfo;
isAnalyticsAssistantAvailableAsync(): Promise<boolean>;
launchAnalyticsAssistantAsync(): Promise<void>;
pauseAutomaticUpdatesAsync(): Promise<void>;
redoAsync(): Promise<void>;
refreshDataAsync(): Promise<void>;
removeEventListener(
type: TableauEventType,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
resize(): void;
resumeAutomaticUpdatesAsync(): Promise<void>;
revertAllAsync(): Promise<void>;
toggleAutomaticUpdatesAsync(): Promise<void>;
undoAsync(): Promise<void>;
}
Hierarchy (View Summary)
- VizActions
Index
Methods
Properties
Methods
addEventListener
- addEventListener(
type: TableauEventType,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidAdds an event listener to the specified event.
async function getSelectedMarks(event) {
const marksSelected = await event.detail.getMarksAsync();
const numMarks = marksSelected.data[0].data.length;
console.log(`${numMarks} marks Selected`);
}
let viz = document.getElementById('tableauViz');
viz.addEventListener("markselectionchanged", getSelectedMarks);Parameters
- type: TableauEventType
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
addFilter
Use this method to filter the viz before initialization. If used after initialization, it will re-render the viz. For filtering after initialization, use the other filtering methods, such as
applyFilterAsync.If you add the same filter fields using the
addFilter()method and by using the<viz-filter>element in the<tableau-viz>web component, you might experience unexpected behavior.Parameters
- fieldName: string
The name of the field to filter on.
- value: string
Single value or a list of comma separated values to filter on.
viz.addFilter('Region', 'Central,West');
Returns void
- fieldName: string
displayDialogAsync
Display one of the export dialogs based on the dialogType parameter
Throws an error if dialogType is invalid
Parameters
- dialogType: TableauDialogType
Returns Promise<void>
exportCrosstabAsync
Exports the crosstab of any given worksheet within the current view to a specified format (CrosstabFileFormat.Excel, CrosstabFileFormat.CSV). Throws an error if the sheet name does not match any worksheets within the active sheet. Throws an error if the crosstab file failed to be created.
NoteexportCrosstabAsyncresolves when a download is initiated. It does not indicate that a download was successful or if the download was complete.let viz = document.getElementById('tableauViz');
viz.exportCrosstabAsync('Sales by Segment', CrosstabFileFormat.CSV);Parameters
- sheetName: string
- format: CrosstabFileFormat
Returns Promise<void>
exportDataAsync
Exports the summary data shown in the View Data window (shown when you click Download > Data from the toolbar for any given worksheet within the current view). The current file format is CSV. There is no limitation on the amount of summary data you can export. Throws an error if the sheet name does not match any worksheets within the active sheet. Throws an error if the CSV file failed to be created.
NoteexportDataAsyncresolves when a download is initiated. It does not indicate that a download was successful or if the download was complete.let viz = document.getElementById('tableauViz');
const activeSheet = viz.workbook.activeSheet;
if (activeSheet.sheetType === SheetType.Worksheet) {
const columns = await activeSheet.getSummaryColumnsInfoAsync();
// Getting fieldId's for Latitude and Longitude columns
const columnsToIncludeById = columns.map((column) => {
if (column.fieldName === 'Latitude' || column.fieldName === 'Longitude') {
return column.fieldId;
}
});
await viz.exportDataAsync(activeSheet.name, { columnsToIncludeById });
}
else if (activeSheet.sheetType === SheetType.Dashboard) {
// Exporting the summary data for each worksheet in the dashboard while also ignoring aliases
for (const worksheet of activeSheet.worksheets) {
await viz.exportDataAsync(worksheet.name, { ignoreAliases: true });
}
}
else
{
// activeSheet is a Story and we want to export worksheets within the current view
const containedSheet = activeSheet.activeStoryPoint.containedSheet;
if (containedSheet !== undefined && containedSheet.sheetType === SheetType.Worksheet) {
// Exporting summary data of a worksheet within the active story point
await viz.exportDataAsync(containedSheet.name);
} else if (containedSheet !== undefined && containedSheet.sheetType === SheetType.Dashboard) {
// Exporting the summary data for each worksheet within the active story point
for (const worksheet of containedSheet.worksheets) {
await viz.exportDataAsync(worksheet.name);
}
}
}Parameters
- sheetName: string
Optionaloptions: ExportDataOptions
Returns Promise<void>
exportImageAsync
Equivalent to clicking on Download > Image from the toolbar, which creates a PNG file of the current visualization.
Returns Promise<void>
exportPDFAsync
Exports the list of sheets with the given ExportPDFOptions options. If no sheets are specified, the current sheet is exported. The list of sheets can either exclusively include the worksheets within a dashboard or exclusively include the published sheets from the workbook. If no ExportPDFOptions are specified, the default settings are: Scaling = Automatic, PageSize = Letter, and Orientation = Portrait.
Throws an error if the list of sheets contains both worksheets within a dashboard and published sheets from the workbook. Throws an error if the PDF file fails to be created.
NoteexportPDFAsyncresolves when a download is initiated. It does not indicate that a download was successful or if the download was complete.let viz = document.getElementById('tableauViz');
const workbook = viz.workbook;
const activeSheet = workbook.activeSheet;
if (activeSheet.sheetType === SheetType.Worksheet || activeSheet.sheetType === SheetType.Story) {
await viz.exportPDFAsync();
} else if (activeSheet.sheetType === SheetType.Dashboard) {
const worksheetNames = activeSheet.worksheets.map((worksheet) => worksheet.name);
await viz.exportPDFAsync(worksheetNames);
}
// exporting all sheets within the workbook to PDF
const publishedSheetNames = workbook.publishedSheetsInfo.map((publishedSheetInfo) => publishedSheetInfo.name);
await viz.exportPDFAsync(publishedSheetNames);Parameters
OptionalsheetNames: string[]Optionaloptions: ExportPDFOptions
Returns Promise<void>
exportPowerPointAsync
Exports the list of sheets to a PowerPoint file. If no sheets are specified, the current sheet is exported. The order the sheets appear in the list is the order the sheets appear in the PowerPoint file. The list of sheets can either exclusively include the worksheets within a dashboard or exclusively include the published sheets from the workbook.
Throws an error if the list of sheets contains both worksheets within a dashboard and published sheets from the workbook. Throws an error if the PowerPoint file fails to be created.
NoteexportPowerPointAsyncresolves when a download is initiated. It does not indicate that a download was successful or if the download was complete.let viz = document.getElementById('tableauViz');
const workbook = viz.workbook;
const activeSheet = workbook.activeSheet;
if (activeSheet.sheetType === SheetType.Worksheet || activeSheet.sheetType === SheetType.Story) {
await viz.exportPowerPointAsync();
} else if (activeSheet.sheetType === SheetType.Dashboard) {
const worksheetNames = activeSheet.worksheets.map((worksheet) => worksheet.name);
await viz.exportPowerPointAsync(worksheetNames);
}
// exporting all sheets within the workbook to PowerPoint
const publishedSheetNames = workbook.publishedSheetsInfo.map((publishedSheetInfo) => publishedSheetInfo.name);
await viz.exportPowerPointAsync(publishedSheetNames);Parameters
OptionalsheetNames: string[]
Returns Promise<void>
getCurrentSrcAsync
Gets the visualization's current URL.
Returns Promise<string>
getVizQLDataServiceSessionInfo
Gets the server session information for use with VizQL Data Service. The server session information contains the VizQL Server Session ID (X-Session-Id) and the Global Session Header (Global-Session-Header).
Returns VizQLDataServiceSessionInfo
isAnalyticsAssistantAvailableAsync
Indicates whether the Analytics Assistant side pane is available.
Returns Promise<boolean>
launchAnalyticsAssistantAsync
Use this method to launch the Analytics Assistant side pane. You can use the
isAnalyticsAssistantAvailableAsync()method to check if the Analytics Assistant is available for use.const isAnalyticsAssistantAvailable = await viz.isAnalyticsAssistantAvailableAsync();
if (isAnalyticsAssistantAvailable) {
await viz.launchAnalyticsAssistantAsync();
}Returns Promise<void>
pauseAutomaticUpdatesAsync
Pause layout updates. This is useful if you are resizing the visualization or performing multiple calls that could affect the layout.
Returns Promise<void>
redoAsync
Redoes the last action performed on a sheet.
Returns Promise<void>
refreshDataAsync
Equivalent to clicking on the Refresh Data toolbar button.
Returns Promise<void>
removeEventListener
- removeEventListener(
type: TableauEventType,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidRemoves an event listener from the specified event.
let viz = document.getElementById('tableauViz');
viz.removeEventListener("markselectionchanged", getSelectedMarks);Parameters
- type: TableauEventType
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
resize
Use this method to readjust the dimensions of the embedded viz in response to things like a window resize, device orientation change, or parent container resize.
window.addEventListener('resize', () => viz.resize());
new ResizeObserver(() => viz.resize()).observe(viz.parentElement);Returns void
resumeAutomaticUpdatesAsync
Resume layout updates.
Returns Promise<void>
revertAllAsync
Equivalent to clicking on the Revert All toolbar button, which restores the workbook to its starting state.
Returns Promise<void>
toggleAutomaticUpdatesAsync
Toggle layout updates.
Returns Promise<void>
undoAsync
Undoes the last action performed on a sheet.
Returns Promise<void>
Partially implemented - Actions related to events and state of the viz