FCandlestickChartBuilder
Fluent semantic builder for one HLC or OHLC Candlestick series.
Each source row represents one trading interval. Map one category field and four distinct numeric fields in Open, High, Low, Close order, or three in High, Low, Close order. A row with any missing or non-finite required price renders as a gap. Three roles mean HLC; four mean OHLC. Missing prices never change roles, and HLC never fabricates Open.
Sheet Header belongs to the source. Doc/Slide use setSource() for raw rows and
setDataSource() to update an inserted chart; explicit Lite Header belongs to the
host resource context. Both project titles into dataset dimensions. ChartContext
only selects dataset indexes and does not store Header. An inline resource containing
a title row uses host context { orient: 'row', header: { band: { startOffset: 0, endOffset: 0 } } }.
The following Doc/Slide examples pass body rows directly, with no title band.
Inheritance
Extends FAxisChartBuilder. Its inherited members are available on this object.
Example
Sheet HLC with an explicit title band
const chartInfo = fWorksheet .newChart(univerAPI.Enum.ChartTypeString.Candlestick) .setSource({ range: 'A1:D6', orientation: univerAPI.Enum.ChartSourceOrientation.Columns, header: { band: { startOffset: 0, endOffset: 0 } }, }) .setCategoryField(0) .setCandlestickFields({ highIndex: 1, lowIndex: 2, closeIndex: 3 }) .setHighLowLineStyle({ border: { color: '#333333', width: 1 } }) .setCloseMarkerStyle({ point: { shape: univerAPI.Enum.ChartLinePointShape.Dash, size: 8 } }) .build()// clearHighLowLineStyle()/clearCloseMarkerStyle() restore the default appearance.Sheet
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')const chartInfo = fWorksheet .newChart(univerAPI.Enum.ChartTypeString.Candlestick) .setSource({ range: 'A1:E8', orientation: univerAPI.Enum.ChartSourceOrientation.Columns, header: { band: { startOffset: 0, endOffset: 0 } }, }) .setCategoryField(0) .setCandlestickFields({ openIndex: 1, highIndex: 2, lowIndex: 3, closeIndex: 4 }) .setRisingStyle({ color: '#0DA471', hollow: true }) .setFallingStyle({ color: '#F05252' }) .setDojiStyle({ color: '#8C8C8C', border: { width: 2 } }) .setCandleWidth(18) .build()await fWorksheet.insertChart(chartInfo)Doc
const fDocument = univerAPI.getActiveDocument()const chartInfo = fDocument .newChart(univerAPI.Enum.ChartTypeString.Candlestick) .setSource([ ['Mon', 112, 96, 108], ['Tue', 116, 102, 105], ]) .setCategoryField(0) .setCandlestickFields({ highIndex: 1, lowIndex: 2, closeIndex: 3 }) .setHighLowLineStyle({ border: { color: '#333333', width: 1 } }) .setCloseMarkerStyle({ point: { shape: univerAPI.Enum.ChartLinePointShape.Dot, size: 8 } }) .build()await fDocument.insertChart(chartInfo)Slide
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const chartInfo = fSlide .newChart(univerAPI.Enum.ChartTypeString.Candlestick) .setSource([ ['Mon', 100, 112, 96, 108], ['Tue', 108, 116, 102, 105], ]) .setCategoryField(0) .setCandlestickFields({ openIndex: 1, highIndex: 2, lowIndex: 3, closeIndex: 4 }) .setRisingStyle({ color: '#0DA471', hollow: true }) .setFallingStyle({ color: '#F05252' }) .setDojiStyle({ color: '#8C8C8C', border: { width: 2 } }) .setCandleWidth(18) .build()await fSlide.insertChart(chartInfo)Board
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Candlestick) .setSource([ ['Mon', 100, 112, 96, 108], ['Tue', 108, 116, 102, 105], ]) .setCategoryField(0) .setCandlestickFields({ openIndex: 1, highIndex: 2, lowIndex: 3, closeIndex: 4 }) .setRisingStyle({ color: '#0DA471', hollow: true }) .setFallingStyle({ color: '#F05252' }) .setDojiStyle({ color: '#8C8C8C', border: { width: 2 } }) .setCandleWidth(18) .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
FCandlestickChartBuilder.clearCandlestickFields
Clears the atomic Candlestick mapping while preserving the category field.
clearCandlestickFields(): thisReturns
This builder for chaining.
Examples
builder.clearCandlestickFields()Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.clearCloseMarkerStyle
Clears authored Close marker appearance.
clearCloseMarkerStyle(): thisExamples
builder.clearCloseMarkerStyle();
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.clearDojiStyle
Clears explicit Doji style overrides so runtime defaults apply.
clearDojiStyle(): thisReturns
This builder for chaining.
Examples
builder.clearDojiStyle()Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.clearFallingStyle
Clears explicit Falling style overrides so runtime defaults apply.
clearFallingStyle(): thisReturns
This builder for chaining.
Examples
builder.clearFallingStyle()Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.clearHighLowLineStyle
Clears authored high-low appearance.
clearHighLowLineStyle(): thisExamples
builder.clearHighLowLineStyle();
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.clearRisingStyle
Clears explicit Rising style overrides so runtime defaults apply.
clearRisingStyle(): thisReturns
This builder for chaining.
Examples
builder.clearRisingStyle()Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.resetCandleWidth
Removes the fixed candle width so the renderer chooses it automatically.
resetCandleWidth(): thisReturns
This builder for chaining.
Examples
builder.resetCandleWidth()Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setCandlestickFields
Replaces High, Low, Close, and optionally Open source fields atomically.
Category remains configured through setCategoryField(). Every supplied index must be a
unique non-negative integer. Read the pending or persisted value with
builder.build().config.mapping?.candlestick.
setCandlestickFields(fields: IChartCandlestickMappingSpec): thisParameters
fields— Required. HLC indexes; omit Open for HLC or supply a real Open index for OHLC.
Returns
This builder for chaining.
Examples
builder .setCategoryField(0) .setCandlestickFields({ openIndex: 1, highIndex: 2, lowIndex: 3, closeIndex: 4 })const mapping = builder.build().config.mapping?.candlestickTypes: IChartCandlestickMappingSpec
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setCandleWidth
Sets a fixed candle width value without Facade range validation.
setCandleWidth(width: number): thisParameters
width— Required. Fixed candle width in pixels.
Returns
This builder for chaining.
Examples
builder.setCandleWidth(18)Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setCloseMarkerStyle
Sets Close marker appearance.
setCloseMarkerStyle(style: NonNullable<IChartCandlestickSpec['closeMarker']>): thisParameters
style— Required.
Examples
builder.setCloseMarkerStyle({ point: { size: 8 } });
Types: NonNullable · IChartCandlestickSpec
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setDojiStyle
Sets semantic Doji body and wick style overrides.
setDojiStyle(style: IChartCandlestickStateStyleSpec): thisParameters
style— Required. Doji body and wick style values, passed through without Facade range validation.
Returns
This builder for chaining.
Examples
builder.setDojiStyle({ color: '#8C8C8C', border: { width: 2 } })Types: IChartCandlestickStateStyleSpec
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setFallingStyle
Sets semantic Falling candle body and wick style overrides.
setFallingStyle(style: IChartCandlestickStateStyleSpec): thisParameters
style— Required. Falling body and wick style values, passed through without Facade range validation.
Returns
This builder for chaining.
Examples
builder.setFallingStyle({ color: '#F05252' })Types: IChartCandlestickStateStyleSpec
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setHighLowLineStyle
Sets high-low line appearance.
setHighLowLineStyle(style: NonNullable<IChartCandlestickSpec['highLowLine']>): thisParameters
style— Required.
Examples
builder.setHighLowLineStyle({ visible: false });
Types: NonNullable · IChartCandlestickSpec
Package: @univerjs-pro/engine-chart · Type definitions
FCandlestickChartBuilder.setRisingStyle
Sets semantic Rising candle body and wick style overrides.
setRisingStyle(style: IChartCandlestickStateStyleSpec): thisParameters
style— Required. Rising body and wick style values, passed through without Facade range validation.
Returns
This builder for chaining.
Examples
builder.setRisingStyle({ color: '#0DA471', hollow: true })Types: IChartCandlestickStateStyleSpec
Package: @univerjs-pro/engine-chart · Type definitions
你觉得这篇文档如何?