Skip to Content
ClassesFSparklineGroup

Class: FSparklineGroup

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

Methods

changeDataSource()

changeDataSource(sourceRanges, targetRanges): FSparklineGroup

Parameters

ParameterTypeDescription
sourceRangesIRange[]Location of new data source
targetRangesIRange[]New placement

Returns

FSparklineGroup

Return this, for chaining

Description

Modify the data source of the sparkline group

Example

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()

removeSparklineGroup(): void

Returns

void

Description

Delete the sparkline group

Example

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()

setConfig(config): FSparklineGroup

Parameters

ParameterTypeDescription
configISparklineGroupConfignew sparkline group config

Returns

FSparklineGroup

Return this instance, for chaining

Description

Modify the configuration of the current sparkline group

Example

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);