Skip to content
Sheetwrite

Analysis

Dashboards

Arrange pivots, slicers, PivotCharts and KPI cards on a dashboard sheet with a grid layout that is saved, undone and synchronized.

Edit on GitHubReport a problem

On this page

A dashboard is a sheet of the workbook with kind: "dashboard". It has a tab, a name, an order and a visibility like a worksheet, but it has no cells, rows or columns. It holds items on a grid of 12 columns.

A dashboard with KPI cards, a Region slicer, a chart and a pivot; the Revenue card's actions menu is open.A dashboard with KPI cards, a Region slicer, a chart and a pivot; the Revenue card's actions menu is open.
Each item has an actions menu, where Move and Resize start; both also work with the arrow keys.

Add a dashboard

Insert › Dashboard › New Dashboard adds a dashboard sheet named Dashboard1, Dashboard2, and so on, and shows it. Hosts can do the same with grid.actions.newDashboard(), or choose the name:

Partial example
grid.addSheet({ name: "Report", kind: "dashboard" });

On a dashboard, Insert › PivotTable asks for the table to analyze. It adds a pivot over that table and an item that shows it in the first free place, in one undo step, and opens the field list.

A dashboard snapshot has rowCount: 0, no columns and no cells. Cell, row, column, table and sheet-format operations that target a dashboard leave it unchanged. Its pivots read a table or the data model, not a range, because slicers filter tables.

Items

A pivot and a slicer
import { initSheetwrite, SheetwriteStore, type WorkbookSnapshot } from "@sheetwrite/core";
const snapshot: WorkbookSnapshot = {
workbook: { activeSheet: "data" },
sheets: [
{
id: "data",
name: "Data",
order: 0,
{ key: "a", header: "A", width: 80, type: "text" },
{ key: "b", header: "B", width: 80, type: "number" },
],
tables: [
{
id: "orders",
name: "Orders",
range: { sheet: "data", start: { row: 0, col: 0 }, end: { row: 2, col: 1 } },
{ id: "region", name: "Region" },
{ id: "amount", name: "Amount" },
],
headerRow: true,
totalsRow: false,
},
],
cells: [],
},
{
id: "dash",
name: "Dash",
order: 1,
kind: "dashboard",
columns: [],
pivots: [
{
id: "by-region",
name: "By region",
source: { table: "orders" },
anchor: { row: 0, col: 0 },
rows: [0],
columns: [],
values: [{ field: 1, aggregation: "SUM" }],
},
],
cells: [],
},
],
};
id: "sales",
box: { x: 0, y: 0, w: 8, h: 6 },
kind: "pivot",
pivot: "by-region",
});
id: "region",
box: { x: 8, y: 0, w: 4, h: 6 },
kind: "slicer",
field: { table: "orders", column: "region" },
selected: ["East"],
});
FieldMeaning
idA stable ID, unique on the dashboard.
boxColumn x (0–11) and row y, width w and height h (1–64) in grid units. x + w is at most 12.
kindWhat the item shows: "pivot", "slicer", "chart" or "kpi" (a KPI card). The other fields depend on it.
pivotPivot items: the ID of a pivot on the same sheet. If that pivot is removed, the item stays and shows #REF!; undo brings the pivot back.
fieldSlicers: the table and column IDs whose values the slicer lists.
selectedSlicers: the values that pass, at most 10,000; absent means every value passes.
itemsWithNoDataSlicers: "dim" (the default), "hide" or "show"; see Slicers.
chartChart items: the ID of a chart on the same sheet; its pivot names the data. See PivotCharts.
measureKPI cards: the ID of a measure of the workbook's data model.
numberFormatKPI cards: the Excel number format code of the value; absent shows it as General.
titleSlicers and KPI cards: the caption; absent shows the column or measure name.

Items do not overlap, and a dashboard holds at most 64 items. They are kept in reading order: by box.y, then by box.x.

The dashboard view

While a dashboard is the active sheet, the grid shows its items over the cells. The toolbar, the side panel and the sheet tabs stay as they are. The view loads as its own chunk the first time a dashboard is shown.

  • A pivot item shows the pivot's result as a table, with each value field's number format. Pivots on a dashboard compute without placing output in cells. With the default engine, the item says that it needs the full engine.
  • A slicer item lists the values of its column. A click keeps one value, and Ctrl or Cmd with a click adds or removes a value; a slicer always keeps at least one value. Clear keeps every value. Each change is saved with the item.
  • Drag an item's header to move it, and drag its bottom-right corner to resize it. With the keyboard, open the item's actions menu, choose Move or Resize, then use the arrow keys; Enter or Escape ends. Each drop or arrow step is one undo step. A place that another item holds is refused, and the view says so.
  • In a read-only grid, items cannot move, resize or change.

Slicers

