use*_*573 18 javascript chart.js
如果标签按天显示,那么有很多要点.所以,我想按月而不是按天显示标签.例如:

有人可以教我怎么做吗?
谢谢.
小智 7
只需将xAxes-> time属性配置为:
单位:“ month”
xAxes: [{
type: 'time',
position: 'bottom',
time: {
displayFormats: {'day': 'MM/YY'},
tooltipFormat: 'DD/MM/YY',
unit: 'month',
}
}],Run Code Online (Sandbox Code Playgroud)
小智 0
数组labels和data数组必须匹配。因此,您需要做的是计算要保存在数据数组中的值以匹配您的标签
data: {
labels: ["Jan", "Feb", "March", ...],
datasets: [{
label: '# of Votes',
data: [01, 02, 03, ...],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
...
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
...
],
borderWidth: 1
}]
},
Run Code Online (Sandbox Code Playgroud)
这能解决你的疑惑吗?
| 归档时间: |
|
| 查看次数: |
12226 次 |
| 最近记录: |