我目前正在使用Chart.js将我的数据显示为雷达图表。我面临的问题是,每次我向页面添加数据时,它都会将最大值设置为表中最高值。我需要它从0到100的Y轴开始。
我正在使用Chart.js v 2.1.2
以下是图表的图表和配置代码:
myRadar = new Chart(document.getElementById("canvas"), config);
var config = {
type: 'radar',
data: radarChartData,
options:
{
responsive: false,
maintainAspectRadio: true,
legend: {
position: 'top',
},
title: {
display: true,
text: 'Radar Chart'
},
scale: {
reverse: false,
ticks: {
beginAtZero: true,
},
pointLabels: {
callback: function (pointLabel) {
if (pointLabel.length > 10)
return pointLabel.substring(0, 10) + '...';
else
return pointLabel
}
}
},
scaleOverride: true,
scaleSteps: 5,
scaleStepWidth: 20,
scaleStartValue: 100,
}
};
答案 0 :(得分:1)
我在2.2.1上测试了这个,不确定你的版本是否有Min / Max。
ticks: {
max:100, // Set it to your Max value
min: 0, // You can also change the Min
beginAtZero: false, // in case you change the Min
}, // etc
文件:tick configuration
Codepen:Chart.js Radar Chart