React Data GridTime Series
react logo
Enterprise

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.

Time vs Category 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.

Time Axis Configuration

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:

const [columnDefs, setColumnDefs] = useState([
    // date objects are treated as time by default
    { field: 'someDate' },
    { field: 'someTimestamp', chartDataType: 'time' },
]);
const [rowData, setRowData] = useState([
    {
        someDate: new Date('Mon Apr 17 2023 12:43:17'), // date object
        someTimestamp: 1681735397000, // numeric timestamp (Javascript format)
    },
    // ... more rows
]);

<AgGridReact
    columnDefs={columnDefs}
    rowData={rowData}
/>

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:

Time Axis Combination Chart

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.

Next Up

Continue to the next section to learn about: Save / Restore Charts.