This section covers how to chart time series data using Integrated Charts.
Integrated Charts supports the charting of time series data using line and area charts when a time axis is chosen instead of a category or numeric axis.
A Time Axis is used to plot continuous date / time values, whereas a Category Axis is used to plot discrete values or categories.
The example below highlights the differences between time and category axes. Notice that the time axis contains all days for the range of values provided, whereas the category axis only shows axis labels for the discrete values provide.
Columns that contain date object values will be automatically plotted using a Time Axis
unless it has been explicitly changed through the chartDataType
column definition property.
Numeric timestamps in the Javascript format are also allowed, but the column should be explicitly configured to use a time axis
via chartDataType='time'
on the column definition.
The following snippet shows how different time series values can be configured to enable a time axis:
<ag-grid-vue
:columnDefs="columnDefs"
:rowData="rowData"
/* other grid options ... */>
</ag-grid-vue>
this.columnDefs = [
// date objects are treated as time by default
{ field: 'someDate' },
{ field: 'someTimestamp', chartDataType: 'time' },
];
this.rowData = [
{
someDate: new Date('Mon Apr 17 2023 12:43:17'), // date object
someTimestamp: 1681735397000, // numeric timestamp (Javascript format)
},
// ... more rows
];
Notice that no configuration is necessary for date objects but numeric timestamps and calendar date string require
that chartDataType='time'
is set on the column definitions.
The following example demonstrates how a column containing numeric timestamps can be configured to use a time axis using
the chartDataType='time'
property on the 'timestamp' column definition:
A time axis can also be used in combination charts as shown in the following example.
For more details on how to configure a combination chart, see the Range Chart API example.
Continue to the next section to learn about: Save / Restore Charts.