@univerjs-pro/sheets-pivot-chart
v1.5.2
Published
Pivot chart integration for Univer Sheets.
Readme
@univerjs-pro/sheets-pivot-chart
@univerjs-pro/sheets-pivot-chart is part of Univer Pro. It provides the Sheet-hosted data and runtime integration for Univer PivotChart.
Package Overview
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
| --- | --- | :---: | :---: | :---: | :---: |
| @univerjs-pro/sheets-pivot-chart | UniverProSheetsPivotChart | No | No | Yes | Yes |
Installation
pnpm add @univerjs-pro/sheets-pivot-chart
# or
npm install @univerjs-pro/sheets-pivot-chartUsage
Start with the integration setup for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
import { UniverSheetsPivotChartPlugin } from '@univerjs-pro/sheets-pivot-chart';
univer.registerPlugin(UniverSheetsPivotChartPlugin);The package currently exposes the PivotChart model, commands, mutations, Worker calculation, and ChartModel binding. UI integration is provided separately.
Worker usage
On the main thread, import UniverSheetsPivotChartPlugin from @univerjs-pro/sheets-pivot-chart. Set notExecuteFormula: true on both PivotTable and PivotChart to delegate calculation to the worker:
import { UniverSheetsPivotTablePlugin } from '@univerjs-pro/sheets-pivot';
import { UniverSheetsPivotChartPlugin } from '@univerjs-pro/sheets-pivot-chart';
univer.registerPlugin(UniverSheetsPivotTablePlugin, { notExecuteFormula: true });
univer.registerPlugin(UniverSheetsPivotChartPlugin, { notExecuteFormula: true });In the worker entry, import UniverSheetsPivotChartWorkerPlugin from @univerjs-pro/sheets-pivot-chart/worker:
import { UniverSheetsPivotTablePlugin } from '@univerjs-pro/sheets-pivot/worker';
import { UniverSheetsPivotChartWorkerPlugin } from '@univerjs-pro/sheets-pivot-chart/worker';
univer.registerPlugin(UniverSheetsPivotTablePlugin, { notExecuteFormula: false });
univer.registerPlugin(UniverSheetsPivotChartWorkerPlugin);The advanced Sheets presets configure this split when worker calculation is enabled. ChartModel and Drawing bindings belong to the main thread. Owned field edits and filter-data requests use the calculation message bridge; undoable mutations remain coordinated by the main process. Linked field edits continue to use the referenced PivotTable commands.
Integration Notes
InsertPivotChartCommand accepts exactly one Pivot data source:
sourceRangeInfocreates an independent PivotChart with a chart-owned PivotModel.pivotTableReflinks the chart to an existing PivotTable. The chart stores only the reference and its visual configuration; the PivotTable remains the sole owner of the PivotModel and Pivot Cache report.
await commandService.executeCommand(InsertPivotChartCommand.id, {
unitId,
subUnitId,
pivotTableRef: {
unitId,
subUnitId: pivotTableSheetId,
pivotTableId,
},
});Field changes made through a linked PivotChart are delegated to the referenced PivotTable commands. Removing the chart does not remove the PivotTable. If the PivotTable is removed, the chart becomes unavailable and reconnects when the same PivotTable is restored.
- Import
@univerjs-pro/sheets-pivot-chart/facadewhen using this package through Univer Facade APIs.
