# @univerjs-pro/chart-embed

- Human documentation: [https://docs.univer.ai/reference/packages/plugins/univerjs-pro/chart-embed](https://docs.univer.ai/reference/packages/plugins/univerjs-pro/chart-embed)

- Agent Markdown: [https://docs.univer.ai/reference/packages/plugins/univerjs-pro/chart-embed.md](https://docs.univer.ai/reference/packages/plugins/univerjs-pro/chart-embed.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.3`

- Source: [packages/plugins/univerjs-pro/chart-embed.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/packages/plugins/univerjs-pro/chart-embed.mdx)

---

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

#### npm

```bash
npm install @univerjs-pro/chart-embed
```

#### pnpm

```bash
pnpm add @univerjs-pro/chart-embed
```

#### yarn

```bash
yarn add @univerjs-pro/chart-embed
```

#### bun

```bash
bun 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.

```ts
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](https://docs.univer.ai/guides/fundamentals/features/embed.md) for reference resolution and collaborative document loading.

## Reference input

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

```ts
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`.
