Skip to content

Show only every x-th label #10192

Answered by stockiNail
AndiLeni asked this question in Q&A
Feb 22, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@AndiLeni have a look to the sample: https://www.chartjs.org/docs/latest/samples/scale-options/ticks.html

You should use ticks.callback to configure in x scale options.

    scales: {
      x: {
        ticks: {
          // For a category axis, the val is the index so the lookup via getLabelForValue is needed
          callback: function(val, index) {
            // Hide every 2nd tick label
            return index % 2 === 0 ? this.getLabelForValue(val) : '';
          },
          color: 'red',
        }
      }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AndiLeni
Comment options

Answer selected by AndiLeni
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