@univerjs-prosheets-sparklinefacadeinterfacesIfworksheetsparklinemixin

@univerjs-pro/sheets-sparkline v0.5.4


Interface: IFWorksheetSparklineMixin

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:8

Methods

addSparkline()

addSparkline(
   sourceRanges, 
   targetRanges, 
   type): undefined | FSparkline

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:28

Parameters

ParameterTypeDescription
sourceRangesIRange[]Source data location for sparklines
targetRangesIRange[]Where to place sparklines
typeLINE_CHARTThe type of Sparklines

Returns

undefined | FSparkline

Returns the sparkline instance for the next call

Description

Add sparkline to the worksheet.

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
 
const sparkline = worksheet.addSparkline(
  [{ startRow: 0, endRow: 6, startColumn: 0, endColumn: 0 }],
  [{ startRow: 9, endRow: 9, startColumn: 0, endColumn: 0 }]
);
 
console.log('sparkline instance', sparkline);

composeSparkline()

composeSparkline(ranges): void

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:73

Parameters

ParameterTypeDescription
rangesIRange[]Current selection

Returns

void

Description

Group the sparklines in the selection into a new sparkline group

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
 
const firstSparkline = worksheet.addSparkline(
  [{ startRow: 0, endRow: 6, startColumn: 0, endColumn: 0 }],
  [{ startRow: 9, endRow: 9, startColumn: 0, endColumn: 0 }]
);
 
const secondSparkline = worksheet.addSparkline(
  [{ startRow: 0, endRow: 6, startColumn: 0, endColumn: 0 }],
  [{ startRow: 9, endRow: 9, startColumn: 1, endColumn: 1 }]
);
 
// There will be two sparklines here
const allSparklineBeforeCompose = worksheet.getAllSubSparkline();
 
worksheet.composeSparkline([{ startRow: 9, endRow: 9, startColumn: 0, endColumn: 1 }]);
 
// After compose, there will only be one sparkline
const allSparklineAfterCompose = worksheet.getAllSubSparkline();
console.log('debugger', allSparklineBeforeCompose, allSparklineAfterCompose);

getAllSubSparkline()

getAllSubSparkline(): 
  | undefined
| Map<string, ISparklineGroup>

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:42

Returns

| undefined | Map<string, ISparklineGroup>

Description

Get all sparklines in the worksheet.

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
 
const allSparkline = worksheet.getAllSubSparkline();
console.log('allSparkline', allSparkline);

getSparklineByCell()

getSparklineByCell(row, col): undefined | FSparkline

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:110

Parameters

ParameterType
rownumber
colnumber

Returns

undefined | FSparkline

Returns the sparkline instance for the next call

Description

Get the sparkline instance of the current cell

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
const sparkline = worksheet.getSparklineByCell(9, 0)

getSparklineGroupByCell()

getSparklineGroupByCell(row, col): undefined | FSparklineGroup

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:124

Parameters

ParameterType
rownumber
colnumber

Returns

undefined | FSparklineGroup

Description

Get the sparkline groups instance of the current cell

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
const sparkline = worksheet.getSparklineGroupByCell(9, 0)

unComposeSparkline()

unComposeSparkline(ranges): void

Defined in: packages/sheets-sparkline/src/facade/f-worksheet.ts:96

Parameters

ParameterTypeDescription
rangesIRange[]Current selection

Returns

void

Description

Split the sparkline group within the current selection

Example

// Continuing from the `composeSparkline` demo
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
 
// There will only be one sparkline here
const allSparklineBeforeUnCompose = worksheet.getAllSubSparkline();
 
worksheet.unComposeSparkline([{ startRow: 9, endRow: 9, startColumn: 0, endColumn: 1 }]);
 
// After unCompose, there will be two sparklines here
const allSparklineAfterUnCompose = worksheet.getAllSubSparkline();
 
console.log('debugger', allSparklineBeforeUnCompose, allSparklineAfterUnCompose);