我想添加新行,但我想在第三个x轴数据中添加。如果我在数据集中添加新数据,则总是从头开始(在我的数据中为一月)。我想要一条新的线路从三月到十二月开始,另一条线路从六月到十二月开始。let chart = new Chart(ctx, { type: 'line', data: { datasets: [{ label: 'First dataset', data: [0, 20, 40, 50, 0, 20, 40, 50, 0, 20, 40, 50] }], labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }, options: { scales: { yAxes: [{ ticks: { suggestedMin: 50, suggestedMax: 100 } }] } }});
1 回答

有只小跳蛙
TA贡献1824条经验 获得超8个赞
您需要设置口巫婆不想使用示例的默认值-0:
data: {
datasets: [{
label: 'First dataset',
data: [0, 20, 40, 50, 0, 20, 40, 50, 0, 20, 40, 50]
},
{
label: 'Second dataset',
data: [0, 0, 0, 0, 0, 20, 40, 50, 0, 20, 40, 50]
}],
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
},
我在这里建立了一个例子,我们可以使用数据值-null,它为此范围留出空白
添加回答
举报
0/150
提交
取消