ProGridSign in

Features

Pivot and charts

Use the same column metadata to power grouped aggregates, multi-dimensional pivots, and chart measures without maintaining a second schema.

Describe the measure once

The chart reads meta.type directly: a number column is offered as a measure and everything else as a category, with dates bucketed by calendar period. Marking a column groupable, pivotable or aggregable promotes it — those columns are listed first — but is no longer what makes it chartable. Set chartable: false to keep an ID or reference code out of the pickers.

Formatting is reused in cells, totals, pivot output, and chart values. A chart tooltip shows formatValue verbatim; axis ticks adopt it only when the result still fits a tick, and otherwise fall back to compact notation — an axis is a scale, not a readout.

// A number column is a chart measure because it said it was a number.
{
  accessorKey: "revenue",
  header: "Revenue",
  meta: {
    type: "number",
    defaultAgg: "sum",
    aggregable: true, // adds the grid's own subtotal/total for the column
    formatValue: (value) => currency.format(Number(value)),
  },
}

// A dimension. Groupable promotes it to the top of the chart's category list.
{
  accessorKey: "region",
  header: "Region",
  meta: { type: "string", groupable: true, pivotable: true },
}

// Typed so it filters, but meaningless to plot.
{ accessorKey: "id", header: "Order", meta: { type: "string", chartable: false } }
Live demo

Grouped analytics

Expand a region, change grouping, press Pivot to open the field panel, or open the chart workbench from the toolbar.

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 }}
    />
  )
}

Revenue by region

Row GroupsRegion
Region
Status
Units
Revenue
Total
Sum16068
Sum$3,354,164
72 rows

Pivot model

A pivot is a cross-tab: any number of row dimensions, any number of column dimensions, one or more measures, and report filters that narrow the rows before anything is aggregated. Pressing Pivot opens a field panel on the right — drag a field into Rows, Columns, Values or Filters, or tick its checkbox to send it to the box its type implies.

Aggregations are sum, average, count, distinct count, minimum, maximum, median, standard deviation, product, first and last. Each measure can also be shown as a share rather than a quantity — of the grand total, of its row, of its column, of its parent — or as a running total, a rank, or a difference from the previous member. A calculated field is a measure written as a formula over the others, such as [Sum of Revenue] / [Sum of Units].

Every level carries a subtotal, above or below its members, and the pivot ends in a grand total row and column. Rows and columns both expand and collapse, and sorting a measure column orders each level’s members within their parent rather than flattening the hierarchy.

Right-click a value cell for Show details to see the rows behind it, rendered with the grid’s own columns. The gear menu copies the pivot as it stands, or exports it to CSV with one header row per column level.

Chart workbench

The chart dialog supports bar, line, area, and pie views; filtered or selected scope; split series; date buckets; stacking; Top N plus “Other”; and a per-measure aggregation. Bars lie down on their own once there are more categories than upright ticks can hold; the direction button pins whichever way you prefer.