Show only every x-th label #10192
-
Hello, Is it possible to hide all labels and show only the first, the fifth, tenth, and so on? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
stockiNail
Feb 22, 2022
Replies: 1 comment 1 reply
-
@AndiLeni have a look to the sample: https://www.chartjs.org/docs/latest/samples/scale-options/ticks.html You should use 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',
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AndiLeni
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.