Chart.js-Radardiagramm
Ein Radar-Diagramm ist eine Möglichkeit, mehrere Datenpunkte und die Variationen zwischen ihnen anzuzeigen.
Ein Radar-Diagramm ist eine grafische Methode zur Darstellung multivariater Daten in Form eines zweidimensionalen Diagramms mit drei oder mehr quantitativen Variablen, die auf Achsen dargestellt werden, die vom selben Punkt ausgehen.
Die relative Position und der Winkel der Achsen sind üblicherweise nicht aussagekräftig.
Gemischtes DiagrammtypeDas Attribut istradar。
const config = {
type: 'radar',
data: data,
options: {
elements: {
line: {
borderWidth: 3 // 设置线条宽度
}
}
},
};
Als Nächstes erstellen wir ein einfaches Radar-Diagramm:
Beispiel
const ctx = document.getElementById('myChart');
const data = {
labels: [
'Essen',
'Trinken',
'Schlafen',
'Designen',
'Programmieren',
'Radfahren',
'Laufen'
],
datasets: [{
label: 'Erster Datensatz',
data: [65, 59, 90, 81, 56, 55, 40],
fill: true,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgb(255, 99, 132)',
pointBackgroundColor: 'rgb(255, 99, 132)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(255, 99, 132)'
}, {
label: 'Zweiter Datensatz',
data: [28, 48, 40, 19, 96, 27, 100],
fill: true,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgb(54, 162, 235)',
pointBackgroundColor: 'rgb(54, 162, 235)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(54, 162, 235)'
}]
};
const config = {
type: 'radar',
data: data,
options: {
responsive: true, // Diagramm responsiv machen, sodass es sich an den Bildschirm anpasst
maintainAspectRatio: false,// Ursprüngliches Seitenverhältnis des Diagramms beibehalten
Elemente: {
line: {
borderWidth: 3 // Setze die Linienbreite
}
}
}
};
const myChart = new Chart(ctx, config);
const data = {
labels: [
'Essen',
'Trinken',
'Schlafen',
'Designen',
'Programmieren',
'Radfahren',
'Laufen'
],
datasets: [{
label: 'Erster Datensatz',
data: [65, 59, 90, 81, 56, 55, 40],
fill: true,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgb(255, 99, 132)',
pointBackgroundColor: 'rgb(255, 99, 132)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(255, 99, 132)'
}, {
label: 'Zweiter Datensatz',
data: [28, 48, 40, 19, 96, 27, 100],
fill: true,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgb(54, 162, 235)',
pointBackgroundColor: 'rgb(54, 162, 235)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(54, 162, 235)'
}]
};
const config = {
type: 'radar',
data: data,
options: {
responsive: true, // Diagramm responsiv machen, sodass es sich an den Bildschirm anpasst
maintainAspectRatio: false,// Ursprüngliches Seitenverhältnis des Diagramms beibehalten
Elemente: {
line: {
borderWidth: 3 // Setze die Linienbreite
}
}
}
};
const myChart = new Chart(ctx, config);
Ausprobieren »
Die Ausgabe des obigen Beispiels ist:
Andere Erweiterungen