PHP Graph dengan JPGraph Chart

Membuat chart dengan data yang ada pada database MySQL menggunakan class JPGraph, berikut chart bar “Resource by Customer” dengan background image, warna bar dan value data dari database…

untuk melihat sampel-sampel chart JPGraph silahkan download source dan dokumentasinya

include “../db_connect.php”;
$result = mysql_query(‘select c.company_color,count(distinct pc.contact_id),c.company_short_name from projects p,companies c,project_contacts pc where p.project_status=3 and c.company_id=p.project_company and pc.project_id=p.project_id group by p.project_company’);

$x = 0;
while ($row = mysql_fetch_array($result)) {
if($x == 0){
$com .=$row[2];
$jml .=$row[1];
$cco .=$row[0].’@0.4′;
$com .= ‘,’.$row[2];
$jml .= ‘,’.$row[1];
$cco .= ‘,’.$row[0].’@0.4′;

//masukan $jml_pro kedalam array
$datay1 = explode(‘,’, $jml);
$color = explode(‘,’, $cco);
$compn = explode(‘,’, $com);

include (“../jpgraph.php”);
include (“../jpgraph_bar.php”);

// Create the basic graph
$graph = new Graph(500,350,’auto’);�

// Adjust the position of the legend box

// Adjust the color for theshadow of the legend

// Get localised version of the month names

// Set a 247 building (in segitigaemas) image

// Set axis titles and fonts




// Setup graph title
$graph->title->Set(‘Resource by Customer’);

// Some extra margin (from the top)

// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);

// Setup the colors with 40% transparency (alpha channel)

// Setup each bar with a shadow of 50% transparency
$gbarplot = new GroupBarPlot(array($bplot1));


berikut layout hasil script diatas:


About davidand

Hi, welcome to my blogs. My name is David Andriansyah. I am currently working as an independent Cognos Business Intelligence consultant, and I also as Freelance Web Developer. View all posts by davidand

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: