FBasePivotView
Facade API object bound to one Base Pivot View.
Access
Access through:
Setup
Register @univerjs-pro/bases-dashboard or a preset that includes it. In plugin mode, import @univerjs-pro/bases-dashboard/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/bases-dashboard
FBasePivotView.calculate
Calculates the Pivot View, optionally applying Dashboard or caller-owned table filters.
calculate(filters?: Array<IFilterConfig | null>): Promise<IBasePivotCalculationResult>Parameters
filters— Optional. Default:[]. Additional Base table filters applied before Pivot calculation.
Returns
Engine Pivot layout result suitable for rendering or Chart adaptation.
Examples
const result = await pivotView.calculate()console.log(result.view.dataView)Types: IBasePivotCalculationResult · Promise · Array · IFilterConfig
Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.delete
Deletes this Pivot View through the command system.
delete(): booleanReturns
Whether the command succeeded.
Examples
pivotView.delete()Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getConfig
Returns a detached Pivot and Chart configuration snapshot.
getConfig(): IBasePivotViewConfigReturns
Current Pivot View configuration.
Examples
const config = pivotView.getConfig()Types: IBasePivotViewConfig
Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getId
Returns the stable Pivot View id.
getId(): stringReturns
Stable Pivot View id.
Examples
const viewId = pivotView.getId()Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getName
Returns the human-readable Pivot View name.
getName(): stringReturns
Pivot View name.
Examples
const name = pivotView.getName()Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getPermission
Returns the Pivot View object permission facade.
canEdit() combines the Base unit, parent Table, and Pivot View Edit points. Enabling the
Pivot View does not override a read-only Base or Table.
getPermission(): FBaseObjectPermissionReturns
Permission facade for this Pivot View.
Examples
Make one Pivot View read-only and restore it
const base = univerAPI.getActiveBase()const table = base?.getTables()[0]const pivot = table ? base?.getPivotViews(table.getId())[0] : undefinedif (!pivot) throw new Error('Pivot View not found.')await pivot.getPermission().setReadOnly()console.log(pivot.getPermission().canEdit()) // falseawait pivot.getPermission().setEditable()Types: FBaseObjectPermission
Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getPivotTable
Creates a detached engine-pivot model initialized from this Pivot View.
Mutating the returned model does not change the Base. After using Engine methods such as
addFieldWithSourceId(), persist the result with updateConfig({ pivot: pivotTable.toJSON() }).
getPivotTable(): PivotTableReturns
Detached Engine Pivot model backed by the current table fields.
Examples
import { PivotTableFiledAreaEnum } from '@univerjs-pro/engine-pivot'const pivotTable = pivotView.getPivotTable()pivotTable.addFieldWithSourceId('region', PivotTableFiledAreaEnum.Row)pivotTable.addFieldWithSourceId('revenue', PivotTableFiledAreaEnum.Value)pivotView.updateConfig({ pivot: pivotTable.toJSON() })Types: PivotTable
Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getSnapshot
Returns a detached Pivot View snapshot.
getSnapshot(): IBasePivotViewSnapshotReturns
Snapshot safe for local inspection or editing.
Throws
If the Pivot View has been deleted or changed to another view type.
Examples
const snapshot = pivotView.getSnapshot()Types: IBasePivotViewSnapshot
Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.getTableId
Returns the stable source table id.
getTableId(): stringReturns
Stable source table id.
Examples
const tableId = pivotView.getTableId()Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.setName
Renames the Pivot View through the command system.
setName(name: string): booleanParameters
name— Required. New human-readable Pivot View name.
Returns
Whether the command succeeded.
Examples
pivotView.setName('Revenue by market')Package: @univerjs-pro/bases-dashboard · Type definitions
FBasePivotView.updateConfig
Partially updates the Pivot View through the command system, including undo and redo support.
Top-level properties are replaced. Merge nested chart properties with the current Chart config
before passing them when only one Chart property should change.
updateConfig(patch: Partial<IBasePivotViewConfig>): booleanParameters
patch— Required. Top-level Pivot View configuration patch.
Returns
Whether the command succeeded.
Examples
import { ChartTypeBits } from '@univerjs-pro/engine-chart'const current = pivotView.getConfig()pivotView.updateConfig({ chart: { ...current.chart, type: ChartTypeBits.Line }, displayMode: 'chart',})Types: Partial · IBasePivotViewConfig
Package: @univerjs-pro/bases-dashboard · Type definitions
你觉得这篇文档如何?