In Part-197 of the Laravel E-commerce series, we will start working on Laravel charts and graphs for reporting in the admin panel. There are many 3rd party charts and graphs available online that we can integrate into Laravel websites and we will use canvasjs that provide many types of graphs and charts including line chart, geo chart, bar chart, pie chart, area chart etc.
In this video, we will display a Line Chart/Graph for the users who registered in our Laravel E-commerce website in the current month, last month, and last to last month means we will compare the users for the last three months that will give us an idea of website traffic, progress, and rankings.
1) Create Route :-
First of all, create a GET route for displaying charts for users like below :-
// View Users Charts
Route::get('view-users-charts','UsersController@viewUsersCharts');
2) Create viewUsersCharts function :-
Now we will create the viewUsersCharts function in UsersController and return it to the view_users_charts blade file.
3) Create view_users_charts.blade.php file :-
We will create view_users_charts.blade.php file at path /resources/views/admin/users and copy the script from the canvasjs website to display static Line Chart from the below link :-
https://canvasjs.com/php-charts/line-...
Now, we will convert this static line chart to dynamic.
4) Update viewUsersCharts function :-
We will update the viewUsersCharts function in UsersController for finding the count for users for the current month, last month, and last to last month. And we will return these last 3 months' counts to the view_users_charts.blade.php file for comparison in line chart.
We will use Carbon class for finding current month data in Laravel and for finding last month's data, we will use subMonth with Carbon as shown in the video.
5) Update view_users_charts.blade.php file :-
We will update the view_users_charts.blade.php file to make it dynamic with users count of the current month, last month, and last to last month as shown in the video.
6) Update users.blade.php file :-
Lastly, we will update the users page to display the "View Reports / Chart" link with Users Heading.
Now check-in video, we are able to display the user reporting for the last three months in Laravel Line Chart.
Thanks for watching :)
Join this channel to get complete code/support :-
/ @stackdevelopers
Watch video Laravel 8 E-commerce | Laravel Charts, Graphs & Reports | Laravel Line Chart/Graph | Users Reporting online without registration, duration hours minute second in high quality. This video was added by user Stack Developers 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,983 once and liked it 38 people.