Sparkline
| Packages | @univerjs-pro/sheets-sparkline |
|---|
The facade class for the sparkline.
This class should not be instantiated directly. Use factory methods on
univerAPIinstead.
Overview
@univerjs-pro/sheets-sparkline
| Method | Description |
|---|---|
changeDataSource | - |
removeSparkline | - |
removeSparklineGroup | - |
setConfig | - |
APIs
Setters & Modifiers
changeDataSource
Signature
changeDataSource(sourceRange: IRange, targetRange: IRange): FSparkline | undefinedParameters
sourceRangeIRange— No descriptiontargetRangeIRange— No description
Returns
FSparkline— Return this, for chaining
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()]
);
// 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);@univerjs-pro/sheets-sparkline
setConfig
Signature
setConfig(config: ISparklineGroupConfig): FSparklineGroupParameters
configISparklineGroupConfig— No description
Returns
FSparklineGroup— Return this instance, for chaining
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);@univerjs-pro/sheets-sparkline
Actions & Operations
removeSparkline
Signature
removeSparkline(): voidExamples
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()]
);
// Remove the sparkline after 3 seconds.
setTimeout(() => {
sparkline.removeSparkline();
}, 3000);@univerjs-pro/sheets-sparkline
removeSparklineGroup
Signature
removeSparklineGroup(): voidExamples
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);@univerjs-pro/sheets-sparkline