How To Create Bar Chart In Codeigniter With AmChart

How To Create Bar Chart In Codeigniter With AmChart

In this article, we will explain to you how to Create Bar Chart In Codeigniter using AmCharts. today we will fetch data into MySQL, and plot a bar graph.

There are many types of charts provide by AmCharts, like a bar chart, area chart, line chart, pie chart, etc. but here we use a bar chart.

We can easily integrate AmCharts with TypeScript, PHP, Angular, React. here In this article, we are using AmCharts version 3. so you can see below the following steps.

Overview

Step 1: Create a Database in table
Step 2: Connect to Database
Step 3: Create Controller
Step 4: Create View File

Step 1: Create Database in table
In this step, we have to create a table in the database, so we will create a database using the below code.

Step 2: Connect to Database
Go to the config folder and open database.php file some changes in this file like hostname, database username, database password, and database name.

Step 3: Create Controller
In this step, we will create an Amchart.php file in the “application/controller” directory and paste the below code in this controller. here we will fetch the last 10 months of data from the database and month-wise count login users. that data will be pass in an Amchart and creating bar graphs.
application/controller/Amchart.php

Step 4: Create View File
So finally, we will create the bar_chart.php file in the “application/views/” directory.
application/views/bar_chart.php

We think would you like this article, so you can click on the “Show Demo” button and you can see this demo article.

Show Demo

Please follow and like us: