Understanding difference between time and timeseries in Chart JS

In Chart.js we often have to draw charts with specific dates. If you are creating a stock market chart where your chart has data for the weekdays only you will have missing or static data the weekends and public holidays. This might be undesirable and you might want to remove those specific dates to keep the chart clean.

The video below will show you visually the difference between scale type time and timeseries.


Time in Chart JS

The type of time is this case not useful. As this will calculate the space based on the difference of the timeframe. For example if the next datapoint would be a week away from the current datapoint it will calculate 7 segments of space. This creates a big gap in our chart. See the gap in the x scales below.

Time in Chart JS

Time Series in Chart JS

Chart.js has a nice build in feature to answer this specific matter which is the time series. In it will set every date based on equidistant.

Equidistant in time series Chart JS

Equidistant is derived from the words ‘equal’ and ‘distant’. In other words, it will set every next datapoint on equal distant no matter the the timeframe between the years.

Time Series in Chart JS

Leave a comment

Your email address will not be published.