# DashboardAnalytics Class

> DashboardAnalytics class in the TX Sheet Control JavaScript API for the browser: Workbook-wide analytics. Covers 12 methods and a JavaScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > JavaScript API > Browser Editor > DashboardAnalytics Class
- **1347 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/llms-full.txt

---

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

| Method | Description |
|---|---|
| [data](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/data-method/llms-full.txt) | Returns at most 1,000 source rows after filters; application must authorize source-data access per widget. |
| [profile](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/profile-method/llms-full.txt) | Profiles up to 250,000 cells per source. Call after before-events complete; returns detached metadata and diagnostics. |
| [query](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/query-method/llms-full.txt) | Executes without UI, yielding every 2,048 rows. Rejects cancellation, stale snapshots and ambiguous joins. |
| [refresh](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/refresh-method/llms-full.txt) | Refreshes source columns/aggregates and requests live data through dataRefreshRequested. Does not await providers. |
| [relationships](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/relationships-method/llms-full.txt) | Lists only explicitly established many-to-one relationships. No automatic join is applied. |
| [removeRelationship](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/removerelationship-method/llms-full.txt) | Removes a join definition without rewriting user queries. Those queries report a missing relationship. |
| [removeSource](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/removesource-method/llms-full.txt) | Removes an explicit binding; dependent widgets display a missing-source diagnostic. |
| [setData](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setdata-method/llms-full.txt) | Replaces 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. |
| [setRelationship](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setrelationship-method/llms-full.txt) | Validates target uniqueness before saving an explicit relationship. Blanks never match blank keys. |
| [setSource](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setsource-method/llms-full.txt) | Registers a range/table or logical connector binding. IDs are unique; replacement invalidates its cache. |
| [sources](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/sources-method/llms-full.txt) | Discovers Excel tables and rectangular named ranges across all worksheets, plus explicit API bindings. |
| [suggestRelationships](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/suggestrelationships-method/llms-full.txt) | Suggests 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.

```javascript
function createDashboardAnalyticsReport(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;
}
```

### See Also

- [JavaScript Browser Editor API](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/llms-full.txt)
- [Creating Dashboards](https://docs.textcontrol.com/tx-sheet-control/dashboards/creating/llms-full.txt)

---

## In This Section

- [DashboardAnalytics.data Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/data-method/llms-full.txt): DashboardAnalytics.data method in the TX Sheet Control JavaScript API for the browser: Returns at most 1,000 source rows after filters.
- [DashboardAnalytics.profile Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/profile-method/llms-full.txt): DashboardAnalytics.profile method in the TX Sheet Control JavaScript API for the browser: Profiles up to 250,000 cells per source.
- [DashboardAnalytics.query Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/query-method/llms-full.txt): DashboardAnalytics.query method in the TX Sheet Control JavaScript API for the browser: Executes without UI, yielding every 2,048 rows.
- [DashboardAnalytics.refresh Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/refresh-method/llms-full.txt): DashboardAnalytics.refresh method in the browser JavaScript API: Refreshes source columns/aggregates and requests live data through dataRefreshRequested.
- [DashboardAnalytics.relationships Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/relationships-method/llms-full.txt): DashboardAnalytics.relationships method in the TX Sheet Control JavaScript API for the browser: Lists only explicitly established many-to-one relationships.
- [DashboardAnalytics.removeRelationship Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/removerelationship-method/llms-full.txt): DashboardAnalytics.removeRelationship method in the TX Sheet Control JavaScript API for the browser: Removes a join definition without rewriting user queries.
- [DashboardAnalytics.removeSource Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/removesource-method/llms-full.txt): DashboardAnalytics.removeSource method in the TX Sheet Control JavaScript API for the browser: Removes an explicit binding.
- [DashboardAnalytics.setData Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setdata-method/llms-full.txt): DashboardAnalytics.setData method in the browser JavaScript API: Replaces a connector source's transient snapshot atomically after validation.
- [DashboardAnalytics.setRelationship Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setrelationship-method/llms-full.txt): DashboardAnalytics.setRelationship method in the browser JavaScript API: Validates target uniqueness before saving an explicit relationship.
- [DashboardAnalytics.setSource Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/setsource-method/llms-full.txt): DashboardAnalytics.setSource method in the TX Sheet Control JavaScript API for the browser: Registers a range/table or logical connector binding.
- [DashboardAnalytics.sources Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/sources-method/llms-full.txt): DashboardAnalytics.sources method in the TX Sheet Control JavaScript API for the browser, with the return type AnalyticsSource[] and a JavaScript example.
- [DashboardAnalytics.suggestRelationships Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/suggestrelationships-method/llms-full.txt): DashboardAnalytics.suggestRelationships method in the browser JavaScript API, with the return type AnalyticsRelationshipSuggestion[] and a JavaScript example.

---

## Nearby

- **Previous:** [Dashboard.toggleSection Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboard/togglesection-method/llms-full.txt)
- **Next:** [DashboardAnalytics.data Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/dashboardanalytics/data-method/llms-full.txt)
