API 參考

@univerjs-pro/chart-embed

此 API 頁面目前提供英文內容。程式碼簽名與識別符不隨介面語言變更。

Loads referenced data for charts in Docs, Slides, and Boards. It provides resource-reference descriptors, shared loading and subscriptions, and bindings between referenced data and chart models.

Registration

Shell
pnpm add @univerjs-pro/chart-embed

Register the plugin once during application initialization, before opening documents that use referenced chart sources. If you configure UniverEmbedPlugin explicitly, register it first so its configuration is applied before the dependency is created.

TypeScript
import { UniverChartEmbedPlugin } from '@univerjs-pro/chart-embed'univer.registerPlugin(UniverChartEmbedPlugin)

The plugin depends on UniverChartPlugin and UniverEmbedPlugin. Continue registering the chart model and UI plugins for your host. Inline chart data and native Sheets range sources do not require this plugin. Referenced charts report ChartDataSourceRuntimeStatus.UNAVAILABLE when the reference runtime is absent.

This package has no Facade, locale, stylesheet, or package-level configuration. It uses the same registration on desktop and mobile. See cross-document embedding for reference resolution and collaborative document loading.

Reference input

Import reference APIs from @univerjs-pro/chart-embed:

TypeScript
import type { IResourceRefChartDataSourceInput } from '@univerjs-pro/chart-embed'const source: IResourceRefChartDataSourceInput = {  unit: { selector: 'sales-workbook', type: 'sheet' },  part: { kind: 'range', sheetName: 'Data', range: 'A1:B20', ref: 'Data!A1:B20' },}

Pass source to a Docs, Slides, or Boards chart builder's setSource() method. The selector must resolve to the source workbook; omitting file selects the current file. ResourceRefChartDataSourceAdapter.toReference(source) creates the stored descriptor when constructing a host data-source input directly.

Public exports

  • UniverChartEmbedPlugin
  • ChartDataSourceRuntimeService, IChartDataSourceRuntimeService, IChartDataSourceHandle, and IChartDataSourceRuntimeState
  • ReferencedChartDataSourceBinding, IReferencedChartDataSource, and isReferencedChartDataSource
  • ResourceRefChartDataSourceAdapter, RESOURCE_REF_CHART_DATA_SOURCE_KIND, IResourceRefChartDataSourceInput, and IResourceRefChartDataSourceReference

ChartDataSourceRuntimeStatus and IChartDataSourceStatus belong to @univerjs-pro/engine-chart. Host snapshot types belong to the corresponding chart package: IDocChartDataSource / IDocChartDataSourceInput, ISlideChartDataSource / ISlideChartDataSourceInput, and IBoardChartDataSource / IBoardChartDataSourceInput.

你覺得這篇文檔如何?

© 2026 DreamNum Co., Ltd.