I want to show each month's registered student count in the line chart. I got the result from the query but I can't understand how to pass the value in the line chart js file. Please help to fix this issue. I attached the codes and the screenshots for my output.
I want to pass the query output data count value into jQuery data: [0, 4, 9, 18, 21, 34, 20, 35, 45, 53, 49, 60],
app.js
(function ($) {
"use strict"; // Chart
if ($('#report-line-chart').length) {
var ctx = $('#report-line-chart')[0].getContext('2d');
var myChart = new chart_js__WEBPACK_IMPORTED_MODULE_1___default.a(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [{
label: '# of total',
data: [0, 4, 9, 18, 21, 34, 20, 35, 45, 53, 49, 60],
borderWidth: 2,
borderColor: '#3160D8',
backgroundColor: 'transparent',
pointBorderColor: 'transparent'
}]
},
options: {
legend: {
display: false
},
scales: {
xAxes: [{
ticks: {
fontSize: '12',
fontColor: '#777777'
},
gridLines: {
display: false
}
}],
yAxes: [{
ticks: {
fontSize: '12',
fontColor: '#777777',
callback: function callback(value, index, values) {
return value;
}
},
gridLines: {
color: '#D8D8D8',
zeroLineColor: '#D8D8D8',
borderDash: [2, 2],
zeroLineBorderDash: [2, 2],
drawBorder: false
}
}]
}
}
});
})($s);
My controller query
<?php
$arr["eachMonthRegister"] = DB::table('students')->select(DB::raw('count(id) as `data`'), DB::raw('YEAR(created_at) year, MONTH(created_at) month'))
->groupby('year','month')
->get();
return view('home')->with($arr);
?>
My query output

`brackets for paths and code fragments. Don't use too much bold font. ;)