Tableau Extensions API
    Preparing search index...

    Interface Dashboard

    The Dashboard interface inherits from the Sheet interface.

    interface Dashboard {
        activeDashboardName: string;
        activeDashboardObjectId: number;
        name: string;
        objects: DashboardObject[];
        sheetType: SheetType;
        size: Size;
        worksheets: Worksheet[];
        addEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): TableauEventUnregisterFn;
        applyFilterAsync(
            fieldName: string,
            values: string[],
            updateType: FilterUpdateType,
            filterOptions: FilterOptions,
        ): Promise<string>;
        findParameterAsync(parameterName: string): Promise<undefined | Parameter>;
        getDashboardObjectById(
            dashboardObjectId: number,
        ): undefined | DashboardObject;
        getFiltersAsync(): Promise<Filter[]>;
        getParametersAsync(): Promise<Parameter[]>;
        moveAndResizeDashboardObjectsAsync(
            dashboardObjectPositionAndSizeUpdateArray: DashboardObjectPositionAndSizeUpdateArray,
        ): Promise<void>;
        removeEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): boolean;
        replayAnimationAsync(replaySpeed: ReplaySpeedType): Promise<void>;
        setDashboardObjectVisibilityAsync(
            dashboardObjectVisibilityMap: DashboardObjectVisibilityMap,
        ): Promise<void>;
        setZoneVisibilityAsync(zoneVisibilityMap: ZoneVisibilityMap): Promise<void>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    activeDashboardName: string

    The name of the active dashboard.

    activeDashboardObjectId: number

    The ID of the active object in the dashboard.

    name: string

    The name of the sheet.

    objects: DashboardObject[]

    The collection of objects contained in the dashboard.

    sheetType: SheetType

    The type of the sheet.

    size: Size

    Size of the sheet.

    worksheets: Worksheet[]

    This is a helper method and is equivalent to looping through all of the objects in a dashboard and collecting all of the objects whose type is worksheet. You can use this property to iterate through all of the worksheets in the dashboard.

    The collection of worksheets contained in the dashboard.

    The following example uses the JavaScript forEach() method to traverse the worksheets in the dashboard.

       let dashboard = tableau.extensions.dashboardContent.dashboard;
    dashboard.worksheets.forEach(function (worksheet) {
    // do something with the worksheets..
    console.log("The worksheet name is " + worksheet.name)
    });

    Methods

    • Adds a new event listener to the object. If this object does not support the specified eventType, the method throws an exception. The following table shows the event types supported by objects.

      object eventType
      Worksheet FilterChanged , MarkSelectionChanged, SummaryDataChanged, WorksheetFormattingChanged
      Parameter ParameterChanged
      Settings SettingsChanged
      Dashboard DashboardLayoutChanged, WorkbookFormattingChanged

      Parameters

      • eventType: TableauEventType

        The type of event to register for. The type of event is a TableauEventType enumeration.

      • handler: TableauEventHandlerFn

        The function which will be called when an event happens.

      Returns TableauEventUnregisterFn

      A helper function which can be called to remove this registration.

      The following example sets up a listener in a worksheet for a mark selection event (MarkSelectionChanged). When the event occurs, the data is reloaded. The addEventListener method returns a function that un-registers the event handler. Call that function, in this case, unregisterEventHandlerFunction() to remove the registration.

      // Add an event listener for the selection changed event on this sheet.
      // Assigning the event to a variable just to make the example fit on the page here.
      const markSelection = tableau.TableauEventType.MarkSelectionChanged;
      //
      unregisterEventHandlerFunction = worksheet.addEventListener(markSelection, function (selectionEvent) {
      // When the selection changes, reload the data
      loadSelectedMarks(worksheetName);
      });

      // remove the event listener when done
      unregisterEventHandlerFunction();
    • Applies a simple categorical filter (non-date) to the dashboard. This method is similar to the method used for worksheets, but applies the filter to all the worksheets in the dashboard that have that same field. Note that the filter is ignored by a worksheet if the worksheet doesn't have the relevant field in its data source.

      Parameters

      • fieldName: string

        The name of the field to filter on.

      • values: string[]

        The list of values to filter on.

      • updateType: FilterUpdateType

        The update type of this filter (add, all, remove, replace).

      • filterOptions: FilterOptions

        Advanced filter options (isExcludeMode).

      Returns Promise<string>

      The field name that the filter is applied on.

      1.9.0 and Tableau 2022.2

    • Searches for a parameter with the given name.

      Parameters

      • parameterName: string

        The name of the parameter to find.

      Returns Promise<undefined | Parameter>

      The parameter with the given name, or undefined if it does not exist.

    • Gets the specified dashboard object by its id. If a dashboard object is not found this method returns undefined.

      Parameters

      • dashboardObjectId: number

        The id of an object on the dashboard.

      Returns undefined | DashboardObject

      The dashboard object with that id. Returns undefined if the dashboard object is not found.

      1.7.0 and Tableau 2021.4

      The following example shows how you can get a dashboard object using its id.

        var dashboard = tableau.extensions.dashboardContent.dashboard;
      var myDashboardObject = dashboard.getDashboardObjectById(8);
    • Returns Promise<Filter[]>

      The collection of filters used on the dashboard

      1.9.0 and Tableau 2022.2

    • Returns Promise<Parameter[]>

      A collection of all the Tableau parameters that are used in this workbook.

    • Sets the position and size of one or more floating dashboard objects. Throws an error if the dashboard object is invalid

      Parameters

      Returns Promise<void>

      Empty promise that resolves when the position and size of the dashboard objects have been changed.

      1.7.0 and Tableau 2021.4

      The following example shows how you can update the position and size of multiple (valid, floating) dashboard objects in a dashboard

        let dashboardObjectPositionAndSizeUpdateArray = [];
      let dashboardObjectPositionAndSizeUpdate1 = {
      dashboardObjectID: 1,
      x: 0,
      y: 0,
      width: 50,
      height: 50
      };
      let dashboardObjectPositionAndSizeUpdate2 = {
      dashboardObjectID: 2,
      x: 75,
      y: 75,
      width: 60,
      height: 60
      };
      dashboardObjectPositionAndSizeUpdateArray.push(dashboardObjectPositionAndSizeUpdate1, dashboardObjectPositionAndsizeUpdate2);
      tableau.extensions.dashboardContent.dashboard.moveAndResizeDashboardObjectsAsync(dashboardObjectPositionAndSizeUpdateArray)
      .then(() => {
      console.log("done");
    • Removes an event listener if a matching one is found. If no matching listener exists, the method does nothing. The handler function must the handler function specified in the call to the addEventListener method. Alternatively, use the function returned from the call to addEventListener to unregister the event listener. For more information, see Events and Event Handling.

      Parameters

      Returns boolean

      Whether or not an event listener was removed.

    • Replays an animation for the active sheet Throws an error if the replay speed is invalid

      Parameters

      Returns Promise<void>

      Empty promise that resolves when the animation has been replayed.

      1.7.0 and Tableau 2021.4

      The following example shows how you can replay an animation in a dashboard.

        let replaySpeed = tableau.ReplaySpeedType.Normal;
      tableau.extensions.dashboardContent.dashboard.replayAnimationAsync(replaySpeed).then(() => {
      console.log("done");
    • Sets the visibility of one or more dashboard objects. Throws an error if the dashboard object is invalid

      Parameters

      Returns Promise<void>

      Empty promise that resolves when the visibility has been changed.

      1.7.0 and Tableau 2021.4

      The following example shows how you can update the visibility of multiple valid dashboard objects

        var dashboardObjectVisibilityMap = new Map();
      dashboardObjectVisibilityMap.set(10, tableau.DashboardObjectVisibilityType.Show);
      dashboardObjectVisibilityMap.set(8, tableau.DashboardObjectVisibilityType.Hide);
      var dashboard = tableau.extensions.dashboardContent.dashboard;
      dashboard.setDashboardObjectVisibilityAsync(dashboardObjectVisibilityMap).then(() => {
      console.log("done");
      });
    • Sets the visibility of one or more floating dashboard zones. Throws an error if the zone is invalid

      Parameters

      • zoneVisibilityMap: ZoneVisibilityMap

        A map of zone ids to the desired state of visibility for that zone.

      Returns Promise<void>

      Empty promise that resolves when the visibility has been changed.

      1.1.0

      use setDashboardObjectVisibilityAsync

      The following example shows how you can update the visibility of multiple (valid, floating) zones in a dashboard

        var zoneVisibilityMap = {};
      zoneVisibilityMap[10] = tableau.ZoneVisibilityType.Show;
      zoneVisibilityMap[8] = tableau.ZoneVisibilityType.Hide;
      tableau.extensions.dashboardContent.dashboard.setZoneVisibilityAsync(zoneVisibilityMap).then(() => {
      console.log("done");
      });

      1.4.0 The zoneVisibilityMap can be either an untyped object, or a Map.

        var zoneVisibilityMap = new Map;
      zoneVisibilityMap.set(10, tableau.ZoneVisibilityType.Show);
      zoneVisibilityMap.set(8, tableau.ZoneVisibilityType.Hide);

      1.5.0 The zone can be any zone in the dashboard.