类: FChart
The facade class for the chart.
方法
getCategoryData()
getCategoryData(): any
Get the category data of the chart.
返回
any
The category data of the chart.
示例
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.
返回
string
The chart id.
getRange()
getRange(): any
Get the range of the chart.
返回
any
The range of the chart.
getSeriesData()
getSeriesData(): IChartDataSeries[]
Get the series data list of the chart.
返回
IChartDataSeries
[]
The series data list of the chart.
示例
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.
返回
FChartBuilderBase
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.
参数
参数 | 类型 | 描述 |
---|---|---|
rangeInfo | ISheetChartSourceSingleRange | The new range of the chart. |
返回
Promise
<boolean
>
Whether the update is successful.
示例
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);
}