Wor*_*kkk 2 html javascript charts chart.js
我的图表上的 y 轴从 1 到 20(最小到最大),但我希望 y 轴从 20 到 1(最大到最小)从图表底部开始的最大数字并随着您而减少向上走直到到达最小值。我似乎找不到执行此操作的语法。我正在使用 chart.js 来做到这一点
<script>
var myChart = document.getElementById("myChart").getContext("2d");
var historyChart = new Chart(myChart, {
type:'line',
data:{
labels:['2012/13', '2013/14', '2014/15', '2015/16', '2016/17'],
datasets:[{
label: 'League Position',
fill: false,
lineTension: 0.1,
backgroundColor: "blue",
borderColor: "black",
borderCapStyle: 'butt',
data: [15, 11, 17, 13, 4]
}]
},
options:{
title: {
display: true,
text: 'League History'
},
scales: {
yAxes : [{
ticks : {
fontSize: 14,
max : 20,
min : 1,
stepSize: 1,
}
}],
xAxes : [{
ticks : {
fontSize: 14,
}
}]
}
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
对 yAxes 配置使用 reverse: true
yAxes: [
{
reverse: true, // will reverse the scale
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |