FAxisChartBuilder
Fluent base Builder for Charts that expose Cartesian axes and mark lines.
Inheritance
Extends FChartBuilderBase. Its inherited members are available on this object.
Example
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')const chartInfo = fWorksheet .newChart(univerAPI.Enum.ChartTypeString.Line) .setSource('A1:D8') .setYAxisTitle('Revenue') .build()await fWorksheet.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
FAxisChartBuilder.clearMarkLines
Clears all fixed-axis mark lines.
Read the cleared value from builder.build().config.markLines.
clearMarkLines(): thisReturns
This builder for chaining.
Examples
builder.clearMarkLines()const markLines = builder.build().config.markLinesPackage: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearRightYAxis
Clears the right yaxis configuration and returns this builder for chaining.
This method executes synchronously.
clearRightYAxis(target?: ChartAxisTarget): thisParameters
target— Optional. The configuration field to clear or reset.
Returns
This builder for chaining.
Examples
builder.clearRightYAxis(univerAPI.Enum.ChartAxisTarget.Line)Types: ChartAxisTarget
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearRightYAxisTitle
Clears the right yaxis title configuration and returns this builder for chaining.
This method executes synchronously.
clearRightYAxisTitle(): thisReturns
This builder for chaining.
Examples
builder.clearRightYAxisTitle()Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearXAxis
Clears the xaxis configuration and returns this builder for chaining.
This method executes synchronously.
clearXAxis(target?: ChartAxisTarget): thisParameters
target— Optional. The configuration field to clear or reset.
Returns
This builder for chaining.
Examples
builder.clearXAxis(univerAPI.Enum.ChartAxisTarget.Label)Types: ChartAxisTarget
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearXAxisTitle
Clears the xaxis title configuration and returns this builder for chaining.
This method executes synchronously.
clearXAxisTitle(): thisReturns
This builder for chaining.
Examples
builder.clearXAxisTitle()Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearYAxis
Clears the Y axis configuration and returns this builder for chaining. Clearing an entire logarithmic axis writes explicit linear intent so imported raw chart data cannot restore the old logarithmic scale. Clearing a field keeps the scale.
This method executes synchronously.
clearYAxis(target?: ChartAxisTarget): thisParameters
target— Optional. The configuration field to clear or reset.
Returns
This builder for chaining.
Examples
builder.clearYAxis(univerAPI.Enum.ChartAxisTarget.GridLine)Types: ChartAxisTarget
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.clearYAxisTitle
Clears the yaxis title configuration and returns this builder for chaining.
This method executes synchronously.
clearYAxisTitle(): thisReturns
This builder for chaining.
Examples
builder.clearYAxisTitle()Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.resetUseDateAxis
Restores the default of using a category axis instead of a date axis and returns this builder for chaining.
This method executes synchronously.
resetUseDateAxis(): thisReturns
This builder for chaining.
Examples
builder.resetUseDateAxis()Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setMarkLines
Replaces all fixed-axis mark lines.
Omitted line-style fields use a 1 px solid stroke at full opacity and inherit the carrier
series color, falling back to the active theme. Endpoint symbols are hidden. Labels are hidden
unless a label object is supplied; an empty label object shows the axis-formatted value.
Read the current value from builder.build().config.markLines.
setMarkLines(lines: readonly IChartMarkLineSpec[]): thisParameters
lines— Required. The complete ordered mark-line collection. An empty list clears it.
Returns
This builder for chaining.
Examples
builder.setMarkLines([{ axis: univerAPI.Enum.ChartSemanticAxis.PrimaryValue, value: 80 }])const markLines = builder.build().config.markLinesTypes: IChartMarkLineSpec
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setRightYAxis
Sets the existing secondary Y axis configuration and returns this builder for chaining.
Logarithmic settings follow setYAxis; this does not create a secondary Bar axis.
This method executes synchronously.
setRightYAxis(value: IChartAxisSpec): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
// The existing Line chart already has a series assigned to its secondary axis.const sheet = univerAPI.getActiveWorkbook().getActiveSheet()const chart = sheet.getCharts()[0]const builder = chart .toBuilder(univerAPI.Enum.ChartTypeString.Line) .setYAxis({ scaleType: 'linear' }) .setRightYAxis({ scaleType: 'log', logBase: 2 })await chart.update(builder.build())Types: IChartAxisSpec
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setRightYAxisTitle
Sets the right yaxis title configuration and returns this builder for chaining.
This method executes synchronously.
setRightYAxisTitle(value: string): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setRightYAxisTitle('Margin')Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setUseDateAxis
Sets the use date axis configuration and returns this builder for chaining.
This method executes synchronously.
setUseDateAxis(value: boolean): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setUseDateAxis(true)Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setXAxis
Sets the X axis configuration and returns this detached builder for chaining.
On a supported Bar chart, { scaleType: 'log', logBase: 2.5 } selects its numeric scale.
Unsupported axis configurations are retained and reported by chart diagnostics.
This method executes synchronously.
setXAxis(value: IChartAxisSpec): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
// Bar charts use the X axis as their numeric axis.const sheet = univerAPI.getActiveWorkbook().getActiveSheet()const chartInfo = sheet .newChart(univerAPI.Enum.ChartTypeString.Bar) .setSource('A1:B8') .setXAxis({ scaleType: 'log', logBase: 10 }) .build()await sheet.insertChart(chartInfo)Types: IChartAxisSpec
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setXAxisTitle
Sets the xaxis title configuration and returns this builder for chaining.
This method executes synchronously.
setXAxisTitle(value: string): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setXAxisTitle('Month')Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setYAxis
Sets the Y axis configuration and returns this detached builder for chaining.
Supported numeric axes accept { scaleType: 'log', logBase: 2.5 }.
Missing base defaults to 10 when first enabled. Finite out-of-range values are retained
for compatibility and render with base 10 plus diagnostics. Normal input uses 2–1000.
Apply an existing-chart draft with await chart.update(builder.build()).
Explicit scaleType: 'linear' removes the base; unrelated patches preserve it.
This method executes synchronously.
setYAxis(value: IChartAxisSpec): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
// Update an existing Line chart; Area and Column use the same Y-axis settings.const sheet = univerAPI.getActiveWorkbook().getActiveSheet()const chart = sheet.getCharts()[0]const builder = chart .toBuilder(univerAPI.Enum.ChartTypeString.Line) .setYAxis({ scaleType: 'log', logBase: 2.5 })await chart.update(builder.build())// Change only the base of the logarithmic axis.await chart.update( chart.toBuilder(univerAPI.Enum.ChartTypeString.Line).setYAxis({ logBase: 2 }).build(),)// Restore linear scaling and remove the logarithm base.await chart.update( chart.toBuilder(univerAPI.Enum.ChartTypeString.Line).setYAxis({ scaleType: 'linear' }).build(),)Types: IChartAxisSpec
Package: @univerjs-pro/engine-chart · Type definitions
FAxisChartBuilder.setYAxisTitle
Sets the yaxis title configuration and returns this builder for chaining.
This method executes synchronously.
setYAxisTitle(value: string): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setYAxisTitle('Revenue')Package: @univerjs-pro/engine-chart · Type definitions
Que pensez-vous de ce guide ?