Référence de l’API

FSparkline

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

The facade class for the sparkline.

Access

Access through:

Setup

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

@univerjs-pro/sheets-sparkline

FSparkline.changeDataSource

Modify the data source of the sparkline in the current cell

TypeScript
changeDataSource(sourceRange: IRange, targetRange: IRange): FSparkline | undefined

Parameters

  • sourceRange — Required. Location of new data source
  • targetRange — Required. New placement

Returns

Return this, for chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Create a sparkline in the range A10, with the data source in the range A1:A7.const sparkline = fWorksheet.addSparkline(  [fWorksheet.getRange('A1:A7').getRange()],  [fWorksheet.getRange('A10').getRange()],)// Modify the data source of the sparkline to the range B1:B7, and move it to the range B10 after 3 seconds.setTimeout(() => {  sparkline.changeDataSource(    fWorksheet.getRange('B1:B7').getRange(),    fWorksheet.getRange('B10').getRange(),  )}, 3000)

Types: FSparkline · IRange

Package: @univerjs-pro/sheets-sparkline · Type definitions

FSparkline.removeSparkline

Delete the sparkline in the current cell

TypeScript
removeSparkline(): void

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Create a sparkline in the range A10, with the data source in the range A1:A7.const sparkline = fWorksheet.addSparkline(  [fWorksheet.getRange('A1:A7').getRange()],  [fWorksheet.getRange('A10').getRange()],)// Remove the sparkline after 3 seconds.setTimeout(() => {  sparkline.removeSparkline()}, 3000)

Package: @univerjs-pro/sheets-sparkline · Type definitions

Que pensez-vous de ce guide ?

© 2026 DreamNum Co., Ltd.