TagoIO SDK for JavaScript and TypeScript
    Preparing search index...

    Class Widgets

    Hierarchy

    Index

    Constructors

    Methods

    • Parameters

      Returns Promise<{ widget: string }>

      Creates a new widget for a specified dashboard with the given configuration.

      If receive an error "Authorization Denied", check policy Dashboard / Create and Edit in Access Management.

      const result = await Resources.dashboards.widgets.create("dashboard-id-123", {
      data : [{
      origin: "origin-id-123",
      query: "last_value",
      variables: ["temperature"]
      }],
      display: {
      show_units: true,
      show_variables: true,
      variables: [{
      origin: "origin-id-123",
      variable: "temperature"
      }]
      },
      label: "Temperature",
      type: "display",
      });
      console.log(result); // { widget: "widget-id-456" }

      // To add the widget size to the dashboard
      // Before running this, make sure doesn't have more widgets in the dashboard.
      await Resources.dashboards.edit("dashboard-id-123", {
      arrangement: [{ widget_id: result.widget, width: 1, height: 2, minW: 1, minH: 2, x: 0, y: 0 }]
      });
    • Parameters

      • dashboardID: string
      • widgetID: string

      Returns Promise<string>

      Permanently removes a widget from a dashboard.

      If receive an error "Authorization Denied", check policy Dashboard / Delete and Edit in Access Management.

      const result = await Resources.dashboards.widgets.delete("dashboard-id-123", "widget-id-456");
      console.log(result); // Successfully Removed

      // To remove sizes from all widgets from a dashboard
      // Before running this, make sure doesn't have more widgets in the dashboard.
      await Resources.dashboards.edit("dashboard-id-123", { arrangement: [] });
    • Parameters

      • dashboardID: string
      • widgetID: string
      • idPairs: `${string}:${string}`[]

      Returns Promise<string>

      Removes multiple data items from the widget by pairs of data ID and resource ID.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const result = await resources.dashboards.widgets.deleteMultipleData(
      "dashboard-id",
      "widget-id",
      [
      "data_1-id:device_A-id",
      "data_2-id:device_A-id",
      "data_3-id:device_B-id",
      ]
      );
    • Parameters

      • dashboardID: string
      • widgetID: string
      • data: Partial<WidgetInfo>

      Returns Promise<string>

      Updates an existing widget's configuration on a dashboard.

      If receive an error "Authorization Denied", check policy Dashboard / Edit in Access Management.

      const result = await Resources.dashboards.widgets.edit("dashboard-id-123", "widget-id-456", {
      label: "Updated Temperature",
      });
      console.log(result); // Successfully Updated
    • Parameters

      Returns Promise<object>

      Updates existing data values for a specific widget.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const result = await resources.dashboards.widgets.editData("dashboard-id-123", "widget-id-456", {
      origin: "origin-id-123",
      id: "data-id-789",
      value: 25.5
      });
      console.log(result); // Device Data Updated
    • Parameters

      • dashboardID: string
      • widgetID: string
      • Optionalparams: GetDataModel

      Returns Promise<object>

      Retrieves data or resource list for a specific widget based on the given parameters.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const result = await resources.dashboards.widgets.getData("dashboard-id-123", "widget-id-456", {
      start_date: "2025-01-01",
      end_date: "2025-12-31",
      timezone: "UTC"
      });
      console.log(result); // { widget: { analysis_run: null, dashboard: '6791456f8b726c0009adccec', ... }, ...}
    • Parameters

      • dashboardID: string
      • widgetID: string

      Returns Promise<WidgetInfo>

      Retrieves detailed information about a specific widget.

      If receive an error "Authorization Denied", check policy Dashboard / Access in Access Management.

      const result = await Resources.dashboards.widgets.info("dashboard-id-123", "widget-id-456");
      console.log(result); // { id: "widget-id-456", data: [ { query: "last_value", ... }, ... ], ... }
    • Parameters

      Returns Promise<object>

      Sends new data values to be displayed in the widget.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const result = await resources.dashboards.widgets.sendData("dashboard-id-123", "widget-id-456", {
      origin: "origin-id-123",
      variable: "temperature",
      value: 25.5,
      unit: "C"
      });
      console.log(result); // [ '1 Data Added' ]
    • Parameters

      • dashboardID: string
      • widgetID: string

      Returns Promise<{ widget_token: string }>

      Generates a new authentication token for embedding a widget. Each call regenerates the token.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const result = await resources.dashboards.widgets.tokenGenerate("dashboard-id-123", "widget-id-456");
      console.log(result); // { widget_token: "widget-token-123" }