We’re back again with new updates! Charts 4 PHP v2.0 has been released with more exciting features.
Here are few screenshots of charts generated with our v2.0 API.
For limited period, we’re providing free of cost update for customers bought within last 6 months.
Whats Next:
]]>
Step 1: Configure Database connectivity in config.php
‘
'.wch_stripslashes('define("CHARTPHP_DBTYPE","pdo"); define("CHARTPHP_DBHOST","mysql:host=localhost;dbname=testdb"); define("CHARTPHP_DBUSER","username"); define("CHARTPHP_DBPASS","password"); define("CHARTPHP_DBNAME",""); ').'
‘
Step 2: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 3: Configure Data array using jQuery to fetch data from Database
‘
'.wch_stripslashes('$p->data_sql = "select c.categoryname, sum(a.quantity) as Sales 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"; ').'
‘
Step 4: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "bar"; ').'
‘
Step 5: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
I. Creating first chart in Dashboard
Step 1: Configure Database connectivity in config.php
‘
'.wch_stripslashes('define("CHARTPHP_DBTYPE","pdo"); define("CHARTPHP_DBHOST","sqlite:../../sampledb/Northwind.db"); define("CHARTPHP_DBUSER",""); define("CHARTPHP_DBPASS",""); define("CHARTPHP_DBNAME",""); ').'
‘
Step 2: Include Charts 4 PHP Library in Dashboard HTML
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 3: Select any one of the substep below to configure Data Array
Step 3a: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array( array('Heavy Industry', 12), array('Retail', 9), array('Light Industry', 14), array('Out of home', 16), array('Commuting', 7), array('Orientation', 9))); ').'
‘
Step 3b: Configure Data array using jQuery to fetch data from Database (e.g. for SQLite DB)
‘
'.wch_stripslashes('$p->data_sql = "select c.categoryname, sum(a.UnitPrice * a.Quantity) as Sales 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"; ').'
‘
Step 4: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "pie"; ').'
‘
Step 5: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
This will give you a single chart in your dashboard something like this.
II. Creating multiple charts in your Dashboard
Step 1: Configure multiple charts into your Dashboard HTML
‘
'.wch_stripslashes('$p = new chartphp(); $p->data = array(array(array("2010/10",48.25),array("2011/01",238.75),array("2011/02",95.50),array("2011/03",300.50),array("2011/04",286.80),array("2011/05",400))); $p->chart_type = "bar"; $out_bar = $p->render('c2'); $p = new chartphp(); $p->data = array(array(array(60, 123, 1067, "Acura"), array(11, 92, 1236, "Alfa Romeo"), array(30, 200, 610, "AM General"), array(50, 23, 800, "Aston"), array(18, 17, 539, "Audi"), array(50, 89, 1026, "BMW"), array(99, 13, 864, "Bugatti"))); $p->chart_type = "bubble"; $out_bubble = $p->render('c3'); $p = new chartphp(); $p->intervals = array(200,300,400,600); $p->chart_type = "meter"; $p->width = "200px"; $p->height = "150px"; $p->data = array(array(rand(200,600))); $out_meter = $p->render('c4'); $p->data = array(array(rand(200,600))); $out_meter2 = $p->render('c41'); $p->data = array(array(rand(200,600))); $out_meter3 = $p->render('c42'); $p->data = array(array(rand(200,600))); $out_meter4 = $p->render('c43'); ').'
‘
Step 2: Render multiple charts in your dashboard to get the final look like this:
For complete code, please visit live demo.
]]>Step 1: Configure Database connectivity in config.php
‘
'.wch_stripslashes('define("CHARTPHP_DBTYPE","pdo"); define("CHARTPHP_DBHOST","mysql:host=localhost;dbname=testdb"); define("CHARTPHP_DBUSER","username"); define("CHARTPHP_DBPASS","password"); define("CHARTPHP_DBNAME",""); ').'
‘
Step 2: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 3: Configure Data array using jQuery to fetch data from Database
‘
'.wch_stripslashes('$p->data_sql = "select strftime('%Y-%m',o.orderdate) as Year, sum(d.quantity) as Sales from `order details` d, orders o where o.orderid = d.orderid group by strftime('%Y-%m',o.orderdate) limit 50"; ').'
‘
Step 4: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "line"; ').'
‘
Step 5: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array along with Intervals array
‘
'.wch_stripslashes('$p->data = array(array( array('Heavy Industry', 12), array('Retail', 9), array('Light Industry', 14), array('Out of home', 16), array('Commuting', 7), array('Orientation', 9) )); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "funnel"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array along with Intervals array
‘
'.wch_stripslashes('$p->data = array(array(266)); $p->intervals = array(200,300,400,600); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "meter"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array( array('Heavy Industry', 12), array('Retail', 9), array('Light Industry', 14), array('Out of home', 16), array('Commuting', 7), array('Orientation', 9) )); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "pie"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array(array('a',6), array('b',8), array('c',14), array('d',20))); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "donut"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array( array(11, 123, 1236, "Acura"), array(45, 92, 1067, "Alfa Romeo"), array(24, 104, 1176, "AM General"), array(50, 23, 610, "Aston Martin Lagonda"), array(18, 17, 539, "Audi"), array(7, 89, 864, "BMW"), array(2, 13, 1026, "Bugatti") )); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "bubble"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array( array("2010/10",48.25), array("2011/01",238.75), array("2011/02",95.50), array("2011/03",300.50), array("2011/04",286.80), array("2011/05",400) )); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "bar"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.
Step 1: Include Charts 4 PHP Library
‘
'.wch_stripslashes('include("../../lib/inc/chartphp_dist.php"); $p = new chartphp(); ').'
‘
Step 2: Configure Data array
‘
'.wch_stripslashes('$p->data = array(array(3,7,9,1,4,6,8,2,5),array(5,3,8,2,6,2,9,2,6)); ').'
‘
Step 3: Set Chart type
‘
'.wch_stripslashes('$p->chart_type = "area"; ').'
‘
Step 4: Render Chart
‘
'.wch_stripslashes('$out = $p->render("c1"); ').'
‘
For complete code, please visit live demo.