Dashboard 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
| Property | Description |
|---|---|
| id | The id value of Dashboard. |
| mode | The mode value of Dashboard. |
| name | The name value of Dashboard. |
| snapshot | Detached definition, including filters, layout, widgets and presentation settings. |
Methods
| Method | Description |
|---|---|
| addWidget | Adds a widget, moving collisions to open space; duplicate IDs and invalid geometry reject atomically. |
| drillTo | Returns 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. |
| drillUp | Returns one level up a widget's configured hierarchy; the root is unchanged. Worksheet data is untouched. |
| query | Evaluates one widget with shared filters; no editor or DOM is required. |
| removeWidget | Removes a widget in one undoable edit. |
| render | Renders a widget without constructing the editor. Chart dimensions are CSS pixels, 120..4096. |
| resetFilters | Restores the saved default filter context. |
| selectMark | Selects 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. |
| setFilters | Sets shared filter context, preserving source worksheet values and AutoFilter state. |
| sourceData | Returns underlying rows only when explicitly enabled on the widget; at most 1,000 rows. |
| update | Replaces validated presentation properties in one undoable transaction; identity is retained. |
| updateWidget | Updates 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
| Method | Description |
|---|---|
| renderSvg | Renders 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. | |
| applyTheme | Applies one of 24 coordinated Light, Medium or Dark presets; existing explicit card overrides remain unchanged. |
| arrangeWidgets | Aligns/distributes all widgets or packs a grid of 1..4 columns. Collision resolution remains atomic and undoable. |
| getExploration | Returns viewer navigation availability. History is limited to 50 successful actions and is not saved to TXWB. |
| goBack | Restores the previous exploration context, including dashboard navigation; design edits invalidate history. |
| goForward | Reapplies an exploration undone with goBack; a new action discards forward history. |
| setParameter | Changes a named numeric what-if value without changing cells; bounds and choices are enforced atomically. |
| setMetric | Switches a widget to a configured metric query and number display, retaining its visual settings. |
| highlightMark | Highlights matching marks across charts on this source; repeating a selection or passing null clears it. |
| navigateTo | Opens the configured dashboard with an equality filter, preserving its other filters and recording Back navigation. |
| toggleBranch | Expands/collapses one hierarchy branch while other branches remain summarized. Paths contain equality filters in hierarchy order. |
| kpi | Calculates comparison, change, target and trend using the same source/filter context as the widget. |
| toggleSection | Collapses/expands a section in the viewer without modifying worksheet data or card definitions. |