Référence de l’API

FDocumentChart

Cette page API est actuellement disponible en anglais. Les signatures et identifiants restent identiques dans toutes les langues.

Live facade for an inserted Document Chart drawing.

Access

Access through:

Inheritance

Extends FChart. Its inherited members are available on this object.

Example

TypeScript
const fDocument = univerAPI.getActiveDocument()const chartInfo = fDocument  .newChart(univerAPI.Enum.ChartTypeString.Line)  .setSource([    ['Month', 'Sales'],    ['Jan', 120],    ['Feb', 180],    ['Mar', 160],  ])  .setFloating()  .setAbsolutePosition(120, 80)  .setSize(640, 360)  .setLineStyle({ width: 2 })  .build()const fChart = await fDocument.insertChart(chartInfo)console.log(fChart.getId(), fChart.getDrawingId(), fChart.getInfo())fChart.setTitle('Monthly sales').setAbsolutePosition(160, 100).setSize(720, 400)await fChart.setDataSource([  ['Month', 'Sales'],  ['Apr', 200],  ['May', 240],  ['Jun', 220],])const updatedInfo = fChart  .toBuilder(univerAPI.Enum.ChartTypeString.Area)  .setSubtitle('Second quarter')  .build()await fChart.update(updatedInfo)

Setup

Register @univerjs-pro/docs-chart or a preset that includes it. In plugin mode, import @univerjs-pro/docs-chart/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/docs-chart

FDocumentChart.getDrawingId

Returns the stable Document drawing identifier that hosts this Chart.

TypeScript
getDrawingId(): string

Returns

The Document drawing identifier.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const fChart = fDocument.getCharts()[0]console.log(fChart.getDrawingId())

Package: @univerjs-pro/docs-chart · Type definitions

FDocumentChart.unitId

The identifier of the Document that owns this Chart.

TypeScript
readonly unitId: string

Package: @univerjs-pro/docs-chart · Type definitions

@univerjs-pro/shape-thread-comment

FDocumentChart.createCommentAsync

Creates a comment anchored to this document chart.

TypeScript
createCommentAsync(content: ThreadComment.ThreadCommentContent, options?: ElementComment.IFloatingElementCommentCreateOptions): Promise<boolean>

Parameters

  • content — Required. Plain text or a Univer document body for rich comment content.
  • options — Optional. Default: {}. Optional stable IDs, author, attachments, and creation time.

Returns

true when the create command succeeds; otherwise, false.

Throws

If the content is empty.

Examples

TypeScript
const chart = univerAPI.getActiveDocument()?.getCharts()[0]await chart?.createCommentAsync('Verify the chart source.')

Types: Promise · ThreadComment.ThreadCommentContent · ElementComment.IFloatingElementCommentCreateOptions

Package: @univerjs-pro/shape-thread-comment · Type definitions

FDocumentChart.getComments

Returns locally loaded comments anchored to this chart's drawing ID.

TypeScript
getComments(): ThreadComment.IFacadeThreadCommentInfo[]

Returns

Matching comment threads in the current document.

Examples

TypeScript
const chart = univerAPI.getActiveDocument()?.getCharts()[0]console.log(chart?.getComments().length ?? 0)

Types: ThreadComment.IFacadeThreadCommentInfo

Package: @univerjs-pro/shape-thread-comment · Type definitions

FDocumentChart.listCommentsAsync

Synchronizes known threads and returns comments anchored to this chart's drawing ID.

TypeScript
listCommentsAsync(): Promise<ThreadComment.IFacadeThreadCommentInfo[]>

Returns

A promise resolving to matching synchronized comment threads.

Examples

TypeScript
const chart = univerAPI.getActiveDocument()?.getCharts()[0]const comments = chart ? await chart.listCommentsAsync() : []console.log(comments.length)

Types: ThreadComment.IFacadeThreadCommentInfo · Promise

Package: @univerjs-pro/shape-thread-comment · Type definitions

Que pensez-vous de ce guide ?

© 2026 DreamNum Co., Ltd.