我在 bootstrap-vue 上使用 chart.js 和 chartjs-plugin-zoom:
- “chart.js”:“^2.9.4”
- “chartjs-plugin-zoom”:“^0.7.7”
绘制图表时,格式正确显示 'HH:mm': ok 使用缩放后,格式被清除为 'hh:mm a' 并重置比例尺: 不正常 我怎样才能避免这种情况或我做错了什么?
chart.js 的代码选项:
options: {
type: 'line',
data: {
datasets: [{
label: 'Error counts',
data: [],
fill: false,
borderColor: 'rgb(192,25,22)',
tension: 0.1
}]
},
options: {
responsive: false,
legend: {
display: false
},
title: {
display: true,
text: 'Error per minute'
},
scales: {
xAxes: [{
type: "time",
ticks: {
source: 'data',
autoSkip: true,
autoSkipPadding: 10,
maxRotation: 0
},
time: {
unit: 'minute',
stepSize: "1",
tooltipFormat: 'HH:mm',
displayFormats: {
millisecond: 'HH:mm',
second: 'HH:mm',
minute: 'HH:mm',
hour: 'HH:mm'
}
}
}]
},
plugins: {
zoom: {
zoom: {
animation: {
duration: 0
},
enabled: true,
mode: 'x',
drag: true,
threshold: 10
}
}
}
}
}