Hello, I hope you are well I am new to this platform. I need some help.
I have 3 files: an HTML, PHP and JS file. In my PHP file, I have a variable of type array() containing 5 values, and this variable will be used to feed a graph. However I don't know how to reuse my variable in my PHP code to my JS code.
I thank you in advance for the answers you will bring me.
What I have tried:
Here is the variable in my PHP code:
$dataSignal = array($lqi_excellent, $lqi_good, $lqi_average, $lqi_limit, $lqi_na);
Here is my js code :
new Chart(document.getElementById("doughnut-chart"), {
type: 'doughnut',
data: {
labels: ["Excellent", "Good", "Average", "Limit", "N/A"],
datasets: [
{
backgroundColor: ["#27AE60", "#3498DB", "#F1C40F", "#E74C3C", "#17202A"],
data: [1,2,3,4,5] --> this is where I want to reuse my variable
}
]
},
options: {
plugins: {
legend: {
title: {
display: true,
text: 'Signal quality'
}
}
}
}
});