当轴位置居中时,ChartJS x 轴标题不可见
ChartJS x axis title not visible when axis position is centered
当位置不居中时,标题可见。
但是如果 x-axis 位置居中,标题就会消失。
这是我的 Chartjs options.The 文档似乎没有解决此问题的可行选项。
const options = {
maintainAspectRatio: false,
scales: {
x: {
type: 'linear',
min: 0,
max: MAX_AGE,
grid: {
display: false,
},
title: {
display: true,
text: 'xaxis title',
},
position: 'center', // what can I do to view the x-axis tile when axis is centered.
},
y: {
min: -10,
max: 10,
grid: {
display: false,
},
title: {
display: true,
text: 'yaxis title',
},
},
},
}
我假设您使用的 chart.js 版本低于 3.5,因为这是一个已在 3.5 版本中通过此 pr 解决的错误:https://github.com/chartjs/Chart.js/pull/9413
因此,要解决您的问题,您需要更新到最新版本的 chart.js
当位置不居中时,标题可见。
但是如果 x-axis 位置居中,标题就会消失。
这是我的 Chartjs options.The 文档似乎没有解决此问题的可行选项。
const options = {
maintainAspectRatio: false,
scales: {
x: {
type: 'linear',
min: 0,
max: MAX_AGE,
grid: {
display: false,
},
title: {
display: true,
text: 'xaxis title',
},
position: 'center', // what can I do to view the x-axis tile when axis is centered.
},
y: {
min: -10,
max: 10,
grid: {
display: false,
},
title: {
display: true,
text: 'yaxis title',
},
},
},
}
我假设您使用的 chart.js 版本低于 3.5,因为这是一个已在 3.5 版本中通过此 pr 解决的错误:https://github.com/chartjs/Chart.js/pull/9413
因此,要解决您的问题,您需要更新到最新版本的 chart.js