JPgraph in php question

Posted on 2009-02-23
Medium Priority
Last Modified: 2013-12-13
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

Question by:ftpphptest1
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 23710873
here is a script using jpgraph
include ("../jpgraph/jpgraph.php");
include ("../jpgraph/jpgraph_pie.php"); 
// 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");
// Set A title for the plot
if (!$country) { $country = 'All'; } 
$graph->title->Set("Account Types ($country)");

// Create
$p1 = new PiePlot($data);


Open in new window

LVL 14

Expert Comment

by:Ionut A. Tudor
ID: 23710898
why using php 4 version ? I suggest you a better tool for graphs: http://www.maani.us/xml_charts/index.php?menu=Tutorial

Author Comment

ID: 23711760
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question