# FSlideChart

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/slide-chart](https://docs.univer.ai/zh-CN/reference/facade/slide-chart)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/slide-chart.md](https://docs.univer.ai/zh-CN/reference/facade/slide-chart.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/slide-chart.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/slide-chart.mdx)

---

The facade class for a slide chart element.

## Access

Access through:

* [`FSlide.insertChart()`](https://docs.univer.ai/zh-CN/reference/facade/slide.md#insertchart)
* [`FSlide.getChart()`](https://docs.univer.ai/zh-CN/reference/facade/slide.md#getchart)
* [`FSlide.getCharts()`](https://docs.univer.ai/zh-CN/reference/facade/slide.md#getcharts)

## Inheritance

Extends [`FChart`](https://docs.univer.ai/zh-CN/reference/facade/chart.md). Its inherited members are available on this object.

## Setup

Register [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) or a preset that includes it. In plugin mode, import `@univerjs-pro/slides-chart/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/slides/getting-started/facade.md).

## `@univerjs-pro/slides-chart`

### `FSlideChart.getChartData`

Get read-only chart resource data stored in the presentation snapshot.
Use `getInfo()` for the complete insertion snapshot. `toBuilder()` creates
a detached copy Builder and does not update this Chart.

```typescript
getChartData(): { chart: IChartResourceSnapshot; dataSource: IChartResourceDataSource; } | null
```

**Returns**

The chart resource data, or `null` when it does not exist.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideById('slide-1')
const charts = fSlide.getCharts()

// Get the chart resource data of the first chart.
const chart = charts[0]
const chartData = chart.getChartData()
console.log(chartData)
```

**Types:** [`IChartResourceSnapshot`](https://unpkg.com/@univerjs-pro/engine-chart@1.0.0-rc.0/lib/types/models/chart-host/resource/chart-resource-repository.d.ts) · [`IChartResourceDataSource`](https://unpkg.com/@univerjs-pro/engine-chart@1.0.0-rc.0/lib/types/models/chart-host/resource/chart-resource-repository.d.ts)

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.getElementId`

Returns the stable Slide element identifier that hosts this Chart.

```typescript
getElementId(): string
```

**Returns**

The Slide element identifier.

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.getPlaceholder`

Get the placeholder metadata associated with this chart.

```typescript
getPlaceholder(): ISlidePlaceholderData | undefined
```

**Returns**

The placeholder metadata, or `undefined` if the chart is not created from a placeholder.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideById('slide-1')
const charts = fSlide.getCharts()
console.log(charts[0].getPlaceholder())
```

**Types:** [`ISlidePlaceholderData`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.getStroke`

Get the chart frame stroke style.

```typescript
getStroke(): IShapeLineStyle | undefined
```

**Returns**

The chart frame stroke style.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideById('slide-1')
const charts = fSlide.getCharts()
console.log(charts[0].getStroke())
```

**Types:** [`IShapeLineStyle`](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.setPlaceholder`

Update the placeholder metadata associated with this chart.

```typescript
setPlaceholder(placeholder?: ISlidePlaceholderData): this
```

**Parameters**

* `placeholder` — Optional. The placeholder metadata. Pass `undefined` to clear it.

**Returns**

This chart, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideById('slide-1')
const charts = fSlide.getCharts()

// Clear the placeholder of the first chart.
const chart = charts[0]
chart.setPlaceholder(undefined)
```

**Types:** [`ISlidePlaceholderData`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.setStroke`

Update the chart frame stroke style.

```typescript
setStroke(stroke?: IShapeLineStyle): this
```

**Parameters**

* `stroke` — Optional. The stroke style. Pass `undefined` to clear it.

**Returns**

This chart, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideById('slide-1')
const charts = fSlide.getCharts()

// Set the stroke of the first chart to a gray thin line.
const chart = charts[0]
chart.setStroke({ color: '#d1d5db', width: 1 })
```

**Types:** [`IShapeLineStyle`](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)

### `FSlideChart.unitId`

```typescript
readonly unitId: string
```

**Package:** [`@univerjs-pro/slides-chart`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides-chart.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides-chart@1.0.0-rc.0/lib/types/facade/f-slide-chart.d.ts)
