PostgreSQL Dashboard

Build PostgreSQL Dashboard and generate PHP code with Dashboard Builder

PostgreSQL Database

Dashboard Builder is the easiest way to create a Line chart using PostgreSQL as database without any coding skills. Its a chart which displays information as a series of data points connected by straight line segments. Follow the following steps to build a Line chart using Dashboard Builder..

 

Requirements

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

 

Installation

 

Create your first Dashboard

 

 

{dglb}images/php-dashboard-screen1.png|images/php-dashboard-screen1.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;|Welcome Screen|Group1{/dglb}

 

  • Following screen will appear. Select Database from data source tab. Select PostgreSQL from the drop down list of Database, Enter your database credential and Save changes    as mentioned in the screen.

 

{dglb}images/postgresql-db-connection.png|images/postgresql-db-connection.png" width="40%" height="40%" style="display: block; margin-left: auto; margin-right: auto;| Select your Database|Group1{/dglb}

 

 

  • A green tick mark with Database  will appear when your database is successfully connected.

 

{dglb}images/php-dashboard-screen7.png|images/php-dashboard-screen7.png"  style="display: block; margin-left: auto; margin-right: auto;| Dashboard Preferece|Group1{/dglb}

 

  • Select the gear icon for your Dashboard preference.

 

{dglb}images/php-dashboard-screen8.png|images/php-dashboard-screen8.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;| Database Connected|Group1{/dglb}

 

  • The following screen will appear. List of the tables will appear.

 

{dglb}images/php-dashboard-screen8b.png|images/php-dashboard-screen8b.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;| Chart Preference |Group1{/dglb}

 

  • Enter your SQL statement in text box, SQL field as the following manner

SELECT strftime('%Y-%m',o.shippeddate) as xaxis, sum(d.quantity) as yaxis from `order details` d, orders o where o.orderid = d.orderid group by strftime('%Y-%m',o.orderdate) limit 50

  • Click the Run Query button

{dglb}images/php-dashboard-screen8c.png|images/php-dashboard-screen8c.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;| SQL Statement|Group1{/dglb}

 

  • Query Result will appear. Now Select your x-axis data from the drop down list of   and y-axis data from the drop down list of Y .
  • Click Save Changes

 

{dglb}images/php-dashboard-screen9.png|images/php-dashboard-screen9.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;| SQL Query Result|Group1{/dglb}

 

  • Charts will be appeared on the screen as shown below.

 

{dglb}images/php-dashboard-screen9b.png|images/php-dashboard-screen9b.png" width="60%" height="60%" style="display: block; margin-left: auto; margin-right: auto;| Chart Preference |Group1{/dglb}

 

  • Now extend the Generate button and click on the PHP Code

 

{dglb}images/php-dashboard-screen9c.png|images/php-dashboard-screen9c.png"  style="display: block; margin-left: auto; margin-right: auto;| Chart Preference |Group1{/dglb}

 

  • PHP code for the chart will automatically generate, you may copy past this code to your PHP application.

 

PHP Code


/**
 * DashboardBuilder
 *
 * @author Diginix Technologies www.diginixtech.com
 * Support  - http://www.dashboardbuilder.net
 * @copyright (C) 2018 Dashboardbuilder.net
 * @version 2.1.7
 * @license: license.txt
 */

include("inc/dashboard_dist.php");  // copy this file to inc folder 


// for chart #1
$data = new dashboardbuilder(); 
$data->type =  "line";

$data->source =  "Database"; 
$data->rdbms =  "pgsql"; 
$data->servername =  "your-servername";
$data->username =  "userid";
$data->password =  "password";
$data->dbname =  "your-db-name";
$data->xaxisSQL[0]=  "SELECT strftime(^%Y-%m^,o.shippeddate) as xaxis, sum(d.quantity) as yaxis from `order details` d, orders o  where o.orderid = d.orderid group by strftime(^%Y-%m^,o.orderdate) limit 50";
$data->xaxisCol[0]=  "xaxis";
$data->yaxisSQL[0]=  "SELECT strftime(^%Y-%m^,o.shippeddate) as xaxis, sum(d.quantity) as yaxis from `order details` d, orders o  where o.orderid = d.orderid group by strftime(^%Y-%m^,o.orderdate) limit 50";
$data->yaxisCol[0]=  "yaxis";
$data->name = "linechart";
$data->title = "Line Chart";
$data->orientation = "";
$data->xaxistitle = "x-axis title";
$data->yaxistitle = "y-axis title";
$result[0] = $data->result();

?>

<!DOCTYPE html>
<html> 
<head> 
	<script src="assets/js/dashboard.min.js"></script> <!-- copy this file to assets/js folder --> 
	<!--<link rel="stylesheet" href="assets/css/bootstrap.min.css"> Bootstrap CSS file, change the path accordingly --> 


</head>
<body> 

<div class="container">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading"></div>
    <div class="panel-body">
        <?php echo $result[0];?>
    </div>
</div>
</div>
</div>
</body>


 

 

The project also offers free and paid plans. The code for Dashboard Builder can be found on GitHub under this license