Skip to content

24 hour x scale #11253

Answered by stockiNail
mariuszgit asked this question in Q&A
Apr 25, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Let's assume you are using cartesian time scale.
You could set min and max and implement a ticks.callback to draw only the min and max:

    scales: {
      x: {
        type: 'time',
        min: '0:00',
        max: '24:00',
        time: {
          unit: 'hour',
          displayFormats: {
            hour: 'H:mm'
          },
        },
        ticks: {
          align: 'inner',
          callback(time) {
            if (time === this.min) {
              return this.format(time);
            } else if (time === this.max) {
              return '24:00'
            }
          }
        }
      }
    }

Here the codepen: https://codepen.io/stockinail/pen/vYVmWMb

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@mariuszgit
Comment options

@stockiNail
Comment options

@mariuszgit
Comment options

@stockiNail
Comment options

@mariuszgit
Comment options

Answer selected by mariuszgit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants