类: PieChartBuilder
The builder for creating a pie chart.
属性
| 属性 | 类型 |
|---|---|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
方法
build()
build(): IChartBuilderInfo;Builds the chart to reflect all changes made to it.
返回
The chart builder info.
Description
This method does not automatically draw the chart on top of the spreadsheet. A new chart must be inserted via sheet.insertChart(chart), and an existing chart should be updated via sheet.updateChart(chart).
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The doughnut hole is set to 0.5.
// The border color is set to red.
// The pie chart has a padding angle.
// The pie chart is a half pie chart.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setDoughnutHole(0.5)
.setBorderColor('#ff0000')
.setHasPaddingAngle(true)
.setIsHalfPie(true)
.build();
await fWorksheet.insertChart(chartInfo);重写了
FChartBuilderBase.buildsetBorderColor()
setBorderColor(borderColor): this;Sets the color of the border around the pie chart.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
borderColor | string | The color of the border around the pie chart. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The border color is set to red.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setBorderColor('#ff0000')
.build();
await fWorksheet.insertChart(chartInfo);setDoughnutHole()
setDoughnutHole(doughnutHole): this;Sets the size of the hole in the center of the pie chart as a percentage of the chart size.The value should be in the range 0-1.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
doughnutHole | number | The size of the hole in the center of the pie chart as a percentage of the chart size. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The doughnut hole is set to 0.5.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setDoughnutHole(0.5)
.build();
await fWorksheet.insertChart(chartInfo);setHasPaddingAngle()
setHasPaddingAngle(hasPaddingAngle): this;Sets whether the pie chart has a padding angle.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
hasPaddingAngle | boolean | True if the pie chart has a padding angle; false otherwise. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The pie chart has a padding angle.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setHasPaddingAngle(true)
.build();
await fWorksheet.insertChart(chartInfo);setIsHalfPie()
setIsHalfPie(isHalfPie): this;Sets whether the pie chart is a half pie chart.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
isHalfPie | boolean | True if the pie chart is a half pie chart; false otherwise. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The pie chart is a half pie chart.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setIsHalfPie(true)
.build();
await fWorksheet.insertChart(chartInfo);setRosePie()
setRosePie(rosePie): this;Sets whether the pie chart is a rose pie chart.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
rosePie | boolean | True if the pie chart is a rose pie chart; false otherwise. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The pie chart is a rose pie chart.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setRosePie(true)
.build();
await fWorksheet.insertChart(chartInfo);setShowLabelLine()
setShowLabelLine(showLabelLine): this;Sets whether the pie chart shows label lines.
参数
| 参数 | 类型 | 描述 |
|---|---|---|
showLabelLine | boolean | True if the pie chart shows label lines; false otherwise. |
返回
this
this builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Create a pie chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The pie chart does not show label lines.
const chartInfo = fWorksheet.newChart()
.asPieChart()
.addRange('A1:D6')
.setPosition(1, 1, 0, 0)
.setShowLabelLine(false)
.build();
await fWorksheet.insertChart(chartInfo);