Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ("../jpgraph.php"); //Sesuaikam dengan folder Anda
- include ("../jpgraph_bar.php"); //Sesuaikam dengan folder Anda
- $dbid = mysql_connect('host_Anda', 'username_Anda', 'password_Anda');
- mysql_select_db('database_Anda',$dbid)
- or die ("Cannot find database");
- $sql = mysql_query("SELECT * FROM data_grafik LIMIT 0,6");
- while($row = mysql_fetch_array($sql))
- {
- $data1[] = $row[0];
- $data2[] = $row[1];
- $data3[] = $row[2];
- }
- // We need some data
- $b1plot = new BarPlot($data1);
- $b2plot = new BarPlot($data2);
- $b3plot = new BarPlot($data3);
- // Setup the graph.
- $graph = new Graph(500,350,"auto");
- $graph->SetScale("textlin",0,20);
- $graph->img->SetMargin(25,85,25,25);
- $graph->SetBackgroundImage("bg.jpg",BGIMG_FILLPLOT); //"bg.jpg" bisa Anda ganti dengan background Anda.
- $graph->title->Set('"GRAFIK PERBANDINGAN JUMLAH PENDAFTAR PER-HARI"');
- $graph->title->SetColor('darkred');
- $graph->title->SetFont(FF_ARIAL);
- $graph->legend->Pos( 0.02,0.5,"right" ,"center");
- // Setup font for axis
- $graph->xaxis->SetFont(FF_ARIAL);
- $graph->yaxis->SetFont(FF_ARIAL);
- // Create the bar pot
- $b1plot->SetWidth(0.8);
- $b1plot->SetLegend("2006");
- $b2plot->SetWidth(0.8);
- $b2plot->SetLegend("2007");
- $b3plot->SetWidth(0.8);
- $b3plot->SetLegend("2008");
- // Setup values
- $b1plot->value->Show();
- $b1plot->value->SetFormat('%d');
- $b1plot->value->SetFont(FF_TIMES);
- $b1plot->value->SetColor("navy");
- $b2plot->value->Show();
- $b2plot->value->SetFormat('%d');
- $b2plot->value->SetFont(FF_TIMES);
- $b2plot->value->SetColor("olivedrab");
- $b3plot->value->Show();
- $b3plot->value->SetFormat('%d');
- $b3plot->value->SetFont(FF_TIMES);
- $b3plot->value->SetColor("orangered");
- // Setup color for gradient fill style
- $b1plot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
- $b2plot->SetFillGradient("olivedrab","olivedrab1",GRAD_WIDE_MIDVER);
- $b3plot->SetFillGradient("orangered","khaki",GRAD_WIDE_MIDVER);
- // Set color for the frame of each bar
- $b1plot->SetColor("navy");
- $b2plot->SetColor("olivedrab");
- $b3plot->SetColor("orangered");
- //create the grouped bar plot
- $gbplot = new GroupBarPlot (array($b1plot ,$b2plot ,$b3plot));
- $graph->Add($gbplot);
- // Finally send the graph to the browser
- $graph->Stroke();
- ?>
Add Comment
Please, Sign In to add comment