[英]Chart.JS how to change order of y-axis
我图的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>
反向使用:对于yAxes配置为true
yAxes: [
{
reverse: true, // will reverse the scale
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.