Which items a slicer filtersA slicer on a column of a table filters every pivot whose table is that table or reaches it through many-to-one relationships; the filter goes from the one side to the many side, never back. Here a Region slicer on Regions filters the pivot over Orders, which reaches Regions, the PivotChart over that pivot, and a KPI card whose measure's home table is Orders. A pivot over Targets, which doesn't reach Regions, is not filtered.Slicer on Regions[Region]Orders → Regions is many to onePivotOver Orders, which reaches RegionsPivotChartFollows its pivotKPI cardMeasure on OrdersPivotOver Targets: not filtered
Which items a slicer filtersA slicer on a column of a table filters every pivot whose table is that table or reaches it through many-to-one relationships; the filter goes from the one side to the many side, never back. Here a Region slicer on Regions filters the pivot over Orders, which reaches Regions, the PivotChart over that pivot, and a KPI card whose measure's home table is Orders. A pivot over Targets, which doesn't reach Regions, is not filtered.Slicer on Regions[Region]Orders → Regions is many to onePivotOver Orders, which reaches RegionsPivotChartFollows its pivotKPI cardMeasure on OrdersPivotOver Targets: not filtered

A slicer filters from the one side to the many side, never back.

Insert › Filters › Slicer shows on a dashboard. It opens the Insert Slicers list, where each checked table column becomes a slicer in the next free place, in one undo step.

The slicers of a dashboard filter its pivots together. A slicer on a column of table T filters every pivot whose table is T, or a table that reaches T through many-to-one relationships, as an Excel slicer filters the PivotTables connected to it. The filter goes from the one side to the many side, never back. A slicer whose table a pivot cannot reach does not filter it. Slicer filters are added to each pivot's own report filters when the pivot computes; the saved definitions do not change.

In an editable grid, a slicer selection is a saved, synced change of its item, so it is one undo step. In a read-only grid, a slicer filters only that viewer's view: it makes no document change and no undo step.

A slicer dims each value that no row has under the other slicers, and the value stays selectable, as Excel's "Visually indicate items with no data" does. The slicer's actions menu has Dim Items with No Data, Hide Items with No Data and Show Items with No Data, each a saved change. In the API, set itemsWithNoData on the slicer item to "hide" to hide those values (Excel's "Hide items with no data"), or to "show" to show every value plainly.

The dashboard view applies the slicers, so they filter once a dashboard has been shown.

PivotCharts

Insert › Charts › PivotChart shows on a dashboard. It adds a chart of the chosen type over the focused pivot item, or else the first pivot, and an item that shows the chart in the next free place, in one undo step. Removing the item removes its chart too. On a worksheet, the command charts the pivot that holds the active cell; see Charts over pivots.

The chart is a ChartDefinition with pivot set to the ID of a pivot on the same dashboard, and an empty series list. As in Excel, the row items are the categories and each value field, for each column item, is one series. Subtotals and grand totals are not points. The slicers filter the chart as they filter its pivot, and the chart follows each recalculation. Charts need @sheetwrite/charts: without it, the item says so.

A chart plots every value field of its pivot unless pivotValues lists the ones to plot, by position in the pivot's values. In the Chart panel, the Values section lists the pivot's value fields with measures next to fields, as the Field List picks a PivotChart's values in Excel; each change is one undo step, and at least one value stays plotted. A measure point is the pivot's measure cell for the same items, computed in the filter context of that point, so the chart keeps no values of its own.

KPI cards

Insert › Dashboard › KPI Card shows on a dashboard when the data model has a measure. It opens a list of the measures and adds a card for the chosen one in the next free place.

A KPI card (kind: "kpi") shows its measure's value, large, in the filter context of the dashboard's slicers: each slicer whose table the measure's home table reaches filters it, as it filters a pivot over that table. title replaces the measure name as the caption, and numberFormat is the Excel format code of the value; absent shows it as General. A card needs the full engine, as measures do.

Styles

The dashboard view needs @sheetwrite/core/styles/dashboard.css, PivotCharts need @sheetwrite/core/styles/charts.css, and the KPI card and slicer forms need @sheetwrite/core/styles/panels.css. @sheetwrite/core/styles.css includes every part; see Stylesheet parts.

XLSX

Excel has no dashboard sheet. toXlsxWorkbook(grid), from @sheetwrite/core with the XLSX add-on installed (initSheetwrite({ addons: [xlsxAddon()] }), xlsxAddon from @sheetwrite/xlsx), writes each dashboard as a worksheet with the same name. Each worksheet column stands for one grid column, and each row for one grid row. Each item writes its values from the top-left cell of its box:

  • a pivot item: its name, then the pivot's current result, with each value field's number format,
  • a slicer: its caption, then the values it keeps,
  • a KPI card: its caption, then its value in its number format,
  • a chart item: a native chart over the box, with its data written into the chart, so Excel shows it without source cells.

The values are the ones that the dashboard shows, with its slicer filters. If an item has more values than its box holds, the export writes all of them and warns. Each export with a dashboard warns once that the dashboard is static in Excel. A snapshot exported without a grid has no computed values, so its dashboards are empty worksheets.

The dashboard itself, with its items, pivots and charts, is saved in the Sheetwrite metadata sheet. Sheetwrite opens the file with the dashboard again; the static values are not read. Excel slicers and timelines in other files are not imported.

Undo and collaboration

setDashboardItem (insert or replace by ID) and removeDashboardItem are document operations. Each change is one undo step, and it is saved and synchronized like other sheet metadata. A slicer selection is a change of its item, so it is saved too, as Excel saves slicer state. Two concurrent changes to the same item conflict, and so do two concurrent items whose boxes overlap. A version-history restore brings the items and pivots of a dashboard back in place.

Store methodResult
getDashboard(sheet)A copy of the items, or null for a worksheet
setDashboardItem(sheet, item)Inserts it, or replaces the item with its ID
removeDashboardItem(sheet, id)Removes it