我在农业网格上启用了分组功能,当我基于该网格创建图表时,出现以下错误
ERROR TypeError: Cannot read property 'colId' of undefined
at ChartModel.push../node_modules/ag-grid-enterprise/dist/lib/chartAdaptor/chartComp/chartModel.js.ChartModel.getSelectedDimensionId (chartModel.js:211)
at ChartModel.push../node_modules/ag-grid-enterprise/dist/lib/chartAdaptor/chartComp/chartModel.js.ChartModel.updateData (chartModel.js:54)
at ChartController.push../node_modules/ag-grid-enterprise/dist/lib/chartAdaptor/chartComp/chartController.js.ChartController.updateForGridChange (chartController.js:53)
at ChartController.push../node_modules/ag-grid-enterprise/dist/lib/chartAdaptor/chartComp/chartController.js.ChartController.init (chartController.js:37)
at context.js:209
at Array.forEach (<anonymous>)
at context.js:209
at Context.push../node_modules/ag-grid-community/dist/lib/context/context.js.Context.forEachMetaDataInHierarchy (context.js:158)
at context.js:204
at Array.forEach (<anonymous>)
这是组列定义
let firstColumn = {
headerName: 'Range',
field: 'reportParameter1',
sortable: true,
resizable: true,
cellClass: 'textFormatter',
rowGroup: true,
hide: true
};
这是ag网格html内容
"<ag-grid-angular #agGrid style="width:100%;" id="cpd-by-state-grid" class="ag-theme-material"
[columnDefs]="columnDefs" [rowData]="rowData" [defaultColDef]="defaultColDef" [enableRangeSelection]="true"
[enableCharts]="true" (gridReady)="onGridReady($event)" [floatingFilter]="true" [enableCharts]="true"
[sideBar]="true" [getRowStyle]="getRowStyle" (sortChanged)="onSortChanged()" (filterChanged)="onFilterChanged()"
[pagination]="true" [paginationPageSize]="paginationPageSize" [processChartOptions]="processChartOptions"
[pinnedBottomRowData]="pinnedBottomRowData" [excelStyles]="excelStyles" [autoGroupColumnDef]="autoGroupColumnDef"
[groupDefaultExpanded]="-1"></ag-grid-angular>"
下面是创建图表方法
createChart(chartType: string, lastRowIndex: number, gridApi: any) {
let cellRange = {
rowStartIndex: 0,
rowEndIndex: lastRowIndex,
columns: ['reportParameter1', 'field1', 'field2', 'field3']
};
let chartRangeParams = {
cellRange: cellRange,
chartType: chartType
};
gridApi.chartRange(chartRangeParams);
}