# 刻度配置
¥Tick Configuration
此示例演示如何使用不同的刻度功能来控制刻度标签在 X 轴上的显示方式。这些功能包括:
¥This sample shows how to use different tick features to control how tick labels are shown on the X axis. These features include:
多行标签
¥Multi-line labels
过滤标签
¥Filtering labels
更改刻度颜色
¥Changing the tick color
更改 X 轴的刻度对齐方式
¥Changing the tick alignment for the X axis
const config = { type: 'line', data: data, options: { responsive: true, plugins: { title: { display: true, text: 'Chart with Tick Configuration' } }, 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', } } } }, };
# 文档
¥Docs