Jan 8, 2019
0
Level 1
Laravel Graph using Chartist JS
I'm using Chartist JS to create a graph for number of registered users against the registered month. Below is my code so far. I'm getting repeated months and it's not tallying with the number of users. So I need help. Thanks
Javascript
var chart = new Chartist.Line('.ct-chart1', {
labels: [
@foreach ($users as $user)
[ "{{ $user->created_at->format('M') }}"],
@endforeach
],
series: [
@foreach ($users as $user)
[ "{{ $user->count() }}"],
@endforeach
]
}, {
low: 0,
showLine: false,
});
Controller
public function getChart()
{
$users = User::All()->where('type', 'default');
return view('users.chart')->with('users', $users);
}
Please or to participate in this conversation.