I am new to ChartJS and due to server constraints I am using ChartJS 2.9.4 using cdnjs and I want to color the background of line chart from
- 60-80 ==> light grey with background text in right side as Significant with dotted lines
- 80-100 ==> dark grey with background text in right side as Severe
Currently it is like this: enter image description here
And the requirement is this: enter image description here
Below is the implemented code:
var ctx = document.getElementById("lineChart").getContext("2d");
var chart = new Chart(ctx, {
type: "line",
data: {
labels: [
"",
"Working Memory",
"Inhibitory Control",
"Cognitive Flexibility",
"High Order EF",
"",
],
datasets: [
{
label: "Competence score in Percent",
data: [null, 80, 65, 90, 75],
borderColor: ["#000", "#ffdb14", "#ff0000", "#38b7fe", "#8866f9"],
backgroundColor: [
"#000",
"#ffdb14",
"#ff0000",
"#38b7fe",
"#8866f9",
],
fill: false,
pointRadius: 16,
pointHoverRadius: 8,
pointBackgroundColor: [
"#000",
"#ffdb14",
"#ff0000",
"#38b7fe",
"#8866f9",
],
lineTension: 0,
borderColor: "#000",
borderWidth: 2,
},
],
},
options: {
responsive: true,
scales: {
xAxes: [
{
scaleLabel: {
display: true,
labelString: "Subtests",
fontSize: 24,
},
ticks: {
fontSize: 24,
},
},
],
yAxes: [
{
scaleLabel: {
display: true,
labelString: "Competence score in Percent",
fontSize: 24,
},
ticks: {
beginAtZero: true,
min: 0,
max: 100,
stepSize: 25,
fontSize: 24,
},
},
],
},
legend: {
display: false,
},
},
});