TX Sheet Control

Dashboard Class

Class

A stable dashboard handle. All snapshots are detached; handles expire after document replacement or deletion.

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

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

Members

Properties

PropertyDescription
idThe id value of Dashboard.
modeThe mode value of Dashboard.
nameThe name value of Dashboard.
snapshotDetached definition, including filters, layout, widgets and presentation settings.

Methods

MethodDescription
addWidgetAdds a widget, moving collisions to open space; duplicate IDs and invalid geometry reject atomically.
drillToReturns to an ancestor in the widget's zero-based hierarchy (0 is the root), clearing descendant filters. Throws for an unknown widget, unconfigured hierarchy, noninteger level or a deeper level without selection.
drillUpReturns one level up a widget's configured hierarchy; the root is unchanged. Worksheet data is untouched.
queryEvaluates one widget with shared filters; no editor or DOM is required.
removeWidgetRemoves a widget in one undoable edit.
renderRenders a widget without constructing the editor. Chart dimensions are CSS pixels, 120..4096.
resetFiltersRestores the saved default filter context.
selectMarkSelects a dimensional chart mark, applying configured cross-filtering and advancing its drill hierarchy. Both changes share one undo transaction. Throws for an absent widget/dimension or invalid scalar value.
setFiltersSets shared filter context, preserving source worksheet values and AutoFilter state.
sourceDataReturns underlying rows only when explicitly enabled on the widget; at most 1,000 rows.
updateReplaces validated presentation properties in one undoable transaction; identity is retained.
updateWidgetUpdates a widget without changing its identity. Moved/resized widgets reserve their requested cells; colliding widgets relocate to the next open space in the same undo transaction. Throws for removed widgets.

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

Advanced Dashboard Operations

MethodDescription
renderSvgRenders the current visible dashboard as portable SVG, including gradients, charts and KPI comparisons.
Width defaults to 1440 CSS pixels (480..4096); height follows the saved grid, at most 16,384 pixels.
Filters and expanded branches are honored; collapsed sections are omitted. Worksheet values are untouched.
applyThemeApplies one of 24 coordinated Light, Medium or Dark presets; existing explicit card overrides remain unchanged.
arrangeWidgetsAligns/distributes all widgets or packs a grid of 1..4 columns. Collision resolution remains atomic and undoable.
getExplorationReturns viewer navigation availability. History is limited to 50 successful actions and is not saved to TXWB.
goBackRestores the previous exploration context, including dashboard navigation; design edits invalidate history.
goForwardReapplies an exploration undone with goBack; a new action discards forward history.
setParameterChanges a named numeric what-if value without changing cells; bounds and choices are enforced atomically.
setMetricSwitches a widget to a configured metric query and number display, retaining its visual settings.
highlightMarkHighlights matching marks across charts on this source; repeating a selection or passing null clears it.
navigateToOpens the configured dashboard with an equality filter, preserving its other filters and recording Back navigation.
toggleBranchExpands/collapses one hierarchy branch while other branches remain summarized. Paths contain equality filters in hierarchy order.
kpiCalculates comparison, change, target and trend using the same source/filter context as the widget.
toggleSectionCollapses/expands a section in the viewer without modifying worksheet data or card definitions.