# FBubbleChartBuilder

- Human documentation: [https://docs.univer.ai/reference/facade/bubble-chart-builder](https://docs.univer.ai/reference/facade/bubble-chart-builder)

- Agent Markdown: [https://docs.univer.ai/reference/facade/bubble-chart-builder.md](https://docs.univer.ai/reference/facade/bubble-chart-builder.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

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

---

Fluent, type-specific Builder for Bubble Charts.

The data source is an observation table: each row represents one bubble. X and Y
must map to numeric fields. Size is an optional numeric field; label and series are
optional categorical fields for point labels and grouping. All mapped fields are
aligned by row, so their source vectors must have the same length.

## Inheritance

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

## Example

Sheet

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
const chartInfo = fWorksheet
  .newChart(univerAPI.Enum.ChartTypeString.Bubble)
  .setSource({
    range: 'A1:E8',
    orientation: univerAPI.Enum.ChartSourceOrientation.Columns,
  })
  .setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2, labelIndex: 3, seriesIndex: 4 })
  .build()
await fWorksheet.insertChart(chartInfo)
```

Doc

```ts
const fDocument = univerAPI.getActiveDocument()
const chartInfo = fDocument
  .newChart(univerAPI.Enum.ChartTypeString.Bubble)
  .setSource([
    ['X', 'Y', 'Size'],
    [10, 20, 5],
    [18, 32, 9],
  ])
  .setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2 })
  .build()
await fDocument.insertChart(chartInfo)
```

Slide

```ts
const fPresentation = univerAPI.getActivePresentation()
const fSlide = fPresentation.getSlideByIndex(0)
const chartInfo = fSlide
  .newChart(univerAPI.Enum.ChartTypeString.Bubble)
  .setSource([
    ['X', 'Y', 'Size'],
    [10, 20, 5],
    [18, 32, 9],
  ])
  .setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2 })
  .build()
await fSlide.insertChart(chartInfo)
```

Board

```ts
const fBoard = univerAPI.getActiveBoard()
const chartInfo = fBoard
  .newChart(univerAPI.Enum.ChartTypeString.Bubble)
  .setSource([
    ['X', 'Y', 'Size'],
    [10, 20, 5],
    [18, 32, 9],
  ])
  .setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2 })
  .build()
await fBoard.insertChart(chartInfo)
```

## Setup

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

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

### `FBubbleChartBuilder.clearBubbleMapping`

Clears the bubble mapping configuration and returns this builder for chaining.

This method executes synchronously.

```typescript
clearBubbleMapping(): this
```

**Returns**

This builder for chaining.

**Examples**

```ts
builder.clearBubbleMapping()
```

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

### `FBubbleChartBuilder.setBubbleMapping`

Sets the bubble mapping configuration and returns this builder for chaining.

This method executes synchronously.

```typescript
setBubbleMapping(value: IChartBubbleMappingSpec): this
```

**Parameters**

* `value` — Required. The semantic value to record.

**Returns**

This builder for chaining.

**Examples**

```ts
builder.setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2 })
```

**Types:** [`IChartBubbleMappingSpec`](https://unpkg.com/@univerjs-pro/engine-chart@1.0.0-rc.0/lib/types/chart-builder/chart-types.d.ts)

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