X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=reporting%2Fincludes%2Fclass.graphic.inc;h=31f0105fdb7276d4f40722d72e7270d57b65d0d2;hb=53d942f2a0d20cce5e9c409c6485867ce0869e4d;hp=c1133648eddd578edba73171f450009c6c341760;hpb=09d5c61846ddda0df907bb9c4e318cc7f1520653;p=fa-stable.git diff --git a/reporting/includes/class.graphic.inc b/reporting/includes/class.graphic.inc index c1133648..31f0105f 100644 --- a/reporting/includes/class.graphic.inc +++ b/reporting/includes/class.graphic.inc @@ -147,11 +147,18 @@ class graph var $h3d = 15; // 3D height var $built_in = true; var $fontfile = ""; - + var $encoding; + function graph() { - $this->x = $this->y = $this->z = array(); + $this->encoding = $_SESSION['language']->encoding; + $path = dirname(__FILE__).'/../fonts/'; + // If you use utf-8 encoding you have to download and install FreeSans.ttf font. + // It is not bundled with application due to its size. + $this->fontfile = $this->encoding=='UTF-8' ? $path.'FreeSans.ttf' : $path.'LiberationSans-Regular.ttf'; + + $this->x = $this->y = $this->z = array(); $this->biggest_x = NULL; $this->biggest_y = NULL; $this->alternate_x = false; @@ -203,6 +210,8 @@ class graph } $this->sum_total = array_sum($this->y); + if ($this->sum_total == 0) + $this->sum_total = 1; $this->space_between_bars += ($this->graphic_2_exists == true) ? 10 : 0; $this->calculate_higher_value(); @@ -488,6 +497,7 @@ class graph foreach ($this->x as $i => $parameter) { $size = $this->y[$i] * 360 / $this->sum_total; + $size = round2($size, 0); $sizes[] = $size; $start += $size; } @@ -509,7 +519,8 @@ class graph for ($i = $this->h3d; $i >= 0; $i--) { //imagearc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color]); - imagefilledarc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_NOFILL); + if ($size >= 1) + imagefilledarc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_NOFILL); } $start += $size; } @@ -525,8 +536,8 @@ class graph $num_color -= 5; } $color = 'arc_' . $num_color; - - imagefilledarc($this->img, $center_x, $center_y, ($width+2), ($height+2), $start, ($start+$size), $this->color[$color], IMG_ARC_EDGED); + if ($size >= 1) + imagefilledarc($this->img, $center_x, $center_y, ($width+2), ($height+2), $start, ($start+$size), $this->color[$color], IMG_ARC_EDGED); $start += $size; } } @@ -543,7 +554,8 @@ class graph } $color = 'arc_' . $num_color; $color_shadow = 'arc_' . $num_color . '_shadow'; - imagefilledarc($this->img, $center_x, $center_y, $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_PIE); + if ($size >= 1) + imagefilledarc($this->img, $center_x, $center_y, $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_PIE); $start += $size; } imagefilledarc($this->img, $center_x, $center_y, 100, 100, 0, 360, $this->color['background'], IMG_ARC_PIE); @@ -595,7 +607,7 @@ class graph $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10; $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size); $this->width += $this->graphic_area_x1 + 20; - $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 10); + $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30); break; // Lines @@ -604,7 +616,7 @@ class graph $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10; $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size); $this->width += $this->graphic_area_x1 + 20; - $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 10); + $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30); break; // Pie @@ -622,6 +634,7 @@ class graph break; } + $this->graphic_area_width = max($this->graphic_area_width, $this->string_width($this->title, $this->size)); $this->width += $this->graphic_area_width; $this->width += $this->legend_box_width; @@ -722,7 +735,8 @@ class graph { if (!empty($this->axis_x)) { - $this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($this->axis_x)*7/2)), $y, $this->axis_x, $this->color['title']); + $this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($this->axis_x)*7/2)), $y, + $this->axis_x." (".$this->graphic_1.")", $this->color['title']); $y += 25; } @@ -942,6 +956,14 @@ class graph { if ($alt && strlen($string) > 12) $string = substr($string, 0, 12); + + if ($this->encoding != 'UTF-8') { + if (function_exists('iconv')) + $string = iconv($this->encoding, 'UTF-8', $string); + else + $string = mb_convert_encoding($string, 'UTF-8', $this->encoding); + } + if ($this->built_in) { imagestring($img, $size, $x, $y + $alt, $string, $col); @@ -963,6 +985,7 @@ class graph // $angle = -15; //else $angle = 0; + imagettftext($img, $size, $angle, $x, $y + $alt, $col, $this->fontfile, $string); } }