i'm drawing a pie chart but since the difference of value of each data is too big, (one too big amount and others too small amount) , the value of the small amount is being overlapped over each other.
how can i fix this?
i'm drawing a pie chart but since the difference of value of each data is too big, (one too big amount and others too small amount) , the value of the small amount is being overlapped over each other.
how can i fix this?
Hi,
please post the some code.
Thomas
Originally posted by tsinka
Hi,
please post the some code.
Thomas
hi,
here's the code::p
<?php
include ("/usr/local/lib/php/jpgraph/jpgraph.php");
include ("/usr/local/lib/php/jpgraph/jpgraph_pie.php");
include ("/usr/local/lib/php/jpgraph/jpgraph_pie3d.php");
$today=date("Y-m-d"); // today's date
$yesterday=date("Y-m-d", strtotime("-1 day")); // yesterday's date
$current_year=date("Y");
$current_mth=date("n");
/*******************/
/* DB Settings */
/*******************/
$ServerName = "localhost"; # mysql hostname
$UserName = "myname"; # mysql account
$PassWd = "mypasswd"; # mysql pw
$DBName = "mydb"; # mysql database name
/***************************************/
/* GET parameters */
/***************************************/
$date=$_GET["date"];
/**************************************/
/* SQL QUERY */
/**************************************/
$con = mysql_connect($ServerName,$UserName,$PassWd);
mysql_select_db($DBName,$con);
$sql = "SELECT type, SUM(amount) as `amt`
FROM table_of_type
GROUP BY type";
$list = mysql_query($sql, $con);
//print $sql;
while($row = mysql_fetch_array($list)){
$data[]=abs(round($row[sum_amount])); //cnt
$leg[]=$row[account_nm]; //account_nm
}
/**************/
/* GRAPH */
/**************/
/* ------------------ */
/* Creating Pie Graph */
/* ------------------ */
$graph = new PieGraph(480,300,"auto");
$graph->SetShadow();
$graph->title->Set("Sum of each type on ".$date);
$graph->title->SetFont(FF_ARIAL,FS_BOLD);
/* ------------------ */
/* Plotting */
/* ------------------ */
$p1 = new PiePlot3D($data);
$p1->SetTheme("sand");
$p1->SetSize(.3);
$p1->SetCenter(0.35);
$p1->SetStartAngle(20);
$p1->SetAngle(85);
$p1->SetLegends($leg);
$p1->value->SetFont(FF_ARIAL,FS_BOLD);
$p1->value->SetColor("darkred");
$p1->SetLabelType(PIE_VALUE_PER);
$a = array_search(max($data),$data); //Find the position of maixum value.
$p1->ExplodeSlice($a);
$graph->Add($p1);
$graph->Stroke();
?>
This displays a pie graph but when the value of each data is too different between each other, the value displayed overlapped each other.
I wonder whether we can specify where to place the value.
thanks