我正在尝试在下面链接的雷达图上设置背景样式,并且希望能够
我认为这必须通过“选项”来完成(因为这与数据集无关),但我对JS的掌握不足,无法在尝试几个小时后使它起作用。
Codepen here Chart JS radar instructions here
new Chart(document.getElementById("radar-chart"), {
type: 'radar',
data: {
labels: ["Business", "Brand", "Marketing", "Stakeholders", "Clients"],
datasets: [
{
label: "",
fill: true,
backgroundColor: "rgba(255,99,132,0.2)",
borderColor: "rgba(255,99,132,1)",
pointBorderColor: "#fff",
pointBackgroundColor: "rgba(255,99,132,1)",
pointBorderColor: "#fff",
data: [25.48,54.16,7.61,8.06,4.45]
}
]
},
options: {
legend: {
display: false
},
borderWidth: 10,
}
});
答案 0 :(得分:1)
为了获得所需的内容,可以在ticks
内定义gridLines
,pointLabels
和options.scale
。
new Chart(document.getElementById("radar-chart"), {
type: 'radar',
data: {
labels: ["Business", "Brand", "Marketing", "Stakeholders", "Clients"],
datasets: [{
data: [25.48, 54.16, 7.61, 8.06, 4.45],
fill: true,
backgroundColor: "rgba(255,99,132,0.2)",
borderColor: "rgba(255,99,132,1)",
pointBorderColor: "#fff",
pointBackgroundColor: "rgba(255,99,132,1)"
}]
},
options: {
legend: {
display: false
},
borderWidth: 10,
scale: {
ticks: {
fontSize: 18,
max: 100
},
gridLines: {
lineWidth: 2,
color: "lightgreen"
},
pointLabels: {
fontSize: 18,
fontStyle: "bold"
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.js"></script>
<canvas id="radar-chart" height="200"></canvas>