DashboardCollection 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
| Property | Description |
|---|---|
| count | The count value of DashboardCollection. |
Methods
| Method | Description |
|---|---|
| add | Creates an empty dashboard. Creation never changes viewport selection implicitly. |
| at | Zero-based index in the dashboard group. |
| duplicate | Copies widgets, filters and layout to a distinct dashboard identity. |
| generate | Generates at most 12 widgets with deterministic field-role rules. Existing customizations require explicit merge/replace. |
| getById | Resolves a stable identity; throws when the dashboard does not exist. |
| list | Ordered detached definitions, safe to inspect or use as inputs for explicit edits. |
| move | Reorders only the dashboard group; index is zero-based. |
| remove | Removes a dashboard. Deleting the active view restores the selected worksheet. |
| setMode | Changes 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.
function createDashboardCollectionReport(book) {
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;
}