I am trying to pass values to my graph in chartjs, this data comes from Mysql and Php, I attach the code:
Then I used Ajax to be able to reuse the code I send in Json format but I need that each line of my graphic is a respective "interface" and the data that I will show is "max_usage" and "week" that come from within the same array that has name the interface
Code PHP:
while($row = $result->fetch_assoc()){
if(!isset($data[$row["INTERFACE"]])){
$data[$row["INTERFACE"]] = array();
}
array_push($data[$row['INTERFACE']], $row);
}
}```
Code ajax.
``` function (data) {
let interfase = [];
for (let i in data){
interfase.push(i);
}
console.log(interfase);
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
data: {
labels: interfase,
datasets: [{
label: 'asdsa',
backgroundColor: 'transparent',
borderColor: 'rgb(255,237,58)',
steppedLine: true,
data: [12],
}]
},```