Class: LineChartBuilder
The builder for creating a line chart.
Extends
FChartBuilderBase
Properties
Property | Type |
---|---|
| |
| |
| |
|
Methods
build()
build(): IChartBuilderInfo
Builds the chart to reflect all changes made to it.
Returns
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
@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);
Overrides
FChartBuilderBase.build
setDataPointColor()
setDataPointColor(dataPointColor): this
The color of the data point in the line chart.
Parameters
Parameter | Type | Description |
---|---|---|
dataPointColor | string | The color of the data point in the line chart. |
Returns
this
The builder, for chaining.
Example
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.
Parameters
Parameter | Type | Description |
---|---|---|
dataPointShape | LinePointShape | The shape of the data point in the line chart. |
Returns
this
- The builder, for chaining.
Example
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.
Parameters
Parameter | Type | Description |
---|---|---|
dataPointSize | number | The size of the data point in the line chart. |
Returns
this
The builder, for chaining.
Example
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.
Parameters
Parameter | Type | Description |
---|---|---|
lineStyle | AreaLineStyle | The line style of the line chart. |
Returns
this
- The builder, for chaining.
Example
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);