One of the most popular simple JavaScript libraries for charts is Chart.js. Let's see how to use it in Laravel, with three practical examples: bar, line, and pie charts.
In this tutorial, we will create three charts based on "users" DB table:
- Bar chart of registered users per day, in the last 30 days
- Same chart just in "line" mode instead of "bar"
- We will add a
birth_date
field and build a "pie" chart of birthdays per season: winter/spring/summer/fall.
But before building those charts, we need to have some kind of visual layout, and the data in the DB to show on the charts, right?
Prepare Laravel Application
For this tutorial, we will use our own Laravel Breeze Skeleton that gives us a simple design.
Next, the database schema. We'll add a birth_date
field...