Examples
Pivot and charts
Turn the same rows into a pivot table with row and column dimensions, calculated measures and subtotals, then chart any slice — using the column definitions you already declared.
Live demo
Pivot and charts
Switch on pivot mode · Drag a dimension onto the column axis · Open the chart dialog · Drill through a value cell
import { ProGrid, type ProColumnDef } from "@/components/pro-grid"
import { formatCurrency, operationOrders, type OperationOrder } from "@/lib/operations-data"
function StatusCell({ value }: { value: unknown }) {
const status = String(value)
return <span className={`order-status order-status--${status.toLowerCase().replaceAll(" ", "-")}`}>{status}</span>
}
const baseColumns: ProColumnDef<OperationOrder>[] = [
{ accessorKey: "id", header: "Order", size: 118, meta: { label: "Order", type: "string" } },
{ accessorKey: "customer", header: "Customer", size: 190, meta: { label: "Customer", type: "string" } },
{
accessorKey: "region",
header: "Region",
size: 145,
meta: {
label: "Region",
type: "string", filterVariant: "set",
filterOptions: ["North America", "Europe", "Asia Pacific", "Latin America"],
groupable: true,
pivotable: true,
},
},
{
accessorKey: "status",
header: "Status",
size: 120,
cell: ({ getValue }) => <StatusCell value={getValue()} />,
meta: {
label: "Status",
type: "string", filterVariant: "set",
filterOptions: ["On track", "At risk", "Delayed", "Complete"],
groupable: true,
pivotable: true,
},
},
{
accessorKey: "units",
header: "Units",
size: 88,
meta: { label: "Units", type: "number", align: "right", aggregable: true, defaultAgg: "sum" },
},
{
accessorKey: "revenue",
header: "Revenue",
size: 128,
meta: {
label: "Revenue",
type: "number",
align: "right",
aggregable: true,
defaultAgg: "sum",
formatValue: (value) => formatCurrency(Number(value)),
},
},
]
const analyticsDemoRows = operationOrders.slice(0, 72)
export function AnalyticsDocsDemo() {
return (
<ProGrid<OperationOrder>
columns={baseColumns}
data={analyticsDemoRows}
getRowId={(row) => row.id}
height={400}
initialGrouping={["region"]}
// Seeded but off: the page reads as a grouped grid until the reader presses
// Pivot, and then shows a configured cross-tab rather than three empty boxes.
initialPivot={{
enabled: false,
config: {
rows: [{ colId: "region" }],
columns: [{ colId: "status" }],
values: [
{ colId: "revenue", agg: "sum" },
{ colId: "units", agg: "avg" },
],
filters: [],
},
rows: { depth: 1, collapsed: [], expanded: [] },
columns: { depth: 64, collapsed: [], expanded: [] },
}}
initialState={{ columnVisibility: { id: false, customer: false } }}
title="Revenue by region"
toolbar={{ quickFilter: false, refresh: false }}
/>
)
}// 72 flat orders. Group aggregates, pivot cells, and chart series are
// all derived from these rows using each column's `defaultAgg`.
/** `Cancelled` is never generated below; the billing demo marks its own. */
type OrderStatus = "On track" | "At risk" | "Delayed" | "Complete" | "Cancelled"
interface OperationOrder extends Record<string, unknown> {
id: string
customer: string
channel: "Direct" | "Marketplace" | "Partner"
region: "North America" | "Europe" | "Asia Pacific" | "Latin America"
owner: string
status: OrderStatus
priority: "Critical" | "High" | "Normal"
units: number
revenue: number
margin: number
slaHours: number
updatedAt: string
}
const rows: OperationOrder[] = [
{
"id": "ORD-10482",
"customer": "Keystone Foods",
"channel": "Direct",
"region": "North America",
"owner": "Theo Martins",
"status": "Complete",
"priority": "Normal",
"units": 18,
"revenue": 1850,
"margin": 12,
"slaHours": 2,
"updatedAt": "2026-08-01T08:00:00.000Z"
},
{
"id": "ORD-10483",
"customer": "Atlas Manufacturing",
"channel": "Partner",
"region": "North America",
"owner": "Jon Bell",
"status": "Delayed",
"priority": "Critical",
"units": 55,
"revenue": 9769,
"margin": 25,
"slaHours": 7,
"updatedAt": "2026-08-02T09:00:00.000Z"
},
// …70 more rows
]Revenue by region
Row GroupsRegion
Region
Status
Units
Revenue
Total
Sum16068
Sum$3,354,164
72 rows
Things to try
- Switch on pivot mode
- Drag a dimension onto the column axis
- Open the chart dialog
- Drill through a value cell
The Code tab above is the component rendering this page; the Data tab is what reaches the grid. The props behind it are explained in Pivot and charts.