[BUG] Wrong time unit chosen for labels (hours instead of date with hours)

I’m creating several charts, most with time axis, and I’ve noticed that chartjs has an odd way of picking it’s labeling. Generally the information on the x-Axis isn’t ideal for the data range. The following example is an example of a small dataset with data over 6 days plotted on an x-axis. The data labels produced are in the format of 12AM etc.

I understand that forcing a unit is one way to fix these, but we have zoom & pan plugins and want the data labels to be dynamic and select different labels based on the range of the x-axis.


Expected Behavior

The x-axis labels to suit the range.

Current Behavior

Time values i.e. 12AM/12PM mark days vs. the dates themselves i.e. 12-07-2017 etc.

Possible Solution

I’d be happy to hear suggestions as to additional ways to fix this that don’t include editing the source code. But if other people also experience the same issues, then maybe the code that picks the type of labels need to be refined?

Steps to Reproduce (for bugs)


Author: Fantashit

2 thoughts on “[BUG] Wrong time unit chosen for labels (hours instead of date with hours)

  1. 100%% agreed about this. I’d plan to fix it.

    The first step is adding proper time zone support so that we can understand where the boundry of a day is. And then I’ll tackle this next.

    I have a PR currently pending to add Luxon support to Chart.js which would be the pre-requisite since moment does not support time zones

Comments are closed.