• Open in:

Date Based Data

The most common type of chart is some column or line chart where the Y axis represents numeric values and the X axis is some sequence of discreet values (often referred to as “categories”). The categories can also be some string representations of dates but they are actually just plain strings as far as the chart’s smarts are concerned. A proper way to display date-based data is using a date-aware X axis which can handle displaying different labels (days, months, years) based on the amount of data, zoom level, etc., as well as handle different data granularity (eg. no data on some days). All of this is handled automatically by amCharts XY chart.

Key implementation details

All you need to do for proper date handling in the XY chart is create a DateAxis as your X axis. You can adjust its behavior by setting axis’ baseInterval and other options. Depending on the data types on your data you may need to pre-process it so the dates are handled as expected.

Related tutorials

Demo source