Creating a Bar Chart using PHP

Creating a Bar Chart using PHP

This article will show how to create a simple bar chart using Charts 4 PHP Framework.

Step 1: Include Charts 4 PHP Library

include("../../lib/inc/chartphp_dist.php");
$p = new chartphp();

Step 2: Configure Data array

$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

$p->chart_type = "bar";

Step 4: Render Chart

$out = $p->render("c1");

For complete code, please visit live demo.