Preview Updated 2026-05-10

Pivot

2D aggregation table — sum / avg / count / min / max aggregators, built-in row/col totals, optional heatmap shading, cell drill-down.

Basic usage

Group a flat array of objects by rowField (rows) and colField (columns), aggregating valueField. Row totals, column totals, and grand total are computed automatically.

region/channel官网门店App合计
华北¥12,400¥8,200¥4,900¥25,500
华东¥22,800¥14,200¥9,800¥46,800
华南¥18,200¥6,800¥5,400¥30,400
西部¥7,400¥3,200¥2,100¥12,700
合计¥60,800¥32,400¥22,200¥115,400

Heatmap mode

With heatmap, each cell is shaded with a translucent accent color proportional to its value (larger = deeper). Combined with different aggregator settings it gives an at-a-glance distribution view.

aggregator

周 × 小时 出行热力(模拟数据)

weekday/hour000408121620
周一8110329231631451
周二515227232632397
周三898431127527158
周四6663293289293104
周五1087328530031062
周六162171127334145297
周日140121121292159319

Drill-down

onCellClick receives { row, col, value, rows }rows is every source record that fell into this cell, ideal for triggering a drawer or modal with the underlying detail.

product/store上海北京深圳合计
A6,0001,9007,900
B5,4006,1004,20015,700
C1,2002,4003,3006,900
合计12,60010,4007,50030,500

API

PropTypeDefaultDescription
dataT[]Flat data array
rowFieldkeyof TRow grouping field
colFieldkeyof TColumn grouping field
valueFieldkeyof TNumeric field (omittable with aggregator='count')
aggregator'sum' | 'avg' | 'count' | 'min' | 'max''sum'Aggregation method
format(value, { row, col }) => stringCustom cell formatter
showTotalsbooleantrueRender row + column totals
heatmapbooleanfalseShade cells by value
heatmapColorstringvar(--accent-1)Heatmap base color
captionstringCaption above the table
size'sm' | 'md' | 'lg''md'Font size scale
onCellClick(cell) => voidCell click callback (receives source rows)

Utility

import { pivotCompute, pivotAggregate } from '@chufix-design/vue';

const result = pivotCompute(data, 'region', 'channel', 'amount', 'sum');
// → { rowKeys, colKeys, cells, raw, rowTotals, colTotals, grandTotal, min, max }

pivotCompute is the same pure function the component uses internally — re-use it for CSV export, charting, or custom drill-down flows.

反馈与讨论

Pivot · Discussion

0
0 / 600
一键发送
正在加载评论...