1
Chart.js沒有顯示圖例。我使用2.4.0版本,並且在我的網站中包含Chart.bundle.min.js
腳本。Chart.js沒有顯示圖例
定義了所有變量,如lineaRoja
,puntos
,MuPu
,並正確顯示數據。
問題是與Falla balanceada
,Mu y Pu aplicados
和Diagrama M-P
與他們各自的顏色沒有顯示的傳說。當我將鼠標懸停在點上時,只有工具提示顯示。
var canvas = document.getElementById(domId);
var ctx = canvas.getContext("2d");
var lineChart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Diagrama M-P',
data: puntos
}, {
label: 'Falla balanceada',
backgroundColor: 'rgba(0,0,0,0)',
borderColor: 'rgba(130,0,0,0.6)',
data: [{ x: 0, y: 0}, { x: lineaRoja[0], y: lineaRoja[1] }],
borderDash: [10, 5]
}, {
type: 'scatter',
data: MuPu,
fill: false,
showLine: false,
backgroundColor: 'rgba(0,130,0,0.6)',
label: 'Mu y Pu aplicados',
pointRadius: 6
}]
},
options: {
animation: { duration: 0 },
scales: {
xAxes: [{
type: 'linear',
position: 'bottom',
scaleLabel: {
display: true,
labelString: 'Ton'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Ton m'
},
ticks: {
min: 0,
beginAtZero: true
}
}]
}
}
});
yes我知道@loki但在這個答案沒有解釋。 –