FWaterfallChartBuilder
Fluent, type-specific Builder for Waterfall Charts.
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.Waterfall) .setSource('A1:B8') .setPointRoles([ { series: 0, dataPointIndex: 3, role: univerAPI.Enum.ChartWaterfallPointRole.Total }, ]) .setConnector(true) .setStackType(univerAPI.Enum.ChartWaterfallStackTypeEnum.Arrangement) .setUseSubtotal(true) .setPositiveStyle(0, { color: '#16a34a' }) .setNegativeStyle(0, { color: '#dc2626' }) .setSubtotalStyle(0, { color: '#2563eb' }) .build()await fWorksheet.insertChart(chartInfo)Doc
const fDocument = univerAPI.getActiveDocument()const chartInfo = fDocument .newChart(univerAPI.Enum.ChartTypeString.Waterfall) .setSource([ ['Stage', 'Change'], ['Revenue', 300], ['Costs', -180], ['Profit', 120], ]) .setPointRoles([ { series: 0, dataPointIndex: 2, role: univerAPI.Enum.ChartWaterfallPointRole.Total }, ]) .setConnector(true) .setStackType(univerAPI.Enum.ChartWaterfallStackTypeEnum.Arrangement) .setUseSubtotal(true) .setPositiveStyle(0, { color: '#16a34a' }) .setNegativeStyle(0, { color: '#dc2626' }) .setSubtotalStyle(0, { color: '#2563eb' }) .build()await fDocument.insertChart(chartInfo)Slide
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const chartInfo = fSlide .newChart(univerAPI.Enum.ChartTypeString.Waterfall) .setSource([ ['Stage', 'Change'], ['Revenue', 300], ['Costs', -180], ['Profit', 120], ]) .setPointRoles([ { series: 0, dataPointIndex: 2, role: univerAPI.Enum.ChartWaterfallPointRole.Total }, ]) .setConnector(true) .setStackType(univerAPI.Enum.ChartWaterfallStackTypeEnum.Arrangement) .setUseSubtotal(true) .setPositiveStyle(0, { color: '#16a34a' }) .setNegativeStyle(0, { color: '#dc2626' }) .setSubtotalStyle(0, { color: '#2563eb' }) .build()await fSlide.insertChart(chartInfo)Board
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Waterfall) .setSource([ ['Stage', 'Change'], ['Revenue', 300], ['Costs', -180], ['Profit', 120], ]) .setPointRoles([ { series: 0, dataPointIndex: 2, role: univerAPI.Enum.ChartWaterfallPointRole.Total }, ]) .setConnector(true) .setStackType(univerAPI.Enum.ChartWaterfallStackTypeEnum.Arrangement) .setUseSubtotal(true) .setPositiveStyle(0, { color: '#16a34a' }) .setNegativeStyle(0, { color: '#dc2626' }) .setSubtotalStyle(0, { color: '#2563eb' }) .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
FWaterfallChartBuilder.clearConnector
Clears connector configuration. With no persisted connector setting, the renderer does not
draw connectors; call setConnector(true) to restore the default dashed connector.
Read the cleared value from builder.build().config.waterfall?.connector.
clearConnector(): thisReturns
This builder for chaining.
Examples
builder.clearConnector()const connector = builder.build().config.waterfall?.connectorPackage: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.clearNegativeStyle
Clears the negative style configuration and returns this builder for chaining.
This method executes synchronously.
clearNegativeStyle(selector: ChartPublicSeriesSelector): thisParameters
selector— Required. The target series selector.
Returns
This builder for chaining.
Examples
builder.clearNegativeStyle(0)const negative = builder.build().config.series[0]?.waterfallStyles?.negativeTypes: ChartPublicSeriesSelector
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.clearPositiveStyle
Clears the positive style configuration and returns this builder for chaining.
This method executes synchronously.
clearPositiveStyle(selector: ChartPublicSeriesSelector): thisParameters
selector— Required. The target series selector.
Returns
This builder for chaining.
Examples
builder.clearPositiveStyle(0)const positive = builder.build().config.series[0]?.waterfallStyles?.positiveTypes: ChartPublicSeriesSelector
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.clearSubtotalStyle
Clears the subtotal style configuration and returns this builder for chaining.
This method executes synchronously.
clearSubtotalStyle(selector: ChartPublicSeriesSelector): thisParameters
selector— Required. The target series selector.
Returns
This builder for chaining.
Examples
builder.clearSubtotalStyle(0)const subtotal = builder.build().config.series[0]?.waterfallStyles?.subtotalTypes: ChartPublicSeriesSelector
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.resetStackType
Restores the stack type to Arrangement and returns this builder for chaining.
This method executes synchronously.
resetStackType(): thisReturns
This builder for chaining.
Examples
builder.resetStackType()Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.resetUseSubtotal
Restores automatic subtotal generation to its default of true and returns this builder for chaining.
This method executes synchronously.
resetUseSubtotal(): thisReturns
This builder for chaining.
Examples
builder.resetUseSubtotal()Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setConnector
Enables, disables, or styles derived Waterfall connectors.
Passing true renders a 1 px dashed connector with full opacity, no endpoint symbols,
and a neutral #8C8C8C base color that is adapted by the active light or dark theme. An object
starts from those defaults and overrides only the supplied fields. Pass false to hide it.
Read the current value from builder.build().config.waterfall?.connector.
setConnector(value: boolean | IChartWaterfallConnectorStyleSpec): thisParameters
value— Required.falsedisables,trueenables the default dashed style, and an object enables style overrides.
Returns
This builder for chaining.
Examples
builder.setConnector(true)const connector = builder.build().config.waterfall?.connectorTypes: IChartWaterfallConnectorStyleSpec
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setNegativeStyle
Sets the negative style configuration and returns this builder for chaining.
This method executes synchronously.
setNegativeStyle(selector: ChartPublicSeriesSelector, value: Omit<IChartSeriesPatch, 'selector'>): thisParameters
selector— Required. The target series selector.value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setNegativeStyle(0, { color: '#f5222d' })const negative = builder.build().config.series[0]?.waterfallStyles?.negativeTypes: ChartPublicSeriesSelector · Omit · IChartSeriesPatch
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setPointRoles
Replaces all Waterfall point roles.
Duplicate series/point identities use the last input and read back in canonical order.
setPointRoles(roles: readonly IChartWaterfallPointRoleSpec[]): thisParameters
roles— Required. The complete point-role collection.
Returns
This builder for chaining.
Examples
builder.setPointRoles([ { series: 0, dataPointIndex: 0, role: univerAPI.Enum.ChartWaterfallPointRole.Total },])const roles = builder.build().config.waterfall?.pointRolesTypes: IChartWaterfallPointRoleSpec
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setPositiveStyle
Sets the positive style configuration and returns this builder for chaining.
This method executes synchronously.
setPositiveStyle(selector: ChartPublicSeriesSelector, value: Omit<IChartSeriesPatch, 'selector'>): thisParameters
selector— Required. The target series selector.value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setPositiveStyle(0, { color: '#52c41a' })const positive = builder.build().config.series[0]?.waterfallStyles?.positiveTypes: ChartPublicSeriesSelector · Omit · IChartSeriesPatch
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setStackType
Sets the stack type configuration and returns this builder for chaining.
This method executes synchronously.
setStackType(value: WaterfallStackTypeEnum): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setStackType(univerAPI.Enum.ChartWaterfallStackTypeEnum.Arrangement)Types: WaterfallStackTypeEnum
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setSubtotalStyle
Sets the subtotal style configuration and returns this builder for chaining.
This method executes synchronously.
setSubtotalStyle(selector: ChartPublicSeriesSelector, value: Omit<IChartSeriesPatch, 'selector'>): thisParameters
selector— Required. The target series selector.value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setSubtotalStyle(0, { color: '#1677ff' })const subtotal = builder.build().config.series[0]?.waterfallStyles?.subtotalTypes: ChartPublicSeriesSelector · Omit · IChartSeriesPatch
Package: @univerjs-pro/engine-chart · Type definitions
FWaterfallChartBuilder.setUseSubtotal
Sets the use subtotal configuration and returns this builder for chaining.
This method executes synchronously.
setUseSubtotal(value: boolean): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setUseSubtotal(true)Package: @univerjs-pro/engine-chart · Type definitions
你觉得这篇文档如何?