js是否可以建立一个时间间隔?就我而言,使用堆叠条形图是我能得到的最接近的方法,但并不是我想要的
我想达到的是this时间间隔
这是密码
const data = {
labels: ['Mon', 'Tue', 'Wed' ],
datasets: [{
label: 'Bars',
data: [
[14, 16],
[17, 22],
[13, 19],
],
backgroundColor: [
'rgba(255, 26, 104, 0.2)',
],
borderColor: [
'rgba(255, 26, 104, 1)',
],
borderWidth: 2,
borderSkipped: false
}]
};
const config = {
type: 'bar',
data,
options: {
indexAxis: 'y',
scales: {
x: {
min: 12,
max: 26,
ticks: {
stepSize: 1,
callback: (val, index) => {
return `${String(val % 24).padStart(2, '0')}:00`
}
},
},
y: {
beginAtZero: true
}
}
}
};
const myChart = new Chart(
document.getElementById('myChart'),
config
);
1条答案
按热度按时间gab6jxml1#
您可以使用horizontalBar作为条形图类型。例如:
这里是result
我希望能帮到你。