TX Sheet Control

DashboardCollection Class

Class

Workbook dashboard views; collection edits share the workbook history and .txwb persistence.

Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.

ES module import: import { DashboardCollection } from '@txtextcontrol/tx-sheet-control';.

Members

Properties

PropertyDescription
countThe count value of DashboardCollection.

Methods

MethodDescription
addCreates an empty dashboard. Creation never changes viewport selection implicitly.
atZero-based index in the dashboard group.
duplicateCopies widgets, filters and layout to a distinct dashboard identity.
generateGenerates at most 12 widgets with deterministic field-role rules. Existing customizations require explicit merge/replace.
getByIdResolves a stable identity; throws when the dashboard does not exist.
listOrdered detached definitions, safe to inspect or use as inputs for explicit edits.
moveReorders only the dashboard group; index is zero-based.
removeRemoves a dashboard. Deleting the active view restores the selected worksheet.
setModeChanges the integrated authoring mode; viewing retains filters and chart interactions.

Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

import type { Workbook } from '@txtextcontrol/tx-sheet-control';

function createDashboardCollectionReport(book: Workbook) {
    const sheet = book.sheets.at(0);
    sheet.range('A1:B5').setValues([
        ['Region', 'Revenue'],
        ['North', 42000],
        ['South', 38500],
        ['East', 31200],
        ['West', 44900],
    ]);

    book.analytics.setSource({
        id: 'sales',
        name: 'Regional sales',
        sheetId: sheet.id,
        range: 'A1:B5',
        hasHeaderRow: true,
    });

    const dashboard = book.dashboards.add('Sales overview');
    dashboard.addWidget({
        id: 'revenue',
        type: 'bar',
        title: 'Revenue by region',
        placement: { x: 0, y: 0, width: 6, height: 4 },
        query: {
            sourceId: 'sales',
            dimensions: ['Region'],
            measures: [{ field: 'Revenue', aggregation: 'SUM', alias: 'Revenue' }],
        },
        drillDown: ['Region'],
        interactions: { filter: true, allowSourceData: true },
    });

    return dashboard.snapshot;
}

See Also