winzip icon

How to create a chart in PHP without writing a PHP code

Submitted on: 11/6/2019 8:50:01 AM
By: George Lewis  
Level: Beginner
User Rating: Unrated
Compatibility: PHP 6.0, PHP 7.0, PHP 8.0
Views: 1606


The purpose of this document is to create a chart in PHP without writing a single code in PHP. This guideline describes how to use Dashboard Builder and generate PHP code for your dashboard without programming.

By the end of this guideline you would be able to create a combination chart with a PHP source code by following the following steps.


  • PHP Version 5.6 or later
  • Apache 2 or later
  • Windows 7 or later /Linux 3 or later
  • Firefox 52, Chrome 57, IE 8

Step 1: Download the file

Download and and place the file in a directory on the web server. e.g. …/www/dashboar/dbuilder/. Unzip the file using Extract Here option to the root folder of "dashboardbuilder".

If you have any problem then you may directly download thie file from Direct Download

Step 2: Retrive data from a database

  • Run the web folder in your browser. e.g. http://localhost/dashboardbuilder
  • Now Click the Database icon
  • Select Database from data source tab. Select SQLite from the drop down list of Database, Enter your "../data/Northwind.db" in the DB name field. Northwind.db is encluded in the zip file.
  • Save your changes
  • A green tick mark with Database will appear when your database is successfully connected

Step 3: Customize your chart

  • Select the gear icon for your Dashboard preference. A List of the tables will appear.
  • Enter your SQL statement in text box, SQL field as the following manner or just click on snakey tabel
  • select c.categoryname, sum(a.quantity) as 'Sales 1997', sum(a.quantity)+1000 as 'Sales 1998' from products b, `Order Details` a, categories c where a.productid = b.productid and c.categoryid = b.categoryid group by c.categoryid order by c.categoryid;
  • Click the Run Query button
  • Query Result will appear. Select "Bar" as Chart Type for Trace 1. Select your CategoryName from the drop down list of X and Sales-1997 from the drop down list of Y .
  • Now, click to add Trace 2. Select "Line" from the drop down list of Type for Trace 2. Select your CategoryName from the drop down list of X and Sales-1998 from the drop down list of Y .
  • Click Save Changes

Combination Chart will be appeared on the screen

Step 4: Generate PHP source code for your chart

Now extend the Generate button and click on the PHP Code. PHP code for the chart will automatically generate, you may copy past this code to your PHP application.

A complete guideline can be found at here

winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

12/3/2019 2:02:47 AMHanzel

Hi, can you Provide for the Source Code for Print that Chart, too?

(If this comment was disrespectful, please report it.)

1/8/2020 8:47:59 AMGeorge Lewis

Hi Hanzel,

There is no such option available to send the chart directly to the printer. However, the charts are downloadable in PNG format.
(If this comment was disrespectful, please report it.)


Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.