import { CreateRangeChartParams , FirstDataRenderedEvent , GridOptions } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'athlete' , width : 150 , chartDataType : 'category' } , { field : 'age' , chartDataType : 'category' , sort : 'asc' } , { field : 'sport' } , { field : 'year' , chartDataType : 'excluded' } , { field : 'gold' , chartDataType : 'series' } , { field : 'silver' , chartDataType : 'series' } , { field : 'bronze' } , ] , defaultColDef : { editable : true , sortable : true , flex : 1 , minWidth : 100 , filter : true , resizable : true , } , popupParent : document . body , enableRangeSelection : true , enableCharts : true , chartThemeOverrides : { common : { title : { enabled : true , text : 'Medals by Age' , } , legend : { position : 'bottom' , } , } , column : { axes : { category : { label : { rotation : 0 , } , } , } , } , } , onFirstDataRendered : onFirstDataRendered , } ; function onFirstDataRendered ( params ) { var createRangeChartParams = { cellRange : { rowStartIndex : 0 , rowEndIndex : 79 , columns : [ 'age' , 'gold' , 'silver' , 'bronze' ] , } , chartType : 'groupedColumn' , chartContainer : document . querySelector ( '#myChart' ) as any , aggFunc : 'sum' , } ; params . api . createRangeChart ( createRangeChartParams ) ; } document . addEventListener ( 'DOMContentLoaded' , function ( ) { var gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; fetch ( 'https://www.ag-grid.com/example-assets/wide-spread-of-sports.json' ) . then ( response => response . json ( ) ) . then ( function ( data ) { gridOptions . api ! . setRowData ( data ) ; } ) ; } ) ;