FSparklineGroup

GitHubEdit on GitHub
packages@univerjs-pro/sheets-sparkline

The facade class for the sparkline group.Which uses to setting multiple sparklines, all sparkline in the same group will share the configs.

APIs

changeDataSource

Signature

changeDataSource(sourceRanges: IRange[], targetRanges: IRange[]): FSparklineGroup | undefined

Parameters

  • sourceRanges (IRange[]) — Location of new data source
  • targetRanges (IRange[]) — New placement

Returns

  • (FSparklineGroup | undefined) — Return this, for chaining

Tags

  • @description — Modify the data source of the sparkline group

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()

// 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()],
)

// Get sparkline group by cell A10
const sparklineGroup = fWorksheet.getSparklineGroupByCell(9, 0)

setTimeout(() => {
  // Modify the data source of the sparkline group to the range B1:B7 after 3 seconds.
  sparklineGroup.changeDataSource(
    [fWorksheet.getRange('B1:B7').getRange()],
    [fWorksheet.getRange('A10').getRange()],
  )
}, 3000)

removeSparklineGroup

Signature

removeSparklineGroup(): void

Returns

Tags

  • @description — Delete the sparkline group

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()

// 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()],
)

// Get sparkline group by cell A10
const sparklineGroup = fWorksheet.getSparklineGroupByCell(9, 0)

setTimeout(() => {
  // Remove sparkline group after 3 seconds.
  sparklineGroup.removeSparklineGroup()
}, 3000)

setConfig

Signature

setConfig(config: ISparklineGroupConfig): FSparklineGroup

Parameters

  • config (ISparklineGroupConfig) — new sparkline group config

Returns

  • (FSparklineGroup) — Return this instance, for chaining

Tags

  • @description — Modify the configuration of the current sparkline group

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()

// 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()],
)

// Get sparkline group by cell A10
const sparklineGroup = fWorksheet.getSparklineGroupByCell(9, 0)

// Set sparkline type to bar chart after 3 seconds
setTimeout(() => {
  sparklineGroup.setConfig({
    type: univerAPI.Enum.SparklineTypeEnum.BAR_CHART,
  })
}, 3000)