Svelte Pivot Table

A pivot table turns a flat list of facts into a crosstab: pick the fields that become rows, the fields that become columns, and the measures to aggregate in the cells. SvGrid does that with createPivotModel over your existing array, and renders the result through the same grid you already use.

If you want your users to build the pivot rather than you, SvPivotDesigner gives them a searchable field list and four drop wells for Filters, Rows, Columns and Values, with per-field aggregators. Its layout is a single bindable prop, so saving and restoring a view is one line.

Install

npm i @svgrid/grid @svgrid/enterprise

The grid and its data model are MIT-licensed in @svgrid/grid; this view ships in the commercial @svgrid/enterprise package and runs unlicensed while you evaluate.

The code

import { createPivotModel } from '@svgrid/enterprise'

const pivot = createPivotModel(orders, {
  rows:   ['region', 'salesPerson'],
  cols:   ['quarter'],
  values: [
    { field: 'amount', agg: 'sum', label: 'Total', format: { type: 'currency', currency: 'USD' } },
    { field: 'amount', agg: 'avg', label: 'Avg' },
  ],
})

What you get

Live examples

Documentation

Related articles

Frequently asked questions

How do I make a pivot table in Svelte?

Call createPivotModel from @svgrid/enterprise with your rows, your row and column dimensions and your value aggregations, then render the result through <SvGrid>. For a user-built pivot, drop in SvPivotDesigner instead.

Is the pivot table free?

No. Pivot is part of the commercial @svgrid/enterprise package, alongside export, import, print and the board and scheduler views. It runs unlicensed with a watermark while you evaluate it.

Can users build their own pivot?

Yes. SvPivotDesigner ships a searchable field picker and Filters, Columns, Rows and Values wells with drag-and-drop between them. Its layout is a bindable prop you can persist per user.

How large a dataset can it pivot?

The pivot aggregates in memory, so it is bound by how much data you can hold client-side. For very large sources, aggregate on the server and pivot the summary rows.

Build something else

Get started · Browse the gallery · Pricing