FRelationChartBuilder
Configures a relation chart.
Inheritance
Extends FChartBuilderBase. Its inherited members are available on this object.
Example
Sheet
A worksheet range A1:C4 can contain this weighted edge list:
| Source | Target | Weight |
|---|---|---|
| A | B | 5 |
| A | C | 3 |
| C | B | 2 |
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')const chartInfo = fWorksheet .newChart(univerAPI.Enum.ChartTypeString.Relation) .setSource({ range: 'A1:C4', orientation: univerAPI.Enum.ChartSourceOrientation.Columns, }) .setLayout(univerAPI.Enum.ChartRelationChartLayoutEnum.Force) .setUseValueAsSymbolSize(true) .setEmphasisEnabled(true) .setForce({ gravity: 0.2, repulsion: 50 }) .setNodeShape(univerAPI.Enum.ChartLinePointShape.Circle) .build()await fWorksheet.insertChart(chartInfo)Doc
const fDocument = univerAPI.getActiveDocument()const chartInfo = fDocument .newChart(univerAPI.Enum.ChartTypeString.Relation) .setSource([ ['Source', 'Target', 'Weight'], ['A', 'B', 5], ['A', 'C', 3], ['C', 'B', 2], ]) .setLayout(univerAPI.Enum.ChartRelationChartLayoutEnum.Force) .setUseValueAsSymbolSize(true) .setEmphasisEnabled(true) .setForce({ gravity: 0.2, repulsion: 50 }) .setNodeShape(univerAPI.Enum.ChartLinePointShape.Circle) .build()await fDocument.insertChart(chartInfo)Slide
const fPresentation = univerAPI.getActivePresentation()const fSlide = fPresentation.getSlideByIndex(0)const chartInfo = fSlide .newChart(univerAPI.Enum.ChartTypeString.Relation) .setSource([ ['Source', 'Target', 'Weight'], ['A', 'B', 5], ['A', 'C', 3], ['C', 'B', 2], ]) .setLayout(univerAPI.Enum.ChartRelationChartLayoutEnum.Force) .setUseValueAsSymbolSize(true) .setEmphasisEnabled(true) .setForce({ gravity: 0.2, repulsion: 50 }) .setNodeShape(univerAPI.Enum.ChartLinePointShape.Circle) .build()await fSlide.insertChart(chartInfo)Board
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Relation) .setSource([ ['Source', 'Target', 'Weight'], ['A', 'B', 5], ['A', 'C', 3], ['C', 'B', 2], ]) .setLayout(univerAPI.Enum.ChartRelationChartLayoutEnum.Force) .setUseValueAsSymbolSize(true) .setEmphasisEnabled(true) .setForce({ gravity: 0.2, repulsion: 50 }) .setNodeShape(univerAPI.Enum.ChartLinePointShape.Circle) .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
FRelationChartBuilder.clearForce
Clears the force configuration and returns this builder for chaining.
Force layout then uses gravity 0.1, repulsion 5000, and an edge length equal to one fifth
of the chart's shorter side.
This method executes synchronously.
clearForce(): thisReturns
This builder for chaining.
Examples
builder.clearForce()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.resetCircularLabelRotation
Restores the default of keeping circular-layout labels unrotated and returns this builder for chaining.
This method executes synchronously.
resetCircularLabelRotation(): thisReturns
This builder for chaining.
Examples
builder.resetCircularLabelRotation()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.resetEmphasisEnabled
Restores the default of emphasizing adjacent nodes and links on hover and returns this builder for chaining.
This method executes synchronously.
resetEmphasisEnabled(): thisReturns
This builder for chaining.
Examples
builder.resetEmphasisEnabled()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.resetLayout
Restores the layout to None, which uses Univer's fixed relation layout, and returns this builder for chaining.
This method executes synchronously.
resetLayout(): thisReturns
This builder for chaining.
Examples
builder.resetLayout()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.resetNodeShape
Removes the node-shape override so relation nodes use the renderer's circular symbol.
This method executes synchronously.
resetNodeShape(): thisReturns
This builder for chaining.
Examples
builder.resetNodeShape()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.resetUseValueAsSymbolSize
Restores the default of scaling node symbols from their values and returns this builder for chaining.
This method executes synchronously.
resetUseValueAsSymbolSize(): thisReturns
This builder for chaining.
Examples
builder.resetUseValueAsSymbolSize()Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setCircularLabelRotation
Sets the circular label rotation configuration and returns this builder for chaining.
This method executes synchronously.
setCircularLabelRotation(value: boolean): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setCircularLabelRotation(true)Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setEmphasisEnabled
Sets the emphasis enabled configuration and returns this builder for chaining.
This method executes synchronously.
setEmphasisEnabled(value: boolean): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setEmphasisEnabled(true)Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setForce
Sets the force configuration and returns this builder for chaining.
Omitted fields keep their current values. Without explicit overrides, force layout uses
gravity 0.1, repulsion 5000, and an edge length equal to one fifth of the chart's shorter side.
This method executes synchronously.
setForce(value: IChartRelationForceSpec): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setForce({ gravity: 0.2, repulsion: 50 })Types: IChartRelationForceSpec
Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setLayout
Sets the layout configuration and returns this builder for chaining.
This method executes synchronously.
setLayout(value: RelationChartLayoutEnum): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setLayout(univerAPI.Enum.ChartRelationChartLayoutEnum.Force)Types: RelationChartLayoutEnum
Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setNodeShape
Sets the node shape configuration and returns this builder for chaining.
This method executes synchronously.
setNodeShape(value: LinePointShape): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setNodeShape(univerAPI.Enum.ChartLinePointShape.Circle)Types: LinePointShape
Package: @univerjs-pro/engine-chart · Type definitions
FRelationChartBuilder.setUseValueAsSymbolSize
Sets the use value as symbol size configuration and returns this builder for chaining.
This method executes synchronously.
setUseValueAsSymbolSize(value: boolean): thisParameters
value— Required. The semantic value to record.
Returns
This builder for chaining.
Examples
builder.setUseValueAsSymbolSize(true)Package: @univerjs-pro/engine-chart · Type definitions
你觉得这篇文档如何?