This is my first post so please apologize me if it's not that good.
This is my "area_chart.charts.php" where the Array is :
$data=array();
foreach ($result as $row) {
$chartDate = date("d/m", strtotime($row['created_at']));
$chartResultats = $row['traitements'];
$chart = array("chartResultats" => $chartResultats,"chartDate" => $chartDate);
array_push($data, $chart);
}
JSON Response: https://prnt.sc/1whxygm
I'm trying to retrieve the data to use it with Chart.JS using Ajax, but the way i'm doing it doesn't work. Do someone have an idea how to do it?
The result i want is :
chartResultats: [10, 30, 20]
chartDate: ["16/10", "16/10", "16/10"]
I tried to use Ajax like this :
$.ajax({
url:"./inc/charts/area_chart.charts.php",
method:"GET",
success:function(data) {
console.log(data);
chartResultats = data["chartResultats"];
chartDate = data["chartDate"];
// Area Chart
var ctx = document.getElementById("chartResultats");
var myLineChart = new Chart(ctx, {
type: 'line',
data: {
labels: [chartDate],
datasets: [{
data: [chartResulats],
}],
and Fetch but it didn't succeded. My chart is returning me underfined.
Can you please help me or clarify me? Thanks in advance!