Skip to content

Commit

Permalink
fixes #4206 it is now possible to render the graphs, fix is verified …
Browse files Browse the repository at this point in the history
…on the mentioned Piwik instance
  • Loading branch information
tsteur committed Nov 13, 2013
1 parent 5c8ba40 commit 516c13d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
16 changes: 13 additions & 3 deletions libs/pChart2.1.3/class/pDraw.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1016,17 +1016,27 @@ function drawText($X,$Y,$Text,$Format="")
if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
{
$C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$Text);
imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$this->getEncodedText($Text));
}

$C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha);
imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$Text);
imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$this->getEncodedText($Text));

$this->Shadow = $Shadow;

return($TxtPos);
}

function getEncodedText($text)
{
$gdinfo = gd_info();
if (!empty($gdinfo['JIS-mapped Japanese Font Support'])) {
return mb_convert_encoding($text, "SJIS", "UTF-8");
}

return $text;
}

/* Draw a gradient within a defined area */
function drawGradientArea($X1,$Y1,$X2,$Y2,$Direction,$Format="")
{
Expand Down Expand Up @@ -1388,7 +1398,7 @@ function drawArrowLabel($X1,$Y1,$Text,$Format="")

$this->drawArrow($X2,$Y2,$X1,$Y1,$Format);

$Size = imagettfbbox($FontSize,0,$FontName,$Text);
$Size = imagettfbbox($FontSize,0,$FontName,$this->getEncodedText($Text));
$TxtWidth = max(abs($Size[2]-$Size[0]),abs($Size[0]-$Size[6]));
$TxtHeight = max(abs($Size[1]-$Size[7]),abs($Size[3]-$Size[1]));

Expand Down
24 changes: 17 additions & 7 deletions libs/pChart2.1.3/class/pImage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function pImage($XSize,$YSize,$DataSet=NULL,$TransparentBackground=FALSE)
imagealphablending($this->Picture,FALSE);
imagefilledrectangle($this->Picture, 0,0,$XSize, $YSize, imagecolorallocatealpha($this->Picture, 255, 255, 255, 127));
imagealphablending($this->Picture,TRUE);
imagesavealpha($this->Picture,true);
imagesavealpha($this->Picture,true);
}
else
{
Expand Down Expand Up @@ -190,7 +190,7 @@ function getAngle($X1,$Y1,$X2,$Y2)
/* Return the surrounding box of text area */
function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text)
{
$Size = imagettfbbox($FontSize,$Angle,$FontName,$Text);
$Size = imagettfbbox($FontSize,$Angle,$FontName,$this->getEncodedText($Text));
$Width = $this->getLength($Size[0],$Size[1],$Size[2],$Size[3])+1;
$Height = $this->getLength($Size[2],$Size[3],$Size[4],$Size[5])+1;

Expand All @@ -205,10 +205,20 @@ function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text)
return($RealPos);
}

function getEncodedText($text)
{
$gdinfo = gd_info();
if (!empty($gdinfo['JIS-mapped Japanese Font Support'])) {
return mb_convert_encoding($text, "SJIS", "UTF-8");
}

return $text;
}

/* Return the surrounding box of text area */
function getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text)
{
$coords = imagettfbbox($FontSize, 0, $FontName, $Text);
$coords = imagettfbbox($FontSize, 0, $FontName, $this->getEncodedText($Text));

$a = deg2rad($Angle); $ca = cos($a); $sa = sin($a); $RealPos = array();
for($i = 0; $i < 7; $i += 2)
Expand Down Expand Up @@ -247,7 +257,7 @@ function setFontProperties($Format="")

if ( $FontName != NULL )
$this->FontName = $FontName;

if ( $FontSize != NULL )
$this->FontSize = $FontSize;
}
Expand Down Expand Up @@ -332,7 +342,7 @@ function replaceImageMapTitle($OldTitle, $NewTitle)
if ( $this->ImageMapStorageMode == NULL ) { return(-1); }

if ( is_array($NewTitle) ) { $NewTitle = $this->removeVOIDFromArray($OldTitle, $NewTitle); }

if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION )
{
if(!isset($_SESSION)) { return(-1); }
Expand Down Expand Up @@ -373,7 +383,7 @@ function replaceImageMapValues($Title, $Values)
if ( $this->ImageMapStorageMode == NULL ) { return(-1); }

$Values = $this->removeVOIDFromArray($Title, $Values);
$ID = 0;
$ID = 0;
if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION )
{
if(!isset($_SESSION)) { return(-1); }
Expand Down Expand Up @@ -460,7 +470,7 @@ function drawAreaMirror($X,$Y,$Width,$Height,$Format="")

$Picture = imagecreatetruecolor($this->XSize,$this->YSize);
imagecopy($Picture,$this->Picture,0,0,0,0,$this->XSize,$this->YSize);

for($i=1;$i<=$Height;$i++)
{
if ( $Y+($i-1) < $this->YSize && $Y-$i > 0 ) { imagecopymerge($Picture,$this->Picture,$X,$Y+($i-1),$X,$Y-$i,$Width,1,$StartAlpha-$AlphaStep*$i); }
Expand Down

0 comments on commit 516c13d

Please sign in to comment.