@univerjs-pro/sheets-chart-ui v0.5.4


Class: FChart

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:7

Constructors

new FChart()

new FChart(
   unitId, 
   subUnitId, 
   chartId, 
   injector): FChart

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:12

Parameters

ParameterType
unitIdstring
subUnitIdstring
chartIdstring
injectorInjector

Returns

FChart

Properties

PropertyTypeDefined in
chartIdstringpackages/sheets-chart-ui/src/facade/f-chart.ts:10
subUnitIdstringpackages/sheets-chart-ui/src/facade/f-chart.ts:9
unitIdstringpackages/sheets-chart-ui/src/facade/f-chart.ts:8

Methods

getCategoryData()

getCategoryData(): undefined | IChartDataCategory

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:115

Get the category data of the chart.

Returns

undefined | IChartDataCategory

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

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:19

Returns

string


getRange()

getRange(): undefined | ISheetChartSourceSingleRange

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:26

Get the range of the chart.

Returns

undefined | ISheetChartSourceSingleRange


getSeriesData()

getSeriesData(): undefined | IChartDataSeries[]

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:85

Get the series data list of the chart.

Returns

undefined | 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

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:127

Returns a new FChartBuilderBase instance that modifies this chart.

Returns

FChartBuilderBase

The new FChartBuilderBase instance.


updateRange()

updateRange(rangeInfo): Promise<boolean>

Defined in: packages/sheets-chart-ui/src/facade/f-chart.ts:56

Update the range info of the chart. The range info includes the range of the chart and the direction in source.

Parameters

ParameterTypeDescription
rangeInfoISheetChartSourceSingleRangeThe 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);
 }