JPgraph in php question

i want to get the example for using JPgraph php 4 version
as i find many problems in the teaching example when i run it

i want to have an example to get the data from MySQL table
and output the data in line chart

thanks
ftpphptest1Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
here is a script using jpgraph
<?php
include ("../jpgraph/jpgraph.php");
include ("../jpgraph/jpgraph_pie.php"); 
$dbRef=mysql_connect("...","...","..."); 
// we will split by country as by the argument ($country) 
$country = @$_GET["country"];
$range_min = @$_GET["range_min"];
$range_max = @$_GET["range_max"]; 

if (!$range_min) { $range_min = 10000; }
if (!$range_max) { $range_max = 100000000; } 

$sql = "select at.name, count(*) c from account a join accounttype at on at.uuid = a.accounttypeid where at.name like ''$country%'' group by at.name order by at.name ";
$sql = "select name, sum(c) c from ( select case when c < $range_min then ''others'' else name end name, c from ( $sql ) ) group by name having sum(c) <= $range_max  "; 

$data = array();
$keys = array();
$labels = array(); 
if ($rows = mysql_query($query))
{
  while ($row = mysql_fetch_array($rows))
  {
    $keys[] = $row["NAME"];
    $data[] = $row["C"];
    $labels[] = $row["C"] . "\n(%.1d%%)";
  }
} 
// Create the Pie Graph. 
$graph = new PieGraph(600,300,"auto");
$graph->SetShadow(); 
// Set A title for the plot
if (!$country) { $country = 'All'; } 
$graph->title->Set("Account Types ($country)");
$graph->title->SetFont(FF_FONT1,FS_BOLD); 

// Create
$p1 = new PiePlot($data);
$p1->SetLegends($keys);
$p1->SetCenter(0.25,0.5); 
$p1->SetLabelType(PIE_VALUE_PER);
$p1->SetLabels($labels); 
$p1->ExplodeAll(5); 

$graph->Add($p1);
$graph->Stroke(); 
?>

Open in new window

0
 
Ionut A. TudorPHP ProgrammerCommented:
why using php 4 version ? I suggest you a better tool for graphs: http://www.maani.us/xml_charts/index.php?menu=Tutorial
0
 
ftpphptest1Author Commented:
i wanna a example which can show different element agianst time  in a pine chart ,
do u all have any example?

the data is from the table in MySQL
table element1
table element2 etc
thanks
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.