forked from halo-battle/game
Upgrade jpgrah to 4.3.4
This commit is contained in:
parent
7c3999c5cd
commit
b5868f05f6
72 changed files with 19157 additions and 10327 deletions
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
/*=======================================================================
|
||||
// File: JPGRAPH_PIE.PHP
|
||||
// Description: Pie plot extension for JpGraph
|
||||
// Created: 2001-02-14
|
||||
// Ver: $Id: jpgraph_pie.php 1006 2008-06-09 22:32:05Z ljp $
|
||||
//
|
||||
// Copyright (c) Aditus Consulting. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
// File: JPGRAPH_PIE.PHP
|
||||
// Description: Pie plot extension for JpGraph
|
||||
// Created: 2001-02-14
|
||||
// Ver: $Id: jpgraph_pie.php 1926 2010-01-11 16:33:07Z ljp $
|
||||
//
|
||||
// Copyright (c) Asial Corporation. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
|
||||
|
||||
// Defines for PiePlot::SetLabelType()
|
||||
DEFINE("PIE_VALUE_ABS", 1);
|
||||
DEFINE("PIE_VALUE_PER", 0);
|
||||
DEFINE("PIE_VALUE_PERCENTAGE", 0);
|
||||
DEFINE("PIE_VALUE_ADJPERCENTAGE", 2);
|
||||
DEFINE("PIE_VALUE_ADJPER", 2);
|
||||
define("PIE_VALUE_ABS", 1);
|
||||
define("PIE_VALUE_PER", 0);
|
||||
define("PIE_VALUE_PERCENTAGE", 0);
|
||||
define("PIE_VALUE_ADJPERCENTAGE", 2);
|
||||
define("PIE_VALUE_ADJPER", 2);
|
||||
|
||||
//===================================================
|
||||
// CLASS PiePlot
|
||||
|
|
@ -25,6 +25,9 @@ class PiePlot
|
|||
{
|
||||
public $posx=0.5;
|
||||
public $posy=0.5;
|
||||
public $is_using_plot_theme = false;
|
||||
public $theme="earth";
|
||||
protected $use_plot_theme_colors = false;
|
||||
protected $radius=0.3;
|
||||
protected $explode_radius=array();
|
||||
protected $explode_all=false;
|
||||
|
|
@ -33,8 +36,8 @@ class PiePlot
|
|||
protected $legends=null;
|
||||
protected $csimtargets=null;
|
||||
protected $csimwintargets=null; // Array of targets for CSIM
|
||||
protected $csimareas=''; // Generated CSIM text
|
||||
protected $csimalts=null; // ALT tags for corresponding target
|
||||
protected $csimareas=''; // Generated CSIM text
|
||||
protected $csimalts=null; // ALT tags for corresponding target
|
||||
protected $data=null;
|
||||
public $title;
|
||||
protected $startangle=0;
|
||||
|
|
@ -43,11 +46,10 @@ class PiePlot
|
|||
protected $legend_margin=6;
|
||||
protected $show_labels=true;
|
||||
protected $themearr = array(
|
||||
"earth" => array(136,34,40,45,46,62,63,134,74,10,120,136,141,168,180,77,209,218,346,395,89,430),
|
||||
"pastel" => array(27,415,128,59,66,79,105,110,42,147,152,230,236,240,331,337,405,38),
|
||||
"water" => array(8,370,24,40,335,56,213,237,268,14,326,387,10,388),
|
||||
"sand" => array(27,168,34,170,19,50,65,72,131,209,46,393));
|
||||
protected $theme="earth";
|
||||
"earth" => array(136,34,40,45,46,62,63,134,74,10,120,136,141,168,180,77,209,218,346,395,89,430),
|
||||
"pastel" => array(27,415,128,59,66,79,105,110,42,147,152,230,236,240,331,337,405,38),
|
||||
"water" => array(8,370,24,40,335,56,213,237,268,14,326,387,10,388),
|
||||
"sand" => array(27,168,34,170,19,50,65,72,131,209,46,393));
|
||||
protected $setslicecolors=array();
|
||||
protected $labeltype=0; // Default to percentage
|
||||
protected $pie_border=true;
|
||||
|
|
@ -67,14 +69,14 @@ class PiePlot
|
|||
protected $iGuideVFactor=1.4;
|
||||
protected $iGuideLineRFactor=0.8;
|
||||
protected $la = array(); // Holds the exact angle for each label
|
||||
|
||||
|
||||
//---------------
|
||||
// CONSTRUCTOR
|
||||
public function PiePlot($data)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = array_reverse($data);
|
||||
$this->title = new Text("");
|
||||
$this->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
$this->title->SetFont(FF_DEFAULT, FS_BOLD);
|
||||
$this->value = new DisplayValue();
|
||||
$this->value->Show();
|
||||
$this->value->SetFormat('%.1f%%');
|
||||
|
|
@ -108,12 +110,12 @@ class PiePlot
|
|||
{
|
||||
$this->color = $aColor;
|
||||
}
|
||||
|
||||
|
||||
public function SetSliceColors($aColors)
|
||||
{
|
||||
$this->setslicecolors = $aColors;
|
||||
}
|
||||
|
||||
|
||||
public function SetShadow($aColor='darkgray', $aDropWidth=4)
|
||||
{
|
||||
$this->ishadowcolor = $aColor;
|
||||
|
|
@ -130,7 +132,7 @@ class PiePlot
|
|||
$this->csimalts=array_reverse($aAlts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GetCSIMareas()
|
||||
{
|
||||
return $this->csimareas;
|
||||
|
|
@ -165,7 +167,7 @@ class PiePlot
|
|||
$xp = floor(($radius*cos($ea))+$xc);
|
||||
$yp = floor($yc-$radius*sin($ea));
|
||||
$coords.= ", $xp, $yp";
|
||||
|
||||
|
||||
//add coordinates every 0.2 radians
|
||||
$a=$ea+0.2;
|
||||
|
||||
|
|
@ -188,7 +190,7 @@ class PiePlot
|
|||
$coords.= ", $xp, $yp";
|
||||
$a += 0.2;
|
||||
}
|
||||
|
||||
|
||||
//Add the last point on the arc
|
||||
$xp = floor($radius*cos($sa)+$xc);
|
||||
$yp = floor($yc-$radius*sin($sa));
|
||||
|
|
@ -207,16 +209,20 @@ class PiePlot
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function SetTheme($aTheme)
|
||||
{
|
||||
// JpGraphError::RaiseL(15012,$aTheme);
|
||||
// return;
|
||||
|
||||
if (in_array($aTheme, array_keys($this->themearr))) {
|
||||
$this->theme = $aTheme;
|
||||
$this->is_using_plot_theme = true;
|
||||
} else {
|
||||
JpGraphError::RaiseL(15001, $aTheme);
|
||||
}//("PiePLot::SetTheme() Unknown theme: $aTheme");
|
||||
JpGraphError::RaiseL(15001, $aTheme);//("PiePLot::SetTheme() Unknown theme: $aTheme");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function ExplodeSlice($e, $radius=20)
|
||||
{
|
||||
if (! is_integer($e)) {
|
||||
|
|
@ -245,15 +251,14 @@ class PiePlot
|
|||
if ($aStart < 0 || $aStart > 360) {
|
||||
JpGraphError::RaiseL(15004);//('Slice start angle must be between 0 and 360 degrees.');
|
||||
}
|
||||
$this->startangle = 360-$aStart;
|
||||
$this->startangle *= M_PI/180;
|
||||
if ($aStart == 0) {
|
||||
$this->startangle = 0;
|
||||
} else {
|
||||
$this->startangle = 360-$aStart;
|
||||
$this->startangle *= M_PI/180;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetFont($family, $style=FS_NORMAL, $size=10)
|
||||
{
|
||||
JpGraphError::RaiseL(15005);//('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.');
|
||||
}
|
||||
|
||||
|
||||
// Size in percentage
|
||||
public function SetSize($aSize)
|
||||
{
|
||||
|
|
@ -264,13 +269,7 @@ class PiePlot
|
|||
}
|
||||
//("PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]");
|
||||
}
|
||||
|
||||
public function SetFontColor($aColor)
|
||||
{
|
||||
JpGraphError::RaiseL(15007);
|
||||
//('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.');
|
||||
}
|
||||
|
||||
|
||||
// Set label arrays
|
||||
public function SetLegends($aLegend)
|
||||
{
|
||||
|
|
@ -288,15 +287,15 @@ class PiePlot
|
|||
{
|
||||
$this->ilabelposadj=$aLblPosAdj;
|
||||
}
|
||||
|
||||
|
||||
// Should we display actual value or percentage?
|
||||
public function SetLabelType($t)
|
||||
public function SetLabelType($aType)
|
||||
{
|
||||
if ($t < 0 || $t > 2) {
|
||||
JpGraphError::RaiseL(15008, $t);
|
||||
if ($aType < 0 || $aType > 2) {
|
||||
JpGraphError::RaiseL(15008, $aType);
|
||||
}
|
||||
//("PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not $t).");
|
||||
$this->labeltype=$t;
|
||||
$this->labeltype = $aType;
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
|
|
@ -311,7 +310,7 @@ class PiePlot
|
|||
$this->pie_border = $exterior;
|
||||
$this->pie_interior_border = $interior;
|
||||
}
|
||||
|
||||
|
||||
// Setup the legends
|
||||
public function Legend($graph)
|
||||
{
|
||||
|
|
@ -332,7 +331,7 @@ class PiePlot
|
|||
$this->setslicecolors = array_reverse($this->setslicecolors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sum=0;
|
||||
for ($i=0; $i < $n; ++$i) {
|
||||
$sum += $this->data[$i];
|
||||
|
|
@ -345,14 +344,16 @@ class PiePlot
|
|||
|
||||
// Make sure we don't plot more values than data points
|
||||
// (in case the user added more legends than data points)
|
||||
$n = min(count($this->legends), count($this->data));
|
||||
$legendsCount = is_array($this->legends) ? count($this->legends) : 0;
|
||||
$n = min($legendsCount, count($this->data));
|
||||
if ($this->legends != "") {
|
||||
$this->legends = array_reverse(array_slice($this->legends, 0, $n));
|
||||
}
|
||||
for ($i=$n-1; $i >= 0; --$i) {
|
||||
$l = $this->legends[$i];
|
||||
// Replace possible format with actual values
|
||||
if (count($this->csimalts) > $i) {
|
||||
$count = is_array($this->csimalts) ? count($this->csimalts) : 0;
|
||||
if ($count > $i) {
|
||||
$fmt = $this->csimalts[$i];
|
||||
} else {
|
||||
$fmt = "%d"; // Deafult Alt if no other has been specified
|
||||
|
|
@ -375,13 +376,15 @@ class PiePlot
|
|||
}
|
||||
|
||||
if ($this->setslicecolors==null) {
|
||||
$graph->legend->Add($l, $colors[$ta[$i%$numcolors]], "", 0, $this->csimtargets[$i], $alt, $wintarg);
|
||||
$csimtarget = isset($this->csimtargets[$i]) ? $this->csimtargets[$i] : null;
|
||||
$graph->legend->Add($l, $colors[$ta[$i%$numcolors]], "", 0, $csimtarget, $alt, $wintarg);
|
||||
} else {
|
||||
$graph->legend->Add($l, $this->setslicecolors[$i%$numcolors], "", 0, $this->csimtargets[$i], $alt, $wintarg);
|
||||
$csimtarget = isset($this->csimtargets[$i]) ? $this->csimtargets[$i] : null;
|
||||
$graph->legend->Add($l, $this->setslicecolors[$i%$numcolors], "", 0, $csimtarget, $alt, $wintarg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Adjust the rounded percetage value so that the sum of
|
||||
// of the pie slices are always 100%
|
||||
// Using the Hare/Niemeyer method
|
||||
|
|
@ -395,7 +398,7 @@ class PiePlot
|
|||
$mul=10000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tmp = array();
|
||||
$result = array();
|
||||
$quote_sum=0;
|
||||
|
|
@ -441,7 +444,7 @@ class PiePlot
|
|||
// aaoption == 1 just the body
|
||||
// aaoption == 2 just the values
|
||||
|
||||
// Explode scaling. If anti anti alias we scale the image
|
||||
// Explode scaling. If anti alias we scale the image
|
||||
// twice and we also need to scale the exploding distance
|
||||
$expscale = $aaoption === 1 ? 2 : 1;
|
||||
|
||||
|
|
@ -450,11 +453,15 @@ class PiePlot
|
|||
$this->adjusted_data = $this->AdjPercentage($this->data);
|
||||
}
|
||||
|
||||
if ($this->use_plot_theme_colors) {
|
||||
$this->setslicecolors = null;
|
||||
}
|
||||
|
||||
$colors = array_keys($img->rgb->rgb_table);
|
||||
sort($colors);
|
||||
$ta=$this->themearr[$this->theme];
|
||||
$n = count($this->data);
|
||||
|
||||
|
||||
if ($this->setslicecolors==null) {
|
||||
$numcolors=count($ta);
|
||||
} else {
|
||||
|
|
@ -476,12 +483,12 @@ class PiePlot
|
|||
for ($i=0; $i < $n; ++$i) {
|
||||
$sum += $this->data[$i];
|
||||
}
|
||||
|
||||
|
||||
// Bail out with error if the sum is 0
|
||||
if ($sum==0) {
|
||||
JpGraphError::RaiseL(15009);
|
||||
}//("Sum of all data is 0 for Pie.");
|
||||
|
||||
JpGraphError::RaiseL(15009);//("Sum of all data is 0 for Pie.");
|
||||
}
|
||||
|
||||
// Set up the pie-circle
|
||||
if ($this->radius <= 1) {
|
||||
$radius = floor($this->radius*min($img->width, $img->height));
|
||||
|
|
@ -494,13 +501,13 @@ class PiePlot
|
|||
} else {
|
||||
$xc = $this->posx ;
|
||||
}
|
||||
|
||||
|
||||
if ($this->posy <= 1 && $this->posy > 0) {
|
||||
$yc = round($this->posy*$img->height);
|
||||
} else {
|
||||
$yc = $this->posy ;
|
||||
}
|
||||
|
||||
|
||||
$n = count($this->data);
|
||||
|
||||
if ($this->explode_all) {
|
||||
|
|
@ -532,7 +539,7 @@ class PiePlot
|
|||
|
||||
$xcm = $xc + $this->explode_radius[$j]*cos($la)*$expscale;
|
||||
$ycm = $yc - $this->explode_radius[$j]*sin($la)*$expscale;
|
||||
|
||||
|
||||
$xcm += $this->ishadowdrop*$expscale;
|
||||
$ycm += $this->ishadowdrop*$expscale;
|
||||
|
||||
|
|
@ -550,8 +557,7 @@ class PiePlot
|
|||
$radius-1,
|
||||
$angle1*180/M_PI,
|
||||
$angle2*180/M_PI,
|
||||
$slicecolor,
|
||||
$arccolor
|
||||
$this->ishadowcolor
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -570,7 +576,7 @@ class PiePlot
|
|||
// There are n slices in total
|
||||
for ($i=0; $sum>0 && $i < $n; ++$i) {
|
||||
|
||||
// $j is the actual index used for the slice
|
||||
// $j is the actual index used for the slice
|
||||
$j = $n-$i-1;
|
||||
|
||||
// Make sure we havea valid distance to explode the slice
|
||||
|
|
@ -593,19 +599,18 @@ class PiePlot
|
|||
// We avoid some trouble by not allowing end angle to be 0, in that case
|
||||
// we translate to 360
|
||||
|
||||
|
||||
// la is used to hold the label angle, which is centered on the slice
|
||||
if ($angle2 < 0.0001 && $angle1 > 0.0001) {
|
||||
$this->la[$i] = 2*M_PI - (abs(2*M_PI-$angle1)/2.0+$angle1);
|
||||
} elseif ($angle1 > $angle2) {
|
||||
// The case where the slice crosses the 3 a'clock line
|
||||
// Remember that the slices are counted clockwise and
|
||||
// labels are counted counter clockwise so we need to revert with 2 PI
|
||||
$this->la[$i] = 2*M_PI-$this->NormAngle($angle1 + ((2*M_PI - $angle1)+$angle2)/2);
|
||||
} else {
|
||||
$this->la[$i] = 2*M_PI - (abs($angle2-$angle1)/2.0+$angle1);
|
||||
}
|
||||
|
||||
$_sa = round($angle1*180/M_PI);
|
||||
$_ea = round($angle2*180/M_PI);
|
||||
$_la = round($this->la[$i]*180/M_PI);
|
||||
//echo "ang1=$_sa , ang2=$_ea - la=$_la<br>";
|
||||
|
||||
// Too avoid rounding problems we skip the slice if it is too small
|
||||
if ($d < 0.00001) {
|
||||
continue;
|
||||
|
|
@ -618,7 +623,13 @@ class PiePlot
|
|||
} else {
|
||||
$slicecolor=$this->setslicecolors[$i%$numcolors];
|
||||
}
|
||||
|
||||
|
||||
// $_sa = round($angle1*180/M_PI);
|
||||
// $_ea = round($angle2*180/M_PI);
|
||||
// $_la = round($this->la[$i]*180/M_PI);
|
||||
// echo "Slice#$i: ang1=$_sa , ang2=$_ea, la=$_la, color=$slicecolor<br>";
|
||||
|
||||
|
||||
// If we have enabled antialias then we don't draw any border so
|
||||
// make the bordedr color the same as the slice color
|
||||
if ($this->pie_interior_border && $aaoption===0) {
|
||||
|
|
@ -641,12 +652,11 @@ class PiePlot
|
|||
$_ea = round($angle2*180/M_PI);
|
||||
$_la = round($this->la[$i]*180/M_PI);
|
||||
//echo "[$i] sa=$_sa, ea=$_ea, la[$i]=$_la, (color=$slicecolor)<br>";
|
||||
|
||||
|
||||
// The CakeSlice method draws a full circle in case of start angle = end angle
|
||||
// for pie slices we don't want this behaviour unless we only have one
|
||||
// slice in the pie in case it is the wanted behaviour
|
||||
if (abs($_ea-$_sa) > 0.1 || $n==1) {
|
||||
// for pie slices we want this in case the slice have a value larger than 99% of the
|
||||
// total sum
|
||||
if (abs($_ea-$_sa) >= 1 || $d == $sum) {
|
||||
$img->CakeSlice($xcm, $ycm, $radius-1, $radius-1, $_sa, $_ea, $slicecolor, $arccolor);
|
||||
}
|
||||
}
|
||||
|
|
@ -731,16 +741,16 @@ class PiePlot
|
|||
$n = count($this->labels);
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Step 1 of the algorithm is to construct a number of clusters
|
||||
// a cluster is defined as all slices within the same quadrant (almost)
|
||||
// that has an angular distance less than the treshold
|
||||
//-----------------------------------------------------------------------
|
||||
$tresh_hold=25 * M_PI/180; // 25 degrees difference to be in a cluster
|
||||
$incluster=false; // flag if we are currently in a cluster or not
|
||||
$clusters = array(); // array of clusters
|
||||
$cidx=-1; // running cluster index
|
||||
// Step 1 of the algorithm is to construct a number of clusters
|
||||
// a cluster is defined as all slices within the same quadrant (almost)
|
||||
// that has an angular distance less than the treshold
|
||||
//-----------------------------------------------------------------------
|
||||
$tresh_hold=25 * M_PI/180; // 25 degrees difference to be in a cluster
|
||||
$incluster=false; // flag if we are currently in a cluster or not
|
||||
$clusters = array(); // array of clusters
|
||||
$cidx=-1; // running cluster index
|
||||
|
||||
// Go through all the labels and construct a number of clusters
|
||||
// Go through all the labels and construct a number of clusters
|
||||
for ($i=0; $i < $n-1; ++$i) {
|
||||
// Calc the angle distance between two consecutive slices
|
||||
$a1=$this->la[$i];
|
||||
|
|
@ -787,7 +797,7 @@ class PiePlot
|
|||
$clusters[$cidx][1]++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$incluster = false;
|
||||
}
|
||||
} elseif ($q1 == $q2) {
|
||||
|
|
@ -797,8 +807,8 @@ class PiePlot
|
|||
// cluster. If we don't do this then we risk that the label
|
||||
// for the cluster of one will cross the guide-line
|
||||
if ($q1 == 0 && $cidx > -1 &&
|
||||
$clusters[$cidx][1] == 1 &&
|
||||
$this->Quadrant($this->la[$clusters[$cidx][0]]) == 0) {
|
||||
$clusters[$cidx][1] == 1 &&
|
||||
$this->Quadrant($this->la[$clusters[$cidx][0]]) == 0) {
|
||||
$clusters[$cidx][1]++;
|
||||
} else {
|
||||
$cidx++;
|
||||
|
|
@ -834,18 +844,18 @@ class PiePlot
|
|||
}
|
||||
|
||||
/*
|
||||
if( true ) {
|
||||
// Debug printout in labels
|
||||
for( $i=0; $i <= $cidx; ++$i ) {
|
||||
for( $j=0; $j < $clusters[$i][1]; ++$j ) {
|
||||
$a = $this->la[$clusters[$i][0]+$j];
|
||||
$aa = round($a*180/M_PI);
|
||||
$q = $this->Quadrant($a);
|
||||
$this->labels[$clusters[$i][0]+$j]="[$q:$aa] $i:$j";
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
if( true ) {
|
||||
// Debug printout in labels
|
||||
for( $i=0; $i <= $cidx; ++$i ) {
|
||||
for( $j=0; $j < $clusters[$i][1]; ++$j ) {
|
||||
$a = $this->la[$clusters[$i][0]+$j];
|
||||
$aa = round($a*180/M_PI);
|
||||
$q = $this->Quadrant($a);
|
||||
$this->labels[$clusters[$i][0]+$j]="[$q:$aa] $i:$j";
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Step 2 of the algorithm is use the clusters and draw the labels
|
||||
|
|
@ -865,7 +875,7 @@ class PiePlot
|
|||
// Walk through all the clusters
|
||||
for ($i=0; $i < $nc; ++$i) {
|
||||
|
||||
// Start angle and number of slices in this cluster
|
||||
// Start angle and number of slices in this cluster
|
||||
$csize = $clusters[$i][1];
|
||||
$a = $this->la[$clusters[$i][0]];
|
||||
$q = $this->Quadrant($a);
|
||||
|
|
@ -901,12 +911,12 @@ class PiePlot
|
|||
// Now adjust the position of the labels in each cluster starting
|
||||
// with the slice that is closest to the equator of the pie
|
||||
$a = $this->la[$clusters[$i][0]+$idx];
|
||||
|
||||
|
||||
// Guide line start in the center of the arc of the slice
|
||||
$r = $radius+$this->explode_radius[$n-1-($clusters[$i][0]+$idx)];
|
||||
$x = round($r*cos($a)+$xc);
|
||||
$y = round($yc-$r*sin($a));
|
||||
|
||||
|
||||
// The distance from the arc depends on chosen font and the "R-Factor"
|
||||
$r += $fh*$this->iGuideLineRFactor;
|
||||
|
||||
|
|
@ -1023,7 +1033,7 @@ class PiePlot
|
|||
public function StrokeLabel($label, $img, $xc, $yc, $a, $r)
|
||||
{
|
||||
|
||||
// Default value
|
||||
// Default value
|
||||
if ($this->ilabelposadj === 'auto') {
|
||||
$this->ilabelposadj = 0.65;
|
||||
}
|
||||
|
|
@ -1033,16 +1043,16 @@ class PiePlot
|
|||
if ($this->ilabelposadj < 1.0) {
|
||||
$this->value->SetAlign('center', 'center');
|
||||
$this->value->margin = 0;
|
||||
|
||||
|
||||
$xt=round($this->ilabelposadj*$r*cos($a)+$xc);
|
||||
$yt=round($yc-$this->ilabelposadj*$r*sin($a));
|
||||
|
||||
|
||||
$this->value->Stroke($img, $label, $xt, $yt);
|
||||
} else {
|
||||
$this->value->halign = "left";
|
||||
$this->value->valign = "top";
|
||||
$this->value->margin = 0;
|
||||
|
||||
|
||||
// Position the axis title.
|
||||
// dx, dy is the offset from the top left corner of the bounding box that sorrounds the text
|
||||
// that intersects with the extension of the corresponding axis. The code looks a little
|
||||
|
|
@ -1065,7 +1075,7 @@ class PiePlot
|
|||
if ($this->ilabelposadj > 1.0 && $this->ilabelposadj < 5.0) {
|
||||
$r *= $this->ilabelposadj;
|
||||
}
|
||||
|
||||
|
||||
$r += $img->GetFontHeight()/1.5;
|
||||
|
||||
$xt=round($r*cos($a)+$xc);
|
||||
|
|
@ -1091,7 +1101,7 @@ class PiePlot
|
|||
if ($a>=5*M_PI/4 && $a <= 7*M_PI/4) {
|
||||
$dx=(1-($a-M_PI*5/4)*2/M_PI);
|
||||
}
|
||||
|
||||
|
||||
if ($a>=7*M_PI/4) {
|
||||
$dy=(($a-M_PI)-3*M_PI/4)*2/M_PI;
|
||||
}
|
||||
|
|
@ -1107,10 +1117,15 @@ class PiePlot
|
|||
if ($a>=5*M_PI/4 && $a <= 7*M_PI/4) {
|
||||
$dy=0;
|
||||
}
|
||||
|
||||
|
||||
$this->value->Stroke($img, $label, $xt-$dx*$w, $yt-$dy*$h);
|
||||
}
|
||||
}
|
||||
|
||||
public function UsePlotThemeColors($flag = true)
|
||||
{
|
||||
$this->use_plot_theme_colors = $flag;
|
||||
}
|
||||
} // Class
|
||||
|
||||
|
||||
|
|
@ -1121,16 +1136,16 @@ class PiePlot
|
|||
//===================================================
|
||||
class PiePlotC extends PiePlot
|
||||
{
|
||||
private $imidsize=0.5; // Fraction of total width
|
||||
private $imidsize=0.5; // Fraction of total width
|
||||
private $imidcolor='white';
|
||||
public $midtitle='';
|
||||
private $middlecsimtarget='';
|
||||
private $middlecsimwintarget='';
|
||||
private $middlecsimalt='';
|
||||
|
||||
public function PiePlotC($data, $aCenterTitle='')
|
||||
public function __construct($data, $aCenterTitle='')
|
||||
{
|
||||
parent::PiePlot($data);
|
||||
parent::__construct($data);
|
||||
$this->midtitle = new Text();
|
||||
$this->midtitle->ParagraphAlign('center');
|
||||
}
|
||||
|
|
@ -1189,7 +1204,7 @@ class PiePlotC extends PiePlot
|
|||
$xp = floor(($this->imidsize*$radius*cos($ea))+$xc);
|
||||
$yp = floor($yc-($this->imidsize*$radius*sin($ea)));
|
||||
$coords = "$xp, $yp";
|
||||
|
||||
|
||||
//add coordinates every 0.25 radians
|
||||
$a=$ea+0.25;
|
||||
|
||||
|
|
@ -1230,7 +1245,7 @@ class PiePlotC extends PiePlot
|
|||
$coords.= ", $xp, $yp";
|
||||
$a -= 0.25;
|
||||
}
|
||||
|
||||
|
||||
//Add the last point on the arc
|
||||
$xp = floor($radius*cos($ea)+$xc);
|
||||
$yp = floor($yc-$radius*sin($ea));
|
||||
|
|
@ -1243,7 +1258,7 @@ class PiePlotC extends PiePlot
|
|||
|
||||
if (!empty($this->csimtargets[$i])) {
|
||||
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".
|
||||
$this->csimtargets[$i]."\"";
|
||||
$this->csimtargets[$i]."\"";
|
||||
if (!empty($this->csimwintargets[$i])) {
|
||||
$this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" ";
|
||||
}
|
||||
|
|
@ -1259,7 +1274,7 @@ class PiePlotC extends PiePlot
|
|||
public function Stroke($img, $aaoption=0)
|
||||
{
|
||||
|
||||
// Stroke the pie but don't stroke values
|
||||
// Stroke the pie but don't stroke values
|
||||
$tmp = $this->value->show;
|
||||
$this->value->show = false;
|
||||
parent::Stroke($img, $aaoption);
|
||||
|
|
@ -1343,12 +1358,16 @@ class PieGraph extends Graph
|
|||
public $pieaa = false ;
|
||||
//---------------
|
||||
// CONSTRUCTOR
|
||||
public function PieGraph($width=300, $height=200, $cachedName="", $timeout=0, $inline=1)
|
||||
public function __construct($width=300, $height=200, $cachedName="", $timeout=0, $inline=1)
|
||||
{
|
||||
$this->Graph($width, $height, $cachedName, $timeout, $inline);
|
||||
parent::__construct($width, $height, $cachedName, $timeout, $inline);
|
||||
$this->posx=$width/2;
|
||||
$this->posy=$height/2;
|
||||
$this->SetColor(array(255,255,255));
|
||||
|
||||
if ($this->graph_theme) {
|
||||
$this->graph_theme->ApplyGraph($this);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------
|
||||
|
|
@ -1369,19 +1388,32 @@ class PieGraph extends Graph
|
|||
if (is_array($aObj)) {
|
||||
$n = count($aObj);
|
||||
for ($i=0; $i < $n; ++$i) {
|
||||
//if ($aObj[$i]->theme) {
|
||||
// $this->ClearTheme();
|
||||
//}
|
||||
$this->plots[] = $aObj[$i];
|
||||
}
|
||||
} else {
|
||||
//if ($aObj->theme) {
|
||||
// $this->ClearTheme();
|
||||
//}
|
||||
$this->plots[] = $aObj;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->graph_theme) {
|
||||
$this->graph_theme->SetupPlot($aObj);
|
||||
if ($aObj->is_using_plot_theme) {
|
||||
$aObj->UsePlotThemeColors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function SetAntiAliasing($aFlg=true)
|
||||
{
|
||||
$this->pieaa = $aFlg;
|
||||
}
|
||||
|
||||
|
||||
public function SetColor($c)
|
||||
{
|
||||
$this->SetMarginColor($c);
|
||||
|
|
@ -1394,7 +1426,8 @@ class PieGraph extends Graph
|
|||
foreach ($this->plots as $p) {
|
||||
$csim .= $p->GetCSIMareas();
|
||||
}
|
||||
//$csim.= $this->legend->GetCSIMareas();
|
||||
|
||||
$csim.= $this->legend->GetCSIMareas();
|
||||
if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", $csim, $coords)) {
|
||||
$this->img->SetColor($this->csimcolor);
|
||||
$n = count($coords[0]);
|
||||
|
|
@ -1421,6 +1454,7 @@ class PieGraph extends Graph
|
|||
// Method description
|
||||
public function Stroke($aStrokeFileName="")
|
||||
{
|
||||
|
||||
// If the filename is the predefined value = '_csim_special_'
|
||||
// we assume that the call to stroke only needs to do enough
|
||||
// to correctly generate the CSIM maps.
|
||||
|
|
@ -1430,6 +1464,12 @@ class PieGraph extends Graph
|
|||
// code below.
|
||||
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
|
||||
|
||||
// If we are called the second time (perhaps the user has called GetHTMLImageMap()
|
||||
// himself then the legends have alsready been populated once in order to get the
|
||||
// CSIM coordinats. Since we do not want the legends to be populated a second time
|
||||
// we clear the legends
|
||||
$this->legend->Clear();
|
||||
|
||||
// We need to know if we have stroked the plot in the
|
||||
// GetCSIMareas. Otherwise the CSIM hasn't been generated
|
||||
// and in the case of GetCSIM called before stroke to generate
|
||||
|
|
@ -1454,7 +1494,7 @@ class PieGraph extends Graph
|
|||
$oldimg = $this->img->img;
|
||||
|
||||
$this->img->CreateImgCanvas(2*$w, 2*$h);
|
||||
|
||||
|
||||
$this->img->SetColor($this->margin_color);
|
||||
$this->img->FilledRectangle(0, 0, 2*$w-1, 2*$h-1);
|
||||
|
||||
|
|
@ -1520,6 +1560,7 @@ class PieGraph extends Graph
|
|||
$this->StrokeFrameBackground();
|
||||
} else {
|
||||
$this->StrokeFrame();
|
||||
$this->StrokeBackgroundGrad();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1537,7 +1578,7 @@ class PieGraph extends Graph
|
|||
|
||||
if (!$_csim) {
|
||||
|
||||
// Stroke texts
|
||||
// Stroke texts
|
||||
if ($this->texts != null) {
|
||||
$n = count($this->texts);
|
||||
for ($i=0; $i < $n; ++$i) {
|
||||
|
|
@ -1555,7 +1596,7 @@ class PieGraph extends Graph
|
|||
require_once('jpgraph_imgtrans.php');
|
||||
//JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.');
|
||||
}
|
||||
|
||||
|
||||
$tform = new ImgTrans($this->img->img);
|
||||
$this->img->img = $tform->Skew3D(
|
||||
$this->iImgTransHorizon,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue