Chart
| Packages | @univerjs-pro/sheets-chart |
|---|
The facade class for the chart.
This class should not be instantiated directly. Use factory methods on
univerAPIinstead.
Overview
@univerjs-pro/sheets-chart
| Method | Description |
|---|---|
chartId | - |
getCategoryData | Get the category data of the chart |
getChartId | Get the chart id |
getRange | Get the range of the chart |
getSeriesData | Get the series data list of the chart |
modify | Returns a new FChartBuilderBase instance that modifies this chart |
subUnitId | - |
unitId | - |
updateRange | Update the range info of the chart |
APIs
Data
getCategoryData
Get the category data of the chart.
Signature
getCategoryData(): IChartDataCategory | undefinedReturns
IChartDataCategory— The category data of the chart.
Examples
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const charts = fWorksheet.getCharts();
if (charts.length > 0){
const categoryData = charts[0].getCategoryData();
console.log(categoryData);
}@univerjs-pro/sheets-chart
getRange
Get the range of the chart.
Signature
getRange(): ISheetChartSourceSingleRange | undefinedReturns
any— The range of the chart.
Examples
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const charts = fWorksheet.getCharts();
console.log(charts[0]?.getRange());@univerjs-pro/sheets-chart
getSeriesData
Get the series data list of the chart.
Signature
getSeriesData(): IChartDataSeries[] | undefinedReturns
IChartDataSeries[]— The series data list of the chart.
Examples
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const charts = fWorksheet.getCharts();
if (charts.length > 0){
const seriesData = charts[0].getSeriesData();
console.log(seriesData);
}@univerjs-pro/sheets-chart
updateRange
Update the range info of the chart. The range info includes the range of the chart and the direction in source.
Signature
updateRange(rangeInfo: ISheetChartSourceSingleRange): Promise<boolean>Parameters
rangeInfoISheetChartSourceSingleRange— No description
Returns
Promise<boolean>— Whether the update is successful.
Examples
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// Get all charts on the active sheet.
const charts = fWorksheet.getCharts();
// Switch chart row direction
if (charts.length > 0){
const rangeInfo = { ...charts[0].getRange() };
rangeInfo.isRowDirection = !rangeInfo.isRowDirection;
charts[0].updateRange(rangeInfo);
}@univerjs-pro/sheets-chart
Modification
modify
Returns a new FChartBuilderBase instance that modifies this chart.
Signature
modify(): FChartBuilderBaseReturns
FChartBuilderBase— The new FChartBuilderBase instance.
@univerjs-pro/sheets-chart
Miscellaneous
chartId
Signature
chartId: stringReturns
string— See signature above.
@univerjs-pro/sheets-chart
getChartId
Get the chart id.
Signature
getChartId(): stringReturns
string— The chart id.
Examples
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const charts = fWorksheet.getCharts();
console.log(charts[0]?.getChartId());@univerjs-pro/sheets-chart
subUnitId
Signature
subUnitId: stringReturns
string— See signature above.
@univerjs-pro/sheets-chart
unitId
Signature
unitId: stringReturns
string— See signature above.
@univerjs-pro/sheets-chart