我在下面有这张图表,我想用TIME来缩放Y轴(时间不是一天中的时间,它是总小时,分钟,秒,所以可能超过24小时)似乎无法让它工作,我得到的只是一个空白屏幕,确定它是一个语法错误,但无法发现它!谢谢将Chart.JS的Y轴格式化为时间
var ctx = document.getElementById("myChart3").getContext('2d');
var myChart3 = new Chart(ctx, {
type: 'line',
data: {
labels: ["2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017"],
datasets: [
{
label: "Time",
backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850", "#565452", "#321456", "#129864", "#326812", "#215984"],
data: ["11:46:07", "11:41:14", "11:55:26", "12:14:58", "11:54:55", "11:54:04", "12:28:29", "12:35:18"]
}
]
},
options: {
scales: {
yAxes: [{
type: 'time',
time: {
displayFormats: {
minutes: 'h:mm:ss a'
}
}
}]
}
}
});
你使用'moment.js'吗? –
不,我不是,但现在已经添加它,仍然无法正常工作。我可以将DATA作为秒数,但希望图表将时间显示为H:mm:ss –