You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Sales Dashboard with Sparkline & Cross-Sheet Formulas
4
4
5
-
This demo showcases data visualization and chart functionality in GridSheet.
5
+
This demo showcases a two-sheet sales dashboard built with GridSheet.
6
6
7
-
It demonstrates a sales dashboard with formula-based calculations, custom chart rendering, and statistical analysis.
8
-
9
-
The grid includes custom chart renderers, dynamic calculations, and trend analysis using formulas.
7
+
The first sheet holds monthly metrics with sparkline charts rendered via a custom policy. The second sheet pulls KPIs from the first using cross-sheet formulas and uses `ARRAYFORMULA` with `IF` to spill status and gap values across multiple rows.
### Receiving a Range Reference with `renderSheet`
15
+
### Rendering Sparklines with `renderSheet`
18
16
19
-
The `renderSheet` method on `PolicyMixinType` is called when a cell's resolved value is a `Sheet` object — that is, when a formula that returns a range (e.g. `=C1:F1`) has been evaluated.
17
+
The `renderSheet` method on `PolicyMixinType` is called when a cell's resolved value is a `Sheet` object — that is, when a formula that returns a range (e.g. `=C1:H1`) has been evaluated.
20
18
21
19
By setting a range formula on a cell and implementing `renderSheet` on that cell's policy, you can visualize multiple columns of data within a single cell.
The resolved result of `=C1:F1` is passed to `renderSheet` as a `Sheet`, letting you build a Chart.js data source directly from it.
51
+
The resolved result of `=C1:H1` is passed to `renderSheet` as a `Sheet`, letting you build a Chart.js data source directly from it.
55
52
56
53
### Sharing the Same `book` Across Multiple `GridSheet` Instances
57
54
58
55
The `book` returned by `useSpellbook` can be passed to multiple `GridSheet` components. Sharing the same `book` enables cross-sheet formula references between them.
When `sheetName` changes, these references update automatically. Try editing the sheet name inputs in the demo to see this in action.
79
76
80
-
### Write Protection with `prevention`
77
+
### Spilling with ARRAYFORMULA + IF
81
78
82
-
Setting `operations.Write` on `prevention` prevents users from editing that cell, column, or row.
79
+
The dashboard sheet uses `ARRAYFORMULA` to compute values that spill across multiple rows from a single formula cell.
83
80
84
-
```tsx
85
-
cells: {
86
-
H: { prevention: operations.Write },
87
-
}
81
+
```
82
+
=ARRAYFORMULA(IF(B1:B5>=C1:C5,"✓ On Track","✗ Behind"))
83
+
=ARRAYFORMULA(B1:B5-C1:C5)
88
84
```
89
85
90
-
In this example, the Trend column (H) is formula-driven, so writes are blocked to keep the calculations intact.
86
+
The first formula compares each KPI value against its target and spills a status label into D1:D5. The second computes the gap between value and target, spilling into E1:E5. Only the origin cell (D1, E1) holds the formula — the remaining cells are filled automatically.
91
87
92
88
### Bulk Data Entry with `matrices` in `buildInitialCells`
93
89
@@ -97,24 +93,16 @@ Use the `matrices` key to set data in matrix form. The key is the address of the
`defaultCol` / `defaultRow` set the default width and height for all columns and rows. A range key like `'C:F'` applies styles to multiple columns at once.
This formula evaluates the quarter-over-quarter change as a percentage and displays an emoji for the trend. Excel-style conditional logic like this works natively in GridSheet's formula engine.
108
+
`defaultCol` / `defaultRow` set the default width and height for all columns and rows. A range key like `'C:H'` applies styles to multiple columns at once.
0 commit comments