FHistogramChartBuilder
Fluent builder for a one-field raw-sample Histogram.
Select exactly one numeric field containing individual observations. The renderer computes bins from those raw samples; do not pass pre-binned ranges or frequencies.
Histogram settings are persisted as authored. Rendering uses Scott Auto when explicit binning is ineffective, never emits more than 1000 visible bins, and falls back to a zero visual gap for ineffective gap values.
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.Histogram) .setSource('A1:A100') .setHistogramField(0) .setBinCount(12) .setUnderflowThreshold(0) .setOverflowThreshold(100) .setBinGap(0.1) .build()await fWorksheet.insertChart(chartInfo)Doc
const fDocument = univerAPI.getActiveDocument()const chartInfo = fDocument .newChart(univerAPI.Enum.ChartTypeString.Histogram) .setSource([['Duration'], [12], [18], [19], [25], [31], [35]]) .setHistogramField(0) .setBinCount(12) .setUnderflowThreshold(0) .setOverflowThreshold(100) .setBinGap(0.1) .build()await fDocument.insertChart(chartInfo)Slide
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const chartInfo = fSlide .newChart(univerAPI.Enum.ChartTypeString.Histogram) .setSource([['Duration'], [12], [18], [19], [25], [31], [35]]) .setHistogramField(0) .setBinCount(12) .setUnderflowThreshold(0) .setOverflowThreshold(100) .setBinGap(0.1) .build()await fSlide.insertChart(chartInfo)Board
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Histogram) .setSource([['Duration'], [12], [18], [19], [25], [31], [35]]) .setHistogramField(0) .setBinCount(12) .setUnderflowThreshold(0) .setOverflowThreshold(100) .setBinGap(0.1) .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
FHistogramChartBuilder.clearHistogramField
Clears the active Histogram value field.
clearHistogramField(): thisReturns
This builder for chaining.
Examples
builder.clearHistogramField()Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.clearOverflowThreshold
Disables Overflow.
clearOverflowThreshold(): thisReturns
This builder for chaining.
Examples
builder.clearOverflowThreshold()Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.clearUnderflowThreshold
Disables Underflow.
clearUnderflowThreshold(): thisReturns
This builder for chaining.
Examples
builder.clearUnderflowThreshold()Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.resetBinGap
Removes the explicit gap and restores the 0.007 runtime default.
resetBinGap(): thisReturns
This builder for chaining.
Examples
builder.resetBinGap()Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.resetBinning
Removes explicit binning and restores runtime-only Scott Auto.
resetBinning(): thisReturns
This builder for chaining.
Examples
builder.resetBinning()Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setBinCount
Stores an explicit total visible-bin count. Integers from 1 through 1000 are effective
when enabled edge bins still leave room for a regular bin. Other finite values remain
persisted and visible through describe() but render with Scott Auto. Non-finite calls
produce no Pending change.
setBinCount(count: number): thisParameters
count— Required. Total visible-bin count.
Returns
This builder for chaining.
Examples
builder.setBinCount(20)Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setBinGap
Stores the visual gap ratio. Values from 0 through 0.9 are effective; other finite values remain persisted but render with the 0.007-gap default. Non-finite calls are no-op.
setBinGap(value: number): thisParameters
value— Required. Gap ratio between adjacent bins.
Returns
This builder for chaining.
Examples
builder.setBinGap(0.15)Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setBinWidth
Stores an explicit width. A positive finite width is effective only when the current range produces at most 1000 visible bins; otherwise rendering uses Scott Auto without rewriting the stored value. Non-finite calls produce no Pending change.
setBinWidth(width: number): thisParameters
width— Required. Bin width in source-value units.
Returns
This builder for chaining.
Examples
builder.setBinWidth(2.5)Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setHistogramField
Selects the only active Histogram value field by zero-based source index.
setHistogramField(index: number): thisParameters
index— Required. Zero-based source field index.
Returns
This builder for chaining.
Examples
builder.setHistogramField(2)Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setOverflowThreshold
Enables the exclusive x > threshold Overflow bin. An ineffective finite threshold
pair remains persisted but both thresholds are ignored for rendering. Non-finite calls are no-op.
setOverflowThreshold(value: number): thisParameters
value— Required. Exclusive Overflow threshold.
Returns
This builder for chaining.
Examples
builder.setOverflowThreshold(100)Package: @univerjs-pro/engine-chart · Type definitions
FHistogramChartBuilder.setUnderflowThreshold
Enables the inclusive x <= threshold Underflow bin. If both thresholds are present,
they are effective only when Underflow is less than Overflow. Non-finite calls are no-op.
setUnderflowThreshold(value: number): thisParameters
value— Required. Inclusive Underflow threshold.
Returns
This builder for chaining.
Examples
builder.setUnderflowThreshold(0)Package: @univerjs-pro/engine-chart · Type definitions
How is this guide?