类: LineChartBuilder
The builder for creating a line 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).
示例
@example
```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
 
// Create a line chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The line style is set to the step type.
// The data point shape is set to circle, color is red, and size is 10.
const chartInfo = fWorksheet.newChart()
  .asLineChart()
  .addRange('A1:D6')
  .setPosition(1, 1, 0, 0)
  .setLineStyle('step')
  .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
  .setDataPointColor('#ff0000')
  .setDataPointSize(10)
  .build();
await fWorksheet.insertChart(chartInfo);重写了
FChartBuilderBase.buildsetDataPointColor()
setDataPointColor(dataPointColor): this;The color of the data point in the line chart.
参数
| 参数 | 类型 | 描述 | 
|---|---|---|
dataPointColor | string | The color of the data point in the line chart. | 
返回
this
The builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
 
// Create a line chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The data point shape is set to circle, color is red, and size is 10.
const chartInfo = fWorksheet.newChart()
  .asLineChart()
  .addRange('A1:D6')
  .setPosition(1, 1, 0, 0)
  .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
  .setDataPointColor('#ff0000')
  .setDataPointSize(10)
  .build();
await fWorksheet.insertChart(chartInfo);setDataPointShape()
setDataPointShape(dataPointShape): this;The shape of the data point in the line chart.
参数
| 参数 | 类型 | 描述 | 
|---|---|---|
dataPointShape | LinePointShape | The shape of the data point in the line chart. | 
返回
this
- The builder, for chaining.
 
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
 
// Create a line chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The data point shape is set to circle, color is red, and size is 10.
const chartInfo = fWorksheet.newChart()
  .asLineChart()
  .addRange('A1:D6')
  .setPosition(1, 1, 0, 0)
  .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
  .setDataPointColor('#ff0000')
  .setDataPointSize(10)
  .build();
await fWorksheet.insertChart(chartInfo);setDataPointSize()
setDataPointSize(dataPointSize): this;The size of the data point in the line chart.
参数
| 参数 | 类型 | 描述 | 
|---|---|---|
dataPointSize | number | The size of the data point in the line chart. | 
返回
this
The builder, for chaining.
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
 
// Create a line chart with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The data point shape is set to circle, color is red, and size is 10.
const chartInfo = fWorksheet.newChart()
  .asLineChart()
  .addRange('A1:D6')
  .setPosition(1, 1, 0, 0)
  .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
  .setDataPointColor('#ff0000')
  .setDataPointSize(10)
  .build();
await fWorksheet.insertChart(chartInfo);setLineStyle()
setLineStyle(lineStyle): this;The line style of the area chart.
参数
| 参数 | 类型 | 描述 | 
|---|---|---|
lineStyle | AreaLineStyle | The line style of the line chart. | 
返回
this
- The builder, for chaining.
 
示例
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
 
// Create a line chart builder with data source A1:D6.
// The starting position is upper-left corner of cell B2.
// The line style is set to the step type.
const chartInfo = fWorksheet.newChart()
  .asLineChart()
  .addRange('A1:D6')
  .setPosition(1, 1, 0, 0)
  .setLineStyle('step')
  .build();
await fWorksheet.insertChart(chartInfo);