【发布时间】:2019-06-27 11:53:28
【问题描述】:
由于某种原因,我图表的 xAxes 从最新数据到最旧日期。我显然想要相反/正常的方式。如何还原 xAxes? .. 或者只是 xAxes 与日期正常运行。
我的图表在这里:https://www.betscout.com/tips(点击统计标签) 我已经尝试过这个选项:https://jsfiddle.net/marineboudeau/4awme3fp/3 - 但它不起作用,即使在提供的示例中也不行(当我将 reverse: true 替换为 reverse: false 时没有任何变化。)
我可以通过这种方式轻松地反转 yAxes,那么为什么不使用 xAxes?
这是我的一些 JS 代码:
let chart = document.getElementById('chart');
let myLineChart = new Chart(chart, {
type: 'line',
data: {
labels: grades,
datasets: [{
data: numbers,
label: 'Total profit',
fill: false,
borderColor: '#3771a3'
}]
},
options: {
scales: {
yAxes: [{
gridLines: {
display: true,
color: "rgba(55, 113, 163, 0.18)"
},
ticks: {
beginAtZero: true,
}
}],
xAxes: [{
gridLines: {
display: true,
color: "rgba(55, 113, 163, 0.18)"
},
ticks: {
display: true,
reverse: true,
fontSize: 12
}
}]
}
}
});
}
【问题讨论】:
标签: javascript chart.js