datetime - 我如何在chartjs图表上显示我的自定义(日-月-年时:分:秒)时间格式?
问题描述
我想在chartjs图表上显示我的自定义(日-月-年小时:分钟:秒->例如:01-05-2019 14:06:47 PM)时间格式
我如何在图表xAxis日期格式上显示这样>>
Day-Month-Year Hour:Min:Sec -->ex: 01-05-2019 14:06:47 PM
时间格式是timeFormat = 'DD/MM/YYYY h:mm:ss a'
但在图表上仅显示月、日、年
这是我下面的代码,并且:
在线代码在 >>> https://codepen.io/sibche2013/pen/XQWWbb
var timeFormat = 'DD/MM/YYYY h:mm:ss a';
var config = {
type: 'line',
data: {
datasets: [
{
label: "UK Dates",
data: [{
x: "01-04-2014 02:15:50", y: 175
}, {
x: "12-04-2014 12:19:27", y: 177
}, {
x: "23-04-2014 22:25:47", y: 178
}, {
x: "28-04-2014 14:46:40", y: 182
}],
fill: false,
borderColor: 'blue'
}
]
},
options: {
responsive: true,
title: {
display: true,
text: "Chart.js Time Scale"
},
scales: {
xAxes: [{
type: "time",
time: {
format: timeFormat,
tooltipFormat: 'll'
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'value'
}
}]
}
}
};
window.onload = function () {
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx, config);
};
解决方案
推荐阅读
- javascript - Discord.js SQLITE_ERROR:表分数没有名为点的列
- tensorflow - Compute Capability 3.0 卡可以运行 Tensorflow 1.8 tensorflow-gpu 运行时吗?
- regex - 使用正则表达式从字符串中提取文件名
- django - 如何在 Django 中将 URL 限制为管理员用户
- javascript - 边距:0 自动;用搜索隐藏另一个 li 元素后
- python - 日历项目没有正确缩进和间距 Python 3
- highcharts - 如何从 Highcharts 中删除注释?
- html - 将图像固定在另一个图像之上(响应式)?
- javascript - 让 getStream (stream.io) 在 Angular 应用程序中工作
- sharepoint - 如何获取最近访问的 OneDrive for Business 文件?