FBubbleChartBuilder
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. Its inherited members are available on this object.
Example
Sheet
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
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
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
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 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.
@univerjs-pro/engine-chart
FBubbleChartBuilder.clearBubbleMapping
Clears the bubble mapping configuration and returns this builder for chaining.
This method executes synchronously.
clearBubbleMapping(): thisReturns
This builder for chaining.
Examples
builder.clearBubbleMapping()Package: @univerjs-pro/engine-chart · Type definitions
FBubbleChartBuilder.setBubbleMapping
Sets the bubble mapping configuration and returns this builder for chaining.
This method executes synchronously.
setBubbleMapping(value: IChartBubbleMappingSpec): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setBubbleMapping({ xIndex: 0, yIndex: 1, sizeIndex: 2 })Types: IChartBubbleMappingSpec
Package: @univerjs-pro/engine-chart · Type definitions
How is this guide?