Changeset 1425


Ignore:
Timestamp:
Sep 26, 2010, 1:26:00 PM (10 years ago)
Author:
roux
Message:

mise-à-jour pChart

Location:
cpc/trunk/project
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/plugins/xsPChartPlugin/lib/pChart/pChart/pChart.class

    r525 r1425  
    33     pChart - a PHP class to build charts!
    44     Copyright (C) 2008 Jean-Damien POGOLOTTI
    5      Version  1.27 last updated on 08/17/08
     5     Version  1.27b last updated on 08/21/08
    66
    77     http://pchart.sourceforge.net
     
    3939      drawFromJPG($FileName,$X,$Y,$Alpha=100)
    4040     Graph setup methods :
     41      addBorder($Width=3,$R=0,$G=0,$B=0)
    4142      drawGraphArea($R,$G,$B,$Stripe=FALSE)
    4243      drawScale(&$Data,&$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1)
    4344      drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=100)
    44       drawLegend($XPos,$YPos,&$DataDescription,$R,$G,$B)
     45      drawLegend($XPos,$YPos,&$DataDescription,$R,$G,$B,$Rs=-1,$Gs=-1,$Bs=-1)
    4546      drawPieLegend($XPos,$YPos,$Data,$DataDescription,$R,$G,$B)
    4647      drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1)
    47       drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4)
     48      drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4,$FreeText=NULL)
    4849      drawArea(&$Data,$Serie1,$Serie2,$R,$G,$B,$Alpha = 50)
    4950      drawRadarAxis(&$Data,&$DataDescription,$Mosaic=TRUE,$BorderOffset=10,$A_R=60,$A_G=60,$A_B=60,$S_R=200,$S_G=200,$S_B=200,$MaxValue=-1)
     51      drawGraphAreaGradient($R,$G,$B,$Decay,$Target=TARGET_GRAPHAREA)
     52      drawTextBox($X1,$Y1,$X2,$Y2,$Text,$Angle=0,$R=255,$G=255,$B=255,$Align=ALIGN_LEFT,$Shadow=TRUE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=100)
    5053      getLegendBoxSize($DataDescription)
    5154      loadColorPalette($FileName,$Delimiter=",")
     
    7679      drawPieGraph(&$Data,&$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$EnhanceColors=TRUE,$Skew=60,$SpliceHeight=20,$SpliceDistance=0,$Decimals=0)
    7780     Other methods :
     81      setImageMap($Mode=TRUE,$GraphID="MyGraph")
     82      getImageMap($MapName,$Flush=TRUE)
    7883      Render($FileName)
    7984      Stroke()
     
    8893 define("PIE_LABELS",2);
    8994 define("PIE_NOLABEL",3);
     95 define("TARGET_GRAPHAREA",1);
     96 define("TARGET_BACKGROUND",2);
     97 define("ALIGN_TOP_LEFT",1);
     98 define("ALIGN_TOP_CENTER",2);
     99 define("ALIGN_TOP_RIGHT",3);
     100 define("ALIGN_LEFT",4);
     101 define("ALIGN_CENTER",5);
     102 define("ALIGN_RIGHT",6);
     103 define("ALIGN_BOTTOM_LEFT",7);
     104 define("ALIGN_BOTTOM_CENTER",8);
     105 define("ALIGN_BOTTOM_RIGHT",9);
    90106 define("PIE_VALUES",4);
    91107
     
    107123   var $YSize          = NULL;
    108124   var $Picture        = NULL;
     125   var $ImageMap       = NULL;
    109126
    110127   /* Error management */
     
    145162   var $AntialiasQuality = 10;
    146163
     164   /* Image Map settings */
     165   var $BuildMap         = FALSE;
     166   var $MapFunction      = NULL;
     167   var $tmpFolder        = "tmp/";
     168   var $MapID            = NULL;
     169
    147170   /* This function create the background picture */
    148171   function pChart($XSize,$YSize)
     
    561584     foreach($DataDescription["Description"] as $Key => $Value)
    562585      {
    563        $Position  = imageftbbox($this->FontSize,0,$this->FontName,$Value);
    564        $TextWidth = $Position[2]-$Position[0];
     586       $Position   = imageftbbox($this->FontSize,0,$this->FontName,$Value);
     587       $TextWidth  = $Position[2]-$Position[0];
     588       $TextHeight = $Position[1]-$Position[7];
    565589       if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }
    566        $MaxHeight = $MaxHeight + ( $this->FontSize + 6 );
     590       $MaxHeight = $MaxHeight + $TextHeight + 4;
    567591      }
    568592     $MaxHeight = $MaxHeight - 3;
     
    573597
    574598   /* Draw the data legends */
    575    function drawLegend($XPos,$YPos,&$DataDescription,$R,$G,$B)
     599   function drawLegend($XPos,$YPos,&$DataDescription,$R,$G,$B,$Rs=-1,$Gs=-1,$Bs=-1)
    576600    {
    577601     /* Validate the Data and DataDescription array */
     
    587611     foreach($DataDescription["Description"] as $Key => $Value)
    588612      {
    589        $Position  = imageftbbox($this->FontSize,0,$this->FontName,$Value);
    590        $TextWidth = $Position[2]-$Position[0];
     613       $Position   = imageftbbox($this->FontSize,0,$this->FontName,$Value);
     614       $TextWidth  = $Position[2]-$Position[0];
     615       $TextHeight = $Position[1]-$Position[7];
    591616       if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }
    592        $MaxHeight = $MaxHeight + ( $this->FontSize + 6 );
     617       $MaxHeight = $MaxHeight + $TextHeight + 4;
    593618      }
    594619     $MaxHeight = $MaxHeight - 5;
    595620     $MaxWidth  = $MaxWidth + 32;
    596621
    597      $this->drawFilledRoundedRectangle($XPos+1,$YPos+1,$XPos+$MaxWidth+1,$YPos+$MaxHeight+1,5,$R-30,$G-30,$B-30);
     622     if ( $Rs == -1 || $Gs == -1 || $Bs == -1 )
     623      { $Rs = $R-30; $Gs = $G-30; $Bs = $B-30; }
     624
     625     $this->drawFilledRoundedRectangle($XPos+1,$YPos+1,$XPos+$MaxWidth+1,$YPos+$MaxHeight+1,5,$Rs,$Gs,$Bs);
    598626     $this->drawFilledRoundedRectangle($XPos,$YPos,$XPos+$MaxWidth,$YPos+$MaxHeight,5,$R,$G,$B);
    599627
     
    602630      {
    603631       $this->drawFilledRoundedRectangle($XPos+10,$YPos+$YOffset-4,$XPos+14,$YPos+$YOffset-4,2,$this->Palette[$ID]["R"],$this->Palette[$ID]["G"],$this->Palette[$ID]["B"]);
    604 
    605632       imagettftext($this->Picture,$this->FontSize,0,$XPos+22,$YPos+$YOffset,$C_TextColor,$this->FontName,$Value);
    606        $YOffset = $YOffset + ( $this->FontSize + 6 );
     633
     634       $Position   = imageftbbox($this->FontSize,0,$this->FontName,$Value);
     635       $TextHeight = $Position[1]-$Position[7];
     636
     637       $YOffset = $YOffset + $TextHeight + 4;
    607638       $ID++;
    608639      }
     
    628659       $Position  = imageftbbox($this->FontSize,0,$this->FontName,$Value2);
    629660       $TextWidth = $Position[2]-$Position[0];
     661       $TextHeight = $Position[1]-$Position[7];
    630662       if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }
    631        $MaxHeight = $MaxHeight + ( $this->FontSize + 6 );
     663
     664       $MaxHeight = $MaxHeight + $TextHeight + 4;
    632665      }
    633666     $MaxHeight = $MaxHeight - 3;
     
    640673     foreach($Data as $Key => $Value)
    641674      {
    642        $Value2 = $Value[$DataDescription["Position"]];
    643 
     675       $Value2     = $Value[$DataDescription["Position"]];
     676       $Position   = imageftbbox($this->FontSize,0,$this->FontName,$Value2);
     677       $TextHeight = $Position[1]-$Position[7];
    644678       $this->drawFilledRectangle($XPos+10,$YPos+$YOffset-6,$XPos+14,$YPos+$YOffset-2,$this->Palette[$ID]["R"],$this->Palette[$ID]["G"],$this->Palette[$ID]["B"]);
    645679
    646680       imagettftext($this->Picture,$this->FontSize,0,$XPos+22,$YPos+$YOffset,$C_TextColor,$this->FontName,$Value2);
    647        $YOffset = $YOffset + ( $this->FontSize + 6 );
     681       $YOffset = $YOffset + $TextHeight + 4;
    648682       $ID++;
    649683      }
     
    672706    }
    673707
     708   /* Draw a text box with text align & alpha properties */
     709   function drawTextBox($X1,$Y1,$X2,$Y2,$Text,$Angle=0,$R=255,$G=255,$B=255,$Align=ALIGN_LEFT,$Shadow=TRUE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=100)
     710    {
     711     $Position   = imageftbbox($this->FontSize,$Angle,$this->FontName,$Text);
     712     $TextWidth  = $Position[2]-$Position[0];
     713     $TextHeight = $Position[5]-$Position[3];
     714     $AreaWidth  = $X2 - $X1;
     715     $AreaHeight = $Y2 - $Y1;
     716
     717     if ( $BgR != -1 && $BgG != -1 && $BgB != -1 )
     718      $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$BgR,$BgG,$BgB,FALSE,$Alpha);
     719
     720     if ( $Align == ALIGN_TOP_LEFT )      { $X = $X1+1; $Y = $Y1+$this->FontSize+1; }
     721     if ( $Align == ALIGN_TOP_CENTER )    { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y1+$this->FontSize+1; }
     722     if ( $Align == ALIGN_TOP_RIGHT )     { $X = $X2-$TextWidth-1; $Y = $Y1+$this->FontSize+1; }
     723     if ( $Align == ALIGN_LEFT )          { $X = $X1+1; $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }
     724     if ( $Align == ALIGN_CENTER )        { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }
     725     if ( $Align == ALIGN_RIGHT )         { $X = $X2-$TextWidth-1; $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }
     726     if ( $Align == ALIGN_BOTTOM_LEFT )   { $X = $X1+1; $Y = $Y2-1; }
     727     if ( $Align == ALIGN_BOTTOM_CENTER ) { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y2-1; }
     728     if ( $Align == ALIGN_BOTTOM_RIGHT )  { $X = $X2-$TextWidth-1; $Y = $Y2-1; }
     729
     730     $C_TextColor   = imagecolorallocate($this->Picture,$R,$G,$B);
     731     $C_ShadowColor = imagecolorallocate($this->Picture,0,0,0);
     732     if ( $Shadow )
     733      imagettftext($this->Picture,$this->FontSize,$Angle,$X+1,$Y+1,$C_ShadowColor,$this->FontName,$Text);     
     734
     735     imagettftext($this->Picture,$this->FontSize,$Angle,$X,$Y,$C_TextColor,$this->FontName,$Text);     
     736    }
     737
    674738   /* Compute and draw the scale */
    675    function drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4)
     739   function drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4,$FreeText=NULL)
    676740    {
    677741     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
     
    692756     if ( $ShowLabel )
    693757      {
     758       if ( $Text == NULL )
     759        { $Label = $Value; } else { $Label = $FreeText; }
     760
    694761       if ( $ShowOnRight )
    695         imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X2+2,$Y+($this->FontSize/2),$C_TextColor,$this->FontName,$Value);
     762        imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X2+2,$Y+($this->FontSize/2),$C_TextColor,$this->FontName,$Label);
    696763       else
    697         imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X1+2,$Y-($this->FontSize/2),$C_TextColor,$this->FontName,$Value);
     764        imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X1+2,$Y-($this->FontSize/2),$C_TextColor,$this->FontName,$Label);
    698765      }
    699766    }
     
    759826        { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }
    760827
    761        $XPos   = $this->GArea_X1 + $this->GAreaXOffset;
     828       $R = $this->Palette[$ColorID]["R"];
     829       $G = $this->Palette[$ColorID]["G"];
     830       $B = $this->Palette[$ColorID]["B"];
     831
     832       if ( isset($DataDescription["Symbol"][$ColName]) )
     833        {
     834         $Is_Alpha = ((ord ( file_get_contents ($DataDescription["Symbol"][$ColName], false, null, 25, 1)) & 6) & 4) == 4;
     835
     836         $Infos       = getimagesize($DataDescription["Symbol"][$ColName]);
     837         $ImageWidth  = $Infos[0];
     838         $ImageHeight = $Infos[1];
     839         $Symbol      = imagecreatefromgif($DataDescription["Symbol"][$ColName]);
     840        }
     841
     842       $XPos  = $this->GArea_X1 + $this->GAreaXOffset;
     843       $Hsize = round($BigRadius/2);
    762844       foreach ( $Data as $Key => $Values )
    763845        {
    764846         $Value = $Data[$Key][$ColName];
    765          $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);
     847         $YPos  = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);
     848
     849         /* Save point into the image map if option activated */
     850         if ( $this->BuildMap )
     851          $this->addToImageMap($XPos-$Hsize,$YPos-$Hsize,$XPos+1+$Hsize,$YPos+$Hsize+1,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Plot");
    766852
    767853         if ( is_numeric($Value) )
    768854          {
    769            $R = $this->Palette[$ColorID]["R"];
    770            $G = $this->Palette[$ColorID]["G"];
    771            $B = $this->Palette[$ColorID]["B"];
    772            $this->drawFilledCircle($XPos+1,$YPos+1,$BigRadius,$R,$G,$B);
    773 
    774            if ( $R2 !=-1 && $G2 !=-1 && $B2 !=-1 )
    775             $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R2,$G2,$B2);
     855           if ( !isset($DataDescription["Symbol"][$ColName]) )
     856            {
     857             $this->drawFilledCircle($XPos+1,$YPos+1,$BigRadius,$R,$G,$B);
     858
     859             if ( $R2 !=-1 && $G2 !=-1 && $B2 !=-1 )
     860              $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R2,$G2,$B2);
     861             else
     862              {
     863               $R = $this->Palette[$ColorID]["R"]-5; if ( $R < 0 ) { $R = 0; }
     864               $G = $this->Palette[$ColorID]["G"]-5; if ( $G < 0 ) { $G = 0; }
     865               $B = $this->Palette[$ColorID]["B"]-5; if ( $B < 0 ) { $B = 0; }
     866
     867               $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R,$G,$B);
     868              }
     869            }
    776870           else
    777871            {
    778              $R = $this->Palette[$ColorID]["R"]-5; if ( $R < 0 ) { $R = 0; }
    779              $G = $this->Palette[$ColorID]["G"]-5; if ( $G < 0 ) { $G = 0; }
    780              $B = $this->Palette[$ColorID]["B"]-5; if ( $B < 0 ) { $B = 0; }
    781 
    782              $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R,$G,$B);
     872             imagecopymerge($this->Picture,$Symbol,$XPos+1-$ImageWidth/2,$YPos+1-$ImageHeight/2,0,0,$ImageWidth,$ImageHeight,100);
    783873            }
    784874          }
     
    900990             $Value = $Data[$Key][$ColName];
    901991             $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);
     992
     993             /* Save point into the image map if option activated */
     994             if ( $this->BuildMap )
     995              $this->addToImageMap($XPos-3,$YPos-3,$XPos+3,$YPos+3,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Line");
    902996
    903997             if (!is_numeric($Value)) { $XLast = -1; }
     
    12171311         $YPos = $LayerHeight - (($Value-$this->VMin) * $this->DivisionRatio);
    12181312
     1313         /* Save point into the image map if option activated */
     1314         if ( $this->BuildMap )
     1315          $this->addToImageMap($XPos-3,$YPos-3,$XPos+3,$YPos+3,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"FLine");
     1316
    12191317         if ( !is_numeric($Value) )
    12201318          {
     
    12921390       imagecolortransparent($this->Layers[$GraphID],$C_White);
    12931391
     1392       //$XWidth = $this->DivisionWidth / 4;
    12941393       $XWidth = $this->DivisionWidth * $Width / 200;
    12951394       $XPos   = $this->GAreaXOffset;
     
    13081407
    13091408             $X1 = floor($XPos - $XWidth + $this->GArea_X1); $Y1 = floor($YPos+$this->GArea_Y1) + .2;
    1310              $X2 = floor($XPos + $XWidth + $this->GArea_X1);
     1409             $X2 = floor($XPos + $XWidth + $this->GArea_X1);
     1410// $Y2 = $this->GArea_Y2 - ((0-$this->VMin) * $this->DivisionRatio);
    13111411             if ( $X1 <= $this->GArea_X1 ) { $X1 = $this->GArea_X1 + 1; }
    13121412             if ( $X2 >= $this->GArea_X2 ) { $X2 = $this->GArea_X2 - 1; }
     1413
     1414             /* Save point into the image map if option activated */
     1415             if ( $this->BuildMap )
     1416              $this->addToImageMap($X1,min($Y1,$Y2),$X2,max($Y1,$Y2),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"oBar");
    13131417
    13141418             $this->drawLine($X1,$Y1,$X2,$Y1,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE);
     
    13601464             $Value = $Data[$Key][$ColName];
    13611465             $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);
     1466
     1467             /* Save point into the image map if option activated */
     1468             if ( $this->BuildMap )
     1469              {
     1470               $this->addToImageMap($XPos+1,min($YZero,$YPos),$XPos+$SeriesWidth-1,max($YZero,$YPos),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Bar");
     1471              }
    13621472           
    13631473             if ( $Shadow && $Alpha == 100 )
     
    14161526               $LastValue[$Key] = $Value;
    14171527              }
     1528
     1529             /* Save point into the image map if option activated */
     1530             if ( $this->BuildMap )
     1531              $this->addToImageMap($XPos+1,min($YBottom,$YPos),$XPos+$SeriesWidth-1,max($YBottom,$YPos),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"sBar");
     1532
    14181533             $this->drawFilledRectangle($XPos+1,$YBottom,$XPos+$SeriesWidth-1,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE,$Alpha);
    14191534            }
     
    15801695          { $YOffset = $Height; $XOffset = -$Width; }
    15811696
     1697         //if ( $Angle > 180 && $Angle <= 270 )
    15821698         if ( $Angle > 180 && $Angle <= 260 )
    15831699          { $XOffset = -$Width; }
     
    17821898
    17831899     /* Calculate all polygons */
     1900     //$Angle    = 0; $TopPlots = "";
    17841901     $Angle    = 260; $TopPlots = "";
    17851902     foreach($iValues as $Key => $Value)
     
    17941911         if ($TAngle > 359) $TAngle -= 360;
    17951912         if ($DrawLabels == PIE_PERCENTAGE)
     1913       //   $Caption  = (round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";
    17961914          $Caption  = (floor($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";
    1797          elseif ($DrawLabels == PIE_VALUES)
    1798           $Caption  = (floor($Value));
    1799         elseif ($DrawLabels == PIE_LABELS)
     1915          elseif ($DrawLabels == PIE_VALUES)
     1916           $Caption  = (floor($Value));
     1917        elseif ($DrawLabels == PIE_LABELS)
    18001918          $Caption  = $iLabels[$Key];
    18011919         $TX       = cos(($TAngle) * 3.1418 / 180 ) * ($Radius + 10)+ $XPos;
    18021920         $TY       = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+ 10) + $YPos + 4;
    18031921
     1922        // if ( $TAngle > 90 && $TAngle < 270 )
    18041923         if ( $TAngle > 90 && $TAngle < 260 )
    18051924          {
     
    18832002
    18842003     /* Calculate all polygons */
     2004     // $Angle    = 0; $TopPlots = "";
    18852005     $Angle    = 260; $TopPlots = "";
    18862006     foreach($iValues as $Key => $Value)
     
    18982018         if ($TAngle > 359) $TAngle -= 360;
    18992019         if ($DrawLabels == PIE_PERCENTAGE)
     2020        //  $Caption  = (round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";
    19002021          $Caption  = (floor($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";
    1901          elseif ($DrawLabels == PIE_VALUES)
    1902           $Caption  = (floor($Value));
     2022          elseif ($DrawLabels == PIE_VALUES)
     2023           $Caption  = (floor($Value));
    19032024         elseif ($DrawLabels == PIE_LABELS)
    19042025          $Caption  = $iLabels[$Key];
     
    19062027         $TY       = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+10+$SpliceDistance) + $YPos + 4;
    19072028
     2029//         if ( $TAngle > 90 && $TAngle < 270 )
    19082030         if ( $TAngle > 90 && $TAngle < 260 )
    19092031          {
     
    19942116           {
    19952117            if ( $Data[$Key][$ColName] == 0 )
     2118           //  { $PieSum++; $iValues[] = 1; $rValues[] = 0; }
    19962119             { $PieSum += 0.00001; $iValues[] = 0.00001; $rValues[] = 0; }
    19972120            else
     
    20132136
    20142137     /* Calculate all polygons */
     2138   // $Angle    = 0; $TopPlots = ""; $BotPlots = ""; $CDev = 5;
    20152139     $Angle    = 260; $TopPlots = ""; $BotPlots = ""; $CDev = 5;
    20162140     foreach($iValues as $Key => $Value)
     
    20282152        {
    20292153         $TAngle   = $Angle+($Value*$SpliceRatio/2);
    2030          if ($TAngle > 359) $TAngle -= 360;
     2154         if ($TAngle > 359) $TAngle -= 360;
    20312155         if ($DrawLabels == PIE_PERCENTAGE)
     2156        //  $Caption  = (round($rValues[$Key] * pow(10,$Decimals) * $rSplicePercent)/pow(10,$Decimals))."%";
    20322157          $Caption  = (floor($rValues[$Key] * pow(10,$Decimals) * $rSplicePercent)/pow(10,$Decimals))."%";
    2033          elseif ($DrawLabels == PIE_VALUES)
    2034          if ($Value == 0) $Caption = '';
    2035          else $Caption  = (floor($Value));
    2036          elseif ($DrawLabels == PIE_LABELS)
     2158         elseif ($DrawLabels == PIE_VALUES) {
     2159          if ($Value == 0) $Caption = '';
     2160          else $Caption  = (floor($Value));
     2161         } elseif ($DrawLabels == PIE_LABELS)
    20372162          $Caption  = $iLabels[$Key];
    20382163
     2164        // $TX       = cos(($TAngle) * 3.1418 / 180 ) * ($Radius + 10)+ $XPos;
    20392165         $TX       = cos(($TAngle) * 3.1418 / 180 ) * ($Radius + 5)+ $XPos;
    20402166
     
    20442170          $TY = sin(($TAngle) * 3.1418 / 180 ) * ($SkewHeight + 10) + $YPos + 4;
    20452171
     2172        // if ( $TAngle > 90 && $TAngle < 270 )
    20462173         if ( $TAngle > 90 && $TAngle < 260 )
    20472174          {
     
    21292256     $C_Background = imagecolorallocate($this->Picture,$R,$G,$B);
    21302257     imagefilledrectangle($this->Picture,0,0,$this->XSize,$this->YSize,$C_Background);
     2258    }
     2259
     2260   /* This function can be used to set the background color */
     2261   function drawGraphAreaGradient($R,$G,$B,$Decay,$Target=TARGET_GRAPHAREA)
     2262    {
     2263     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
     2264     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
     2265     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
     2266
     2267     if ( $Target == TARGET_GRAPHAREA )  { $X1 = $this->GArea_X1+1; $X2 = $this->GArea_X2-1; $Y1 = $this->GArea_Y1+1; $Y2 = $this->GArea_Y2; }
     2268     if ( $Target == TARGET_BACKGROUND ) { $X1 = 0; $X2 = $this->XSize; $Y1 = 0; $Y2 = $this->YSize; }
     2269
     2270     $YStep = ($Y2 - $Y1 - 2) / $Decay;
     2271     for($i=0;$i<=$Decay;$i++)
     2272      {
     2273       $R-=1;$G-=1;$B-=1;
     2274       $Yi1 = $Y1 + ( $i * $YStep );
     2275       $Yi2 = ceil( $Yi1 + ( $i * $YStep ) + $YStep );
     2276       if ( $Yi2 >= $Yi2 ) { $Yi2 = $Y2-1; }
     2277
     2278       $C_Background = $this->AllocateColor($this->Picture,$R,$G,$B);
     2279       imagefilledrectangle($this->Picture,$X1,$Yi1,$X2,$Yi2,$C_Background);
     2280      }
    21312281    }
    21322282
     
    21512301   function drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B,$DrawBorder=TRUE,$Alpha=100)
    21522302    {
     2303     if ( $X2 > $X1 ) { list($X1, $X2) = array($X2, $X1); }
     2304     if ( $Y2 > $Y1 ) { list($Y1, $Y2) = array($Y2, $Y1); }
     2305
    21532306     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
    21542307     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
     
    24592612    }
    24602613
     2614   /* Add a border to the picture */
     2615   function addBorder($Size=3,$R=0,$G=0,$B=0)
     2616    {
     2617     $Width  = $this->XSize+2*$Size;
     2618     $Height = $this->YSize+2*$Size;
     2619
     2620     $Resampled    = imagecreatetruecolor($Width,$Height);
     2621     $C_Background = imagecolorallocate($Resampled,$R,$G,$B);
     2622     imagefilledrectangle($Resampled,0,0,$Width,$Height,$C_Background);
     2623
     2624     imagecopy($Resampled,$this->Picture,$Size,$Size,0,0,$this->XSize,$this->YSize);
     2625     imagedestroy($this->Picture);
     2626
     2627     $this->XSize = $Width;
     2628     $this->YSize = $Height;
     2629
     2630     $this->Picture = imagecreatetruecolor($this->XSize,$this->YSize);
     2631     $C_White = imagecolorallocate($this->Picture,255,255,255);
     2632     imagefilledrectangle($this->Picture,0,0,$this->XSize,$this->YSize,$C_White);
     2633     imagecolortransparent($this->Picture,$C_White);
     2634     imagecopy($this->Picture,$Resampled,0,0,0,0,$this->XSize,$this->YSize);
     2635    }
     2636
    24612637   /* Render the current picture to a file */
    24622638   function Render($FileName)
     
    24652641      $this->printErrors($this->ErrorInterface);
    24662642
     2643     /* Save image map if requested */
     2644     if ( $this->BuildMap )
     2645      $this->SaveImageMap();
     2646
    24672647     imagepng($this->Picture,$FileName);
    24682648    }
     
    24732653     if ( $this->ErrorReporting )
    24742654      $this->printErrors("GD");
     2655
     2656     /* Save image map if requested */
     2657     if ( $this->BuildMap )
     2658      $this->SaveImageMap();
    24752659
    24762660     header('Content-type: image/png');
     
    26032787        }
    26042788      }
     2789    }
     2790
     2791   /* Activate the image map creation process */
     2792   function setImageMap($Mode=TRUE,$GraphID="MyGraph")
     2793    {
     2794     $this->BuildMap = $Mode;
     2795     $this->MapID    = $GraphID;
     2796    }
     2797
     2798   /* Add a box into the image map */
     2799   function addToImageMap($X1,$Y1,$X2,$Y2,$SerieName,$Value,$CallerFunction)
     2800    {
     2801     if ( $this->MapFunction == NULL || $this->MapFunction == $CallerFunction )
     2802      {
     2803       $this->ImageMap[]  = round($X1).",".round($Y1).",".round($X2).",".round($Y2).",".$SerieName.",".$Value;
     2804       $this->MapFunction = $CallerFunction;
     2805      }
     2806    }
     2807
     2808   /* Load and cleanup the image map from disk */
     2809   function getImageMap($MapName,$Flush=TRUE)
     2810    {
     2811     /* Strip HTML query strings */
     2812     $Values   = $this->tmpFolder.$MapName;
     2813     $Value    = split("\?",$Values);
     2814     $FileName = $Value[0];
     2815
     2816     if ( file_exists($FileName) )
     2817      {
     2818       $Handle     = fopen($FileName, "r");
     2819       $MapContent = fread($Handle, filesize($FileName));
     2820       fclose($Handle);
     2821       echo $MapContent;
     2822
     2823       if ( $Flush )
     2824        unlink($FileName);
     2825
     2826       exit();
     2827      }
     2828     else
     2829      {
     2830       header("HTTP/1.0 404 Not Found");
     2831       exit();
     2832      }
     2833    }
     2834
     2835   /* Save the image map to the disk */
     2836   function SaveImageMap()
     2837    {
     2838     if ( !$this->BuildMap ) { return(-1); }
     2839
     2840     if ( $this->ImageMap == NULL )
     2841      {
     2842       $this->Errors[] = "[Warning] SaveImageMap - Image map is empty.";
     2843       return(-1);
     2844      }
     2845
     2846     $Handle = fopen($this->tmpFolder.$this->MapID, 'w');
     2847     if ( !$Handle )
     2848      {
     2849       $this->Errors[] = "[Warning] SaveImageMap - Cannot save the image map.";
     2850       return(-1);
     2851      }
     2852     else
     2853      {
     2854       foreach($this->ImageMap as $Key => $Value)
     2855        fwrite($Handle, htmlentities($Value)."\r");
     2856      }
     2857     fclose ($Handle);
    26052858    }
    26062859
  • cpc/trunk/project/plugins/xsPChartPlugin/lib/pChart/pChart/pData.class

    r1381 r1425  
    3131      SetAbsciseLabelSerie($SerieName = "Name")
    3232      SetSerieName($Name,$SerieName="Serie1")
     33  +   SetSerieSymbol($Name,$Symbol)
    3334      SetXAxisName($Name="X Axis")
    3435      SetYAxisName($Name="Y Axis")
     
    125126     for($i=0;$i<=count($this->Data);$i++)
    126127      { if(isset($this->Data[$i][$Serie])) { $ID = $i+1; } }
     128
    127129     if ( count($Value) == 1 )
    128130      {
     
    229231    }
    230232
     233   function SetSerieSymbol($Name,$Symbol)
     234    {
     235     $this->DataDescription["Symbol"][$Name] = $Symbol;
     236    }
     237
    231238   function removeSerieName($SerieName)
    232239    {
Note: See TracChangeset for help on using the changeset viewer.