Tableau Embedding API
    Preparing search index...

    Interface Viz

    The interface for the top level Viz object.

    interface Viz {
        automaticUpdatesArePaused: boolean;
        debug?: boolean;
        device?: DeviceType;
        disableUrlActionsPopups?: boolean;
        height?: string | number;
        hideEditButton?: boolean;
        hideEditInDesktopButton?: boolean;
        hideTabs?: boolean;
        iframeAttributeClass?: string;
        iframeAttributeLoading?: string;
        iframeAttributeStyle?: string;
        iframeAuth?: boolean;
        instanceIdToClone?: string;
        onCustomMarkContextMenuEvent?: string;
        onCustomViewLoaded?: string;
        onCustomViewRemoved?: string;
        onCustomViewSaved?: string;
        onCustomViewSetDefault?: string;
        onEditButtonClicked?: string;
        onEditInDesktopButtonClicked?: string;
        onFilterChanged?: string;
        onFirstInteractive?: string;
        onFirstVizSizeKnown?: string;
        onMarkSelectionChanged?: string;
        onParameterChanged?: string;
        onStoryPointSwitched?: string;
        onSummaryDataChanged?: string;
        onTabSwitched?: string;
        onToolbarStateChanged?: string;
        onUrlAction?: string;
        src?: null | string;
        suppressDefaultEditBehavior?: boolean;
        token?: string;
        toolbar?: Toolbar;
        touchOptimize?: boolean;
        width?: string | number;
        workbook?: Workbook;
        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>;
        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>;
        setAuthToken(token: string): void;
        toggleAutomaticUpdatesAsync(): Promise<void>;
        undoAsync(): Promise<void>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Adds 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

    • 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

    • Display one of the export dialogs based on the dialogType parameter

      Throws an error if dialogType is invalid

      Parameters

      Returns Promise<void>

    • 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.

      Note

      exportCrosstabAsync resolves 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

      Returns Promise<void>

    • 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.

      Note

      exportDataAsync resolves 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

      Returns Promise<void>

    • Equivalent to clicking on Download > Image from the toolbar, which creates a PNG file of the current visualization.

      Returns Promise<void>

    • 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.

      Note

      exportPDFAsync resolves 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

      Returns Promise<void>

    • 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.

      Note

      exportPowerPointAsync resolves 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>

    • Gets the visualization's current URL.

      Returns Promise<string>

    • Indicates whether the Analytics Assistant side pane is available.

      Returns Promise<boolean>

    • 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>

    • Pause layout updates. This is useful if you are resizing the visualization or performing multiple calls that could affect the layout.

      Returns Promise<void>

    • Redoes the last action performed on a sheet.

      Returns Promise<void>

    • Equivalent to clicking on the Refresh Data toolbar button.

      Returns Promise<void>

    • Removes 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

    • 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

    • Resume layout updates.

      Returns Promise<void>

    • Equivalent to clicking on the Revert All toolbar button, which restores the workbook to its starting state.

      Returns Promise<void>

    • Provide an auth token for salesforce native mode

      Parameters

      • token: string

      Returns void

    • Toggle layout updates.

      Returns Promise<void>

    • Undoes the last action performed on a sheet.

      Returns Promise<void>

    Properties

    automaticUpdatesArePaused: boolean

    Indicates whether automatic updates are currently paused.

    debug?: boolean

    Indicates whether the non-minified version of JavaScript is loaded. If specified (or set to true), the non-minified version is used for both the local component and the Tableau Server visualization (if enabled). If not specified (or set to false), the minified version of the JavaScript files are loaded.

    <tableau-viz id="tableauViz" debug />
    <tableau-authoring-viz id="tableauViz" debug />
    <tableau-ask-data id="tableauAskData" debug />
    device?: DeviceType

    Specifies a device layout for a dashboard, if it exists. Values can be default, desktop, tablet, or phone. If not specified, defaults to loading a layout based on the smallest dimension of the hosting iframe element.

    <tableau-viz id="tableauViz"  device="desktop" />
    
    disableUrlActionsPopups?: boolean

    Indicates whether to suppress the execution of URL actions. This option does not prevent the URL action event from being raised. You can use this option to change what happens when a URL action occurs. If set to true and you create an event listener for the URL_ACTION event, you can use an event listener handler to customize the actions.

    <tableau-viz id="tableauViz" disable-url-actions />
    
    height?: string | number

    Represents height in pixels Can be any valid CSS size specifier. If not specified, defaults to the published height of the view.

    hideEditButton?: boolean

    Indicates whether the Edit button is hidden or visible. If not set, defaults to false, meaning that the Edit button is visible.

    <tableau-viz id="tableauViz" hide-edit-button>
    
    hideEditInDesktopButton?: boolean

    Indicates whether the Edit in Desktop button is hidden or visible. If not specified, defaults to false, meaning that the Edit in Desktop button is visible.

    <tableau-viz id="tableauViz" hide-edit-in-desktop-button>
    <tableau-authoring-viz id="tableauViz" hide-edit-in-desktop-button>
    hideTabs?: boolean

    Indicates whether tabs are hidden or shown.

    <tableau-viz id="tableauViz"  hide-tabs />
    
    iframeAttributeClass?: string

    The value of the 'class' attribute of the embedded iframe providing access to any custom selectors defined in the <iframe-style> child tag.

    <tableau-viz id="tableauViz" iframe-attr-class="red-border">
    <iframe-style>
    .red-border {
    border: 1px solid red;
    }
    </iframe-style>
    </tableau-viz>
    iframeAttributeLoading?: string

    The value of the 'loading' attribute of the embedded iframe. See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#loading

    <tableau-viz id="tableauViz" iframe-attr-loading="lazy" />
    <tableau-authoring-viz id="tableauViz" iframe-attr-loading="lazy" />
    <tableau-pulse id="tableauPulse" iframe-attr-loading="lazy" />
    iframeAttributeStyle?: string

    The value of the 'style' attribute of the embedded iframe.

    <tableau-viz id="tableauViz" iframe-attr-style="border: 1px solid red" />
    <tableau-authoring-viz id="tableauViz" iframe-attr-style="border: 1px solid red" />
    <tableau-pulse id="tableauPulse" iframe-attr-style="border: 1px solid red" />
    iframeAuth?: boolean

    Indicates whether to use the old auth mechanism for authentication which happens inside the iframe. If specified, VizLoadErrorEvents triggered due to auth failures will not be thrown.

    <tableau-viz id="tableauViz" iframe-auth />
    <tableau-authoring-viz id="tableauViz" iframe-auth />
    <tableau-ask-data id="tableauAskData" iframe-auth />
    instanceIdToClone?: string

    Specifies the ID of an existing instance to make a copy (clone) of. This is useful if the user wants to continue analysis of an existing visualization without losing the state of the original. If the ID does not refer to an existing visualization, the cloned version is derived from the original visualization.

    <tableau-viz id="tableauViz"  instance-id-to-clone="id1" />
    
    onCustomMarkContextMenuEvent?: string

    An event raised when a custom mark context menu is clicked.

    <tableau-viz id="tableauViz" onCustomMarkContextMenuEvent="onCustomMarkContextMenuEventHandler" />
    
    onCustomViewLoaded?: string

    An event raised when a custom view has finished loading. This event is raised after the callback function for TableauEventType.FirstInteractive (if any) has been called.

    <tableau-viz id="tableauViz" onCustomViewLoaded="onCustomViewLoadedHandler" />
    
    onCustomViewRemoved?: string

    An event raised when a custom view has been removed.

    <tableau-viz id="tableauViz" onCustomViewRemoved="onCustomViewRemovedHandler" />
    
    onCustomViewSaved?: string

    An event raised when a custom view has been saved (newly created or updated).

    <tableau-viz id="tableauViz" onCustomViewSaved="onCustomViewSavedHandler" />
    
    onCustomViewSetDefault?: string

    An event raised when a custom view has been set as the default view for a workbook.

    <tableau-viz id="tableauViz" onCustomViewSetDefault="onCustomViewSetDefaultHandler" />
    
    onEditButtonClicked?: string

    An event raised when the user clicks on the Edit Button.

    <tableau-viz id="tableauViz" onEditButtonClicked="onEditButtonClickedHandler" />
    
    onEditInDesktopButtonClicked?: string

    An event raised when the user clicks on the Edit In Desktop Button. You can use this event type with TableauViz objects.

    <tableau-viz id="tableauViz" onEditInDesktopButtonClicked="onEditInDesktopButtonClickedHandler" />
    <tableau-authoring-viz id="tableauViz" onEditInDesktopButtonClicked="onEditInDesktopButtonClickedHandler" />
    onFilterChanged?: string

    An event raised when any filter has changed state. You can use this event type with TableauViz objects.

    <tableau-viz id="tableauViz" onFilterChanged="onFilterChangedHandler" />
    
    onFirstInteractive?: string

    An event raised when the Viz object first becomes interactive. This is only raised once.

    <tableau-viz id="tableauViz" "onFirstInteractive"="onFirstInteractiveHandler" />
    <tableau-authoring-viz id="tableauViz" onFirstInteractive="onFirstInteractiveHandler" />
    onFirstVizSizeKnown?: string

    An event raised when the size of the viz is known. You can use this event to perform tasks such as resizing the elements surrounding the Viz object once the object's size has been established.

    <tableau-viz id="tableauViz" "onFirstVizSizeKnown"="onFirstVizSizeKnownHandler" />
    <tableau-authoring-viz id="tableauViz" onFirstVizSizeKnown="onFirstVizSizeKnownHandler" />
    onMarkSelectionChanged?: string

    An event raised when the selected marks on a visualization have changed. You can use this event type with TableauViz objects.

    <tableau-viz id="tableauViz" onMarkSelectionChanged="onMarkSelectionChangedHandler" />
    
    onParameterChanged?: string

    An event raised when a parameter has had its value modified. You can use this event type with [[Parameter]] objects.

    <tableau-viz id="tableauViz" onParameterChanged="onParameterChangedHandler" />
    
    onStoryPointSwitched?: string

    An event raised after a new story point becomes active.

    <tableau-viz id="tableauViz" onStoryPointSwitched="onStoryPointSwitchedHandler" />
    
    onSummaryDataChanged?: string

    An event raised when the summary data on a visualization have changed. You can use this event type with TableauViz objects.

    <tableau-viz id="tableauViz" onSummaryDataChanged="onSummaryDataChangedHandler" />
    
    onTabSwitched?: string

    An event raised after a tab switch occurs (the active sheet has changed). Guarantees the viz object will be interactive after this.

    <tableau-viz id="tableauViz" onTabSwitched="onTabSwitchedHandler" />
    
    onToolbarStateChanged?: string

    An event raised when a toolbar button or control becomes available or becomes unavailable.

    <tableau-viz id="tableauViz" onToolbarStateChanged="onToolbarStateChangedHandler" />
    
    onUrlAction?: string

    An event raised when a URL action occurs. See the UrlActionEvent class.

    <tableau-viz id="tableauViz" onUrlAction="onUrlActionHandler" />
    
    src?: null | string

    The viz src

    suppressDefaultEditBehavior?: boolean

    Indicates whether the default edit behavior is suppressed. If not specified, defaults to false, meaning that the default edit behavior is not suppressed.

    <tableau-viz id="tableauViz" suppress-default-edit-behavior>
    <tableau-authoring-viz id="tableauViz" suppress-default-edit-behavior>
    token?: string

    The token used for authorization

    <tableau-viz id="tableauViz" token="some-token-containing-clientId" />
    <tableau-authoring-viz id="tableauViz" token="some-token-containing-clientId" />
    <tableau-ask-data id="tableauAskData" token="some-token-containing-clientId" />
    toolbar?: Toolbar

    Specifies the position of the toolbar, if it is shown. The values can be Toolbar.Top, Toolbar.Bottom or Toolbar.Hidden. If not specified, defaults to Toolbar.Bottom.

    <tableau-viz id="tableauViz"  toolbar="hidden" />
    
    touchOptimize?: boolean

    Indicates whether to touch optimize viz controls.

    <tableau-viz id="tableauViz" touch-optimize />
    <tableau-authoring-viz id="tableauViz" touch-optimize />
    width?: string | number

    Represents width in pixels Can be any valid CSS size specifier. If not specified, defaults to the published width of the view.

    workbook?: Workbook

    One Workbook is supported per visualization.