Class: FChart
The facade class for the chart.
Methods
getCategoryData()
getCategoryData(): any
Get the category data of the chart.
Returns
any
The category data of the chart.
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fSheet = fWorkbook.getActiveSheet();
const charts = fSheet.getCharts();
if (charts.length > 0){
const categoryData = charts[0].getCategoryData();
console.log(categoryData);
}
getChartId()
getChartId(): string
Get the chart id.
Returns
string
The chart id.
getRange()
getRange(): any
Get the range of the chart.
Returns
any
The range of the chart.
getSeriesData()
getSeriesData(): IChartDataSeries[]
Get the series data list of the chart.
Returns
IChartDataSeries
[]
The series data list of the chart.
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fSheet = fWorkbook.getActiveSheet();
const charts = fSheet.getCharts();
if (charts.length > 0){
const seriesData = charts[0].getSeriesData();
console.log(seriesData);
}
modify()
modify(): FChartBuilderBase
Returns a new FChartBuilderBase instance that modifies this chart.
Returns
The new FChartBuilderBase instance.
updateRange()
updateRange(rangeInfo): Promise<boolean>
Update the range info of the chart. The range info includes the range of the chart and the direction in source.
Parameters
Parameter | Type | Description |
---|---|---|
rangeInfo | ISheetChartSourceSingleRange | The new range of the chart. |
Returns
Promise
<boolean
>
Whether the update is successful.
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fSheet = fWorkbook.getActiveSheet();
const charts = fSheet.getCharts();
// switch chart row direction
if (charts.length > 0){
const rangeInfo = {...charts[0].getRange()}
rangeInfo.isRowDirection = !rangeInfo.isRowDirection;
charts[0].updateRange(rangeInfo);
}