我不知道为什么我没有定义 x 轴上的正常分区名称 (100,200,300)。我已经在这个问题上苦苦挣扎了两天了。
链接:https ://codepen.io/kotbegemotest/pen/oNvGJXp
faValues = [];
raValues = [];
for(let i = 100; i<=20000; i+=100) {
faValues[i] = i;
}
for(let i = 100; i<=20000; i+=100) {
raValues[i] = Math.round(Math.pow(i, 2)/(Math.exp(i/500)-1))
}
let plotLineChart = document.getElementById('plotLineChart');
Chart.defaults.scale.ticks.beginAtZero = true
const data = {
labels: faValues,
datasets: [
{
label: 'T=500',
borderWidth: 2,
boderColor: 'blue',
pointBackgroundColor : 'blue',
backgroundColor: 'rgba(65,52,71,0.0)',
data: raValues
}
]
}
const lineChart = new Chart(plotLineChart,{
type: 'line',
data: data,
options : {
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: 'r',
fontSize: 32
}
}],
xAxes: [{
scaleLabel: {
display: true,
labelString: 'f',
fontSize: 32
}
}],
}
}
});
<canvas id="plotLineChart">
</canvas>

您无需指定密钥编号。试试这样:
在您的代码中,您将 i 以 100 的增量放入循环中,但计数器本身仍然遍历所有值,但这些值仅分配给数组的每 100 个元素。因此,所有其他的都是未定义的。
在第二个周期 - 相同。