TX Sheet Control

DashboardAnalytics Class

Class

Workbook-wide analytics; caches are private, column-oriented and invalidated by affected cells and formula changes.

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

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

Members

Methods

MethodDescription
dataReturns at most 1,000 source rows after filters; application must authorize source-data access per widget.
profileProfiles up to 250,000 cells per source. Call after before-events complete; returns detached metadata and diagnostics.
queryExecutes without UI, yielding every 2,048 rows. Rejects cancellation, stale snapshots and ambiguous joins.
refreshRefreshes source columns/aggregates and requests live data through dataRefreshRequested. Does not await providers.
relationshipsLists only explicitly established many-to-one relationships. No automatic join is applied.
removeRelationshipRemoves a join definition without rewriting user queries. Those queries report a missing relationship.
removeSourceRemoves an explicit binding; dependent widgets display a missing-source diagnostic.
setDataReplaces a connector source's transient snapshot atomically after validation. Rows are detached, bounded to 250,000 cells and cleared on document replacement. Existing queries, joins and widgets use the same field IDs as worksheet sources.
setRelationshipValidates target uniqueness before saving an explicit relationship. Blanks never match blank keys.
setSourceRegisters a range/table or logical connector binding. IDs are unique; replacement invalidates its cache.
sourcesDiscovers Excel tables and rectangular named ranges across all worksheets, plus explicit API bindings.
suggestRelationshipsSuggests same-name key joins only with unique target keys and at least 90% observed source coverage.

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 createDashboardAnalyticsReport(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