@univerjs-pro/chart-embed
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
pnpm add @univerjs-pro/chart-embednpm install @univerjs-pro/chart-embedyarn add @univerjs-pro/chart-embedbun add @univerjs-pro/chart-embedRegister 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.
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:
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
UniverChartEmbedPluginChartDataSourceRuntimeService,IChartDataSourceRuntimeService,IChartDataSourceHandle, andIChartDataSourceRuntimeStateReferencedChartDataSourceBinding,IReferencedChartDataSource, andisReferencedChartDataSourceResourceRefChartDataSourceAdapter,RESOURCE_REF_CHART_DATA_SOURCE_KIND,IResourceRefChartDataSourceInput, andIResourceRefChartDataSourceReference
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.
How is this guide?