Skip to content

How can I reuse time on the y axis for different days on the x axis? #11710

Answered by alinnert
alinnert asked this question in Q&A
Discussion options

You must be logged in to vote

I figure it's a good idea to use a custom format. I did the following now:

new Chart(element, {
  /* ... */
  options: {
    scales: {
      x: {
        type: 'time',
        time: { unit: 'day' },
      },
      y: {
        type: 'linear',
        // The y axis uses numeric values between 0 and 24.
        // "3" represents "03:00", "5.75" represents "05:45" etc.
        min: 0,
        max: 24,
        ticks: {
          // `stepSize: 1` shows "00:00", "01:00", "02:00" etc.
          // `stepSize: 0.5` shows "00:00", "00:30", "01:00" etc.
          stepSize: 1,
          // This generates custom tick labels
          callback(tickValue) {
            if (typeof tickValue !== 'number' && 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alinnert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant