Charts - BETA
This section introduces the grid's integrated charting functionality that allows users to chart directly inside the grid and supports applications that want to create pre-defined charts.
The charting functionality is deeply integrated with the grid. This integration gives users a seamless charting experience while keeping the coding required by developers to a minimum.
We are not aware of any other datagrid that provides such integration. Other companies may provide a grid library and / or a charting library, but it's up to the developer to tie the two together.
This section introduces the two ways charts can be created from the data contained in the grid:
- User Created Charts: A user creates a chart using the grid's UI by selecting a range of cells and then selecting to chart via the context menu.
- Application Created Charts: The application requests the grid to create a chart through the grid's charting API.
To minimise bundle sizes for applications that do not require charting, charts are contained in a separate module, which can be imported as follows:
The charts module has been built from the ground up with zero dependencies on any third party libraries.
ag-grid-enterprise.jsalready contains the charting module.
To enable charting in the grid set the following grid option:
User Created Charts
User created charts are designed to provide an out-of-the box charting experience, similar to that found in spreadsheet applications such as Excel, but more compelling it will be integrated inside your applications.
Try it out on our demo page by doing the following:
- Select a Cell Range of numeric values in the grid by dragging the mouse over a range of cells.
- The bring up the Context Menu and select the desired chart type from the 'Chart Range' sub menu.
The animation above highlights a number of charting features. For more details on each feature follow the links provided below:
- Chart Ranges: When a chart is created, corresponding chart ranges appear in the grid and are adjusted via the chart range handle.
- Categories and Series: Columns can be configured as either categories or series for charting. If not configured then the grid will infer whether a column is category or series data.
- Chart Toolbar:
The chart toolbar is located in the top right area of the chart and brings
the user to UI components to perform the following:
- Change the chart type
- Change the colour palette
- Select categories and series columns
- Format the chart
- Download the chart
By default, user created charts are displayed inside the grid's own popup windows. The windows can be moved (by mouse dragging the windows title bar) and resized (by mouse dragging the windows borders).
It is also possible to display user created charts in an another location or application dialog. For more details see the section on providing a chart container.
popupParentso that the popup windows are not constrained to the bounds of the grid. Typically users set
popupParent=document.bodyto achieve this.
Application Created Charts
Charts can be pre-defined or dynamically created from within applications, and as with user created charts, these charts also benefit from the integration provided with the grid.
The dummy financial application below just touches on what is possible with the grid's integrated charting capabilities. The following should be noted:
- Pre-Defined Chart: A pre-defined chart is shown in a separate chart container below the grid.
- Dynamic Charts: Buttons positioned above the grid dynamically create different chart types.
- High Performance: 100 rows are randomly updated 10 times a second (1,000 updates per second). Try updating the example via plunker with higher update frequencies and more data.
To learn how to create charts in your applications see the following sections for details:
- Chart Range API: Used to create charts programmatically inside applications.
- Provide a Chart Container: Used to target chart containers inside the application instead of the popup window provided by the grid.
Before each chart is created, the developer can do fine grained Chart Customisation to change the charts appearance and behaviour. For example you can change the thickness of the lines, or customise the formatting of the axis labels.
The section Chart Customisation outlines all the items that can be customised for each chart type.
Continue to the next section to learn about: Chart Ranges.