function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
 {
     $width = 340;
     $height = 220;
     //	$labelfont = '2';
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($post_var)) {
         ${$kk} = $vv;
     }
     /*
     $to_date=2004-01-02;
     $from_date=2004-01-02;
     $avg_rater=50.23;
     */
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
     //$border2 = ImageColorAllocate($image,0x000000, 0xcccccc, 0x000000);
     ImageRectangle($image, 40, 20, 240, 160, $border);
     ImageString($image, $labelfont, 15, 20, "100%", $border);
     ImageString($image, $labelfont, 20, 55, "75%", $border);
     ImageString($image, $labelfont, 20, 90, "50%", $border);
     ImageString($image, $labelfont, 20, 125, "25%", $border);
     ImageString($image, $labelfont, 20, 155, "0%", $border);
     $fdate = $learning->changedate_display($from_date);
     $tdate = $learning->changedate_display($to_date);
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     $avg_rt = @explode(",", $avg_rater);
     $id = @explode(",", $ids);
     for ($i = 0; $i < count($avg_rt); $i++) {
         $p1 = rand(0, 200);
         $p2 = rand(30, 250);
         $p3 = rand(100, 250);
         $color = imagecolorallocate($image, $p1, $p2, $p3);
         $avg = $avg_rt[$i];
         $avg_comp = 160 - 140 / 100 * $avg;
         $avg = round($avg, 2);
         $rid = $id[$i];
         $rname = $common->name_display($db_object, $rid);
         ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
         ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
         ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
         //ImageString($image, $labeltitlefont, 50,180, "$rname", $color);
         ImageLine($image, 240, 20, 40, 160, $border1);
         //COMMITMENT LINE
         ImageLine($image, 240, $avg_comp, 40, 160, $color);
         //AVERAGE COMPLETION
         header("Content-type: image/png");
         // or "Content-type: image/png"
         Imagepng($image);
         // or imagepng($image)
     }
     ImageDestroy($image);
 }
Example #2
0
function drawTitles($image, $w, $h, $col, $title, $xtitle, $ytitle)
{
    $width = ImageFontWidth(1) * strlen($title);
    $x = ($w - $width) / 2;
    ImageString($image, 1, $x, 3, $title, $col);
    $width = ImageFontWidth(1) * strlen($ytitle);
    $x = ($w - $width) / 2;
    ImageString($image, 1, $x, $h - 10, $ytitle, $col);
    $height = ImageFontWidth(1) * strlen($xtitle);
    $y = ($h - $height) / 2;
    ImageStringUp($image, 1, 1, $y + $height, $xtitle, $col);
}
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
 {
     $width = 340;
     $height = 220;
     //	$labelfont = '2';
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($post_var)) {
         ${$kk} = $vv;
     }
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
     $border2 = ImageColorAllocate($image, 0x0, 0xcccccc, 0x0);
     ImageRectangle($image, 40, 20, 240, 160, $border);
     ImageString($image, $labelfont, 15, 20, "100%", $border);
     ImageString($image, $labelfont, 20, 55, "75%", $border);
     ImageString($image, $labelfont, 20, 90, "50%", $border);
     ImageString($image, $labelfont, 20, 125, "25%", $border);
     ImageString($image, $labelfont, 20, 155, "0%", $border);
     $fdate = $learning->changedate_display($from_date);
     $tdate = $learning->changedate_display($to_date);
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     $avg_comp = 160 - 140 / 100 * $avg;
     $avg = round($avg, 2);
     ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
     ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
     ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
     ImageString($image, $labeltitlefont, 50, 200, $error_msg['cCTimelyCompletionofActivities'], $border);
     ImageString($image, $labeltitlefont, 50, 185, $error_msg['cAverage'], $border);
     ImageString($image, $labeltitlefont, 115, 185, $avg, $border);
     ImageLine($image, 240, 20, 40, 160, $border1);
     //COMMITMENT LINE
     ImageLine($image, 240, $avg_comp, 40, 160, $border2);
     //AVERAGE COMPLETION
     ImageString($image, $labeltitlefont, 245, $avg_comp, $error_msg['cAccomplishment'], $border);
     header("Content-type: image/png");
     // or "Content-type: image/png"
     Imagepng($image);
     // or imagepng($image)
     ImageDestroy($image);
 }
 function createGistagramm($width, $heigth)
 {
     $image = @imagecreate($width, $heigth);
     $maxKey = findMaxKey($this->array);
     $maxValue = findMaxValue($this->array);
     ImageColorAllocate($image, 255, 255, 255);
     ImageLine($image, $this->align, $heigth - $this->align, $width - $this->align, $heigth - $this->align, 1);
     ImageLine($image, $this->align, $this->align, $this->align, $heigth - $this->align, 1);
     $widthRect = round(($width - 2 * $this->align) / ($maxKey + 1)) * $this->widthColumn;
     foreach ($this->array as $key => $value) {
         $color = getColor($image, $value, $maxValue);
         $heigthRect = round($value * ($heigth - 2 * $this->align) / $maxValue);
         $pos = round($key / ($maxKey + 1) * ($width - 2 * $this->align)) + $this->align;
         ImageFilledRectangle($image, $pos - $widthRect / 2, $heigth - $heigthRect, $pos + $widthRect / 2, $heigth - $this->align, $color);
         $white = ImageColorAllocate($image, 217, 220, 57);
         ImageStringUp($image, 0, $pos - $widthRect / 2 + 4, $heigth - $heigthRect / 2, $value, $white);
         ImageString($image, 0, $pos - $widthRect / 2, $heigth - $this->align, $key, 1);
     }
     $this->image = $image;
 }
Example #5
0
 /**
  * Convierte un texto a imagen
  * @param string $texto
  */
 public function executeText2img(sfWebRequest $request)
 {
     //fuente por defecto
     $this->font = 2;
     //obtengo el texto
     $texto = utf8_decode($request->getParameter('texto', 'null'));
     //seteo el header
     header("Content-type: image/png");
     // calculo el alto
     $alto = strlen($texto) * imagefontwidth($this->font) + imagefontwidth($this->font);
     $img_handle = imagecreatetruecolor(imagefontheight($this->font), $alto) or die("Cannot Create image");
     // ImageColorAllocate (image, red, green, blue)
     $back_color = ImageColorAllocate($img_handle, 255, 255, 255);
     $txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
     ImageFill($img_handle, 0, 0, $back_color);
     ImageStringUp($img_handle, $this->font, 0, $alto - imagefontwidth($this->font) / 2, $texto, $txt_color);
     ImagePng($img_handle);
     ImageDestroy($img_handle);
     return sfView::NONE;
 }
Example #6
0
 function MakeBarChart()
 {
     // #DEFINITIONS#####################################
     $chartx = 5;
     $charty = 5;
     $chartw = $this->Width - 10;
     $charth = $this->Height - 10;
     $im = imagecreate($this->Width, $this->Height);
     $black = ImageColorAllocate($im, 0, 0, 0);
     $white = ImageColorAllocate($im, 255, 255, 255);
     imagesetstyle($im, array($black, $black, $black, $white, $white, $white));
     $colors[0] = ImageColorAllocate($im, 100, 149, 237);
     $colors[1] = ImageColorAllocate($im, 240, 128, 128);
     $colors[2] = ImageColorAllocate($im, 50, 205, 50);
     $colors[3] = ImageColorAllocate($im, 255, 215, 0);
     $colors[4] = ImageColorAllocate($im, 131, 111, 255);
     $colors[5] = ImageColorAllocate($im, 144, 238, 144);
     $colors[6] = ImageColorAllocate($im, 70, 130, 180);
     $colors[7] = ImageColorAllocate($im, 244, 164, 96);
     $colors[8] = ImageColorAllocate($im, 139, 121, 94);
     $colors[9] = ImageColorAllocate($im, 190, 190, 190);
     $font1 = 5;
     $ifh1 = ImageFontHeight($font1);
     $ifw1 = ImageFontWidth($font1);
     $font2 = 4;
     $ifh2 = ImageFontHeight($font2);
     $ifw2 = ImageFontWidth($font2);
     $font3 = 3;
     $ifh3 = ImageFontHeight($font3);
     $ifw3 = ImageFontWidth($font3);
     // #################################################
     ImageFill($im, 0, 0, $white);
     // #DRAWING CAPTIONS################################
     if ($this->Title) {
         $len = strlen($this->Title) * $ifw1;
         ImageString($im, $font1, ($this->Width - $len) / 2, $charty, $this->Title, $black);
         ImageLine($im, ($this->Width - $len) / 2, $charty + $ifh1, ($this->Width + $len) / 2, $charty + $ifh1, $black);
         $charty += $ifh1 + 5;
         $charth -= $ifh1 + 5;
     }
     if ($this->SubTitle) {
         // GET A LITTLE NEAR TO TITLE
         $charty -= 3;
         $charth += 3;
         $len = strlen($this->SubTitle) * $ifw3;
         ImageString($im, $font3, ($this->Width - $len) / 2, $charty, $this->SubTitle, $black);
         $charty += $ifh3 + 5;
         $charth -= $ifh3 + 5;
     }
     if ($this->xCaption) {
         $len = strlen($this->xCaption) * $ifw3;
         ImageString($im, $font3, ($this->Width - $len) / 2, $this->Height - $ifh3 - 5, $this->xCaption, $black);
         $charth -= $ifh3 + 5;
     }
     if ($this->yCaption) {
         $len = strlen($this->yCaption) * $ifw3;
         ImageStringUp($im, $font3, $chartx, ($this->Height + $len) / 2, $this->yCaption, $black);
         $chartx += $ifh3 + 15;
         $chartw -= $ifh3 + 15;
     }
     // #################################################
     /* X,Y AXIS MUST BE RESIZED TO FIT THE LONGEST CAPTION
     		BEFORE WE START DRAWING ON THEM */
     // #RESERVING SPACE FOR X VALUES####################
     if ($this->xCount && $this->xShowValue) {
         $xValueMaxLen = 0;
         if (is_array($this->xValue)) {
             foreach ($this->xValue as $value) {
                 $xValueMaxLen = max($xValueMaxLen, strlen($value));
             }
         }
         $charth -= $xValueMaxLen * $ifw3 + 5;
     }
     // #################################################
     // #RESERVING SPACE FOR Y VALUES####################
     if ($this->yCount) {
         $yValueMaxLen = 0;
         $yScale = array();
         $valueInc = ($this->DataMax - $this->DataMin) / $this->yCount;
         $value = $this->DataMin;
         for ($i = 0; $i <= $this->yCount; $i++) {
             if (isset($this->DataDecimalPlaces)) {
                 $str = number_format($value, $this->DataDecimalPlaces, ',', '');
             } else {
                 $str = $value;
             }
             $yValueMaxLen = max($yValueMaxLen, strlen($str));
             $yAxis[] = $str;
             $value += $valueInc;
         }
         // THE SPACE SHOULD BE RESERVED ONLY IF WE ARE GOING TO PRINT THE VALUES
         if ($this->yShowValue) {
             $chartx += $yValueMaxLen * $ifw3 + 5;
             $chartw -= $yValueMaxLen * $ifw3 + 5;
         }
     }
     // #################################################
     // #DRAWING VALUES AT X AXIS########################
     if ($this->xCount) {
         $xdelta = $chartw / (3 * $this->xCount + 1);
         if ($xdelta > 15) {
             $xdelta = 15;
         }
         // WE DONT WANT BAR WIDTH BIGGER THAN 30px
         for ($i = 0; $i < $this->xCount; $i++) {
             if ($this->xShowValue) {
                 $xoff = $chartx + $xdelta * (3 * $i + 2) - $ifh3 / 2;
                 if ($this->xValue[$i]) {
                     ImageStringUp($im, $font3, $xoff, $charty + $charth + 5 + strlen($this->xValue[$i]) * $ifw3, $this->xValue[$i], $black);
                 }
             }
             if ($this->yShowGrid && !($i % $this->yTriggerGrid)) {
                 $xoff += $ifh3 / 2;
                 ImageLine($im, $xoff, $charty, $xoff, $charty + $charth, IMG_COLOR_STYLED);
             }
         }
     }
     // #################################################
     // #DRAWING VALUES AT Y AXIS########################
     if ($this->yCount) {
         $yInc = $charth / $this->yCount;
         $yDraw = $charty;
         foreach ($yAxis as $value) {
             if ($this->yShowValue) {
                 ImageString($im, $font3, $chartx - 5 - strlen($value) * $ifw3, $yDraw + $charth - $ifh3 / 2, $value, $black);
             }
             // TO BE IMPLEMENTED YET
             //if (($this->xShowGrid) && !($i % $this->xTriggerGrid))
             if ($this->xShowGrid) {
                 ImageLine($im, $chartx, $yDraw + $charth, $chartx + $chartw, $yDraw + $charth, IMG_COLOR_STYLED);
             }
             $yDraw -= $yInc;
         }
     }
     // #################################################
     // #DRAWING AXIS####################################
     ImageLine($im, $chartx - 2, $charty + $charth, $chartx + $chartw, $charty + $charth, $black);
     ImageLine($im, $chartx, $charty, $chartx, $charty + $charth + 2, $black);
     // #################################################
     // #DRAWING DATA####################################
     if ($this->xCount) {
         $j = 0;
         for ($i = 0; $i < $this->xCount; $i++) {
             $xoff = $chartx + ($i * 3 + 1) * $xdelta;
             $barh = $this->DataValue[$i] / $this->DataMax * $charth;
             $top = $charty + $charth - $barh;
             ImageFilledRectangle($im, $xoff - 1, $top - 1, $xoff + 2 * $xdelta, $charty + $charth, $black);
             // SHADOW
             ImageFilledRectangle($im, $xoff, $top, $xoff + 2 * $xdelta - 5, $charty + $charth - 2, $colors[$j]);
             // COLOUR BAR
             $len = strlen($this->DataValue[$i]) * $ifw3;
             if ($this->DataShowValue && $len < $barh) {
                 ImageStringUp($im, $font3, $xoff, $top + $len, $this->DataValue[$i], $white);
             }
             $j = ($j + 1) % 9;
         }
     }
     // #################################################
     ImagePNG($im);
     ImageDestroy($im);
 }
Example #7
0
 /**
  * SetyTitle sets a title to the left of the y-axis.
  */
 function SetyTitle($ytitle)
 {
     $text_left = 10;
     $text_top = $this->image_height / 2 + strlen($ytitle) * 2.4;
     ImageStringUp($this->im, 1, $text_left, $text_top, $ytitle, $this->color['black']);
 }
 /**
  * Write a text on the canvas
  * @param int $x The X (horizontal) position of the text 
  * @param int $y The Y (vertical) position of the text 
  * @param string $text The text to write on the canvas 
  * @access private 
  */
 function _write($x, $y, $text)
 {
     ImageStringUp($this->_canvas(), IMAGE_GRAPH_FONT, $x, $y + $this->height($text), $text, $this->_getColor());
 }
Example #9
0
<?php

$im = ImageCreate(175, 125);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
ImageString($im, 1, 10, 20, "Font 1: ABCdef", $black);
ImageString($im, 2, 10, 35, "Font 2: ABCdef", $black);
ImageString($im, 3, 10, 53, "Font 3: ABCdef", $black);
ImageString($im, 4, 10, 70, "Font 4: ABCdef", $black);
ImageString($im, 5, 10, 90, "Font 5: ABCdef", $black);
ImageStringUp($im, 5, 150, 118, "Vertical Text", $black);
Header('Content-Type: image/png');
ImagePNG($im);
Example #10
0
    /**
     * Output the element to the canvas
     * @see Image_Graph_Common 
     * @access private
     */
    function _done()
    {
        if (is_a($this->_fillStyle, "Image_Graph_Fill")) {
            $this->_fillStyle->_reset();
        }
                
        if ($this->_background != null) {
            $this->_debug("Drawing background");
            ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $this->_getBackground());
        }

        if ($this->_identify) {
            $this->_debug("Identifying");
            $red = rand(0, 255);
            $green = rand(0, 255);
            $blue = rand(0, 255);
            $color = ImageColorAllocate($this->_canvas(), $red, $green, $blue);
            if (isset($GLOBALS['_Image_Graph_gd2'])) {
                $alphaColor = ImageColorResolveAlpha($this->_canvas(), $red, $green, $blue, 200);
            } else {
                $alphaColor = $color;
            }

            ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $color);
            ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $alphaColor);

            if ($this->_identifyText) {
                $text = eregi_replace("<[^>]*>([^<]*)", "\\1", $this->_identification());
                if (ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text) > $this->width()) {
                    $x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2));
                    $y = max($this->_top, min($this->_bottom, $this->_bottom - ($this->height() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2));
                    ImageStringUp($this->_canvas(), FONT, $x, $y, $text, $color);
                } else {
                    $x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2));
                    $y = max($this->_top, min($this->_bottom, $this->_top + ($this->height() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2));
                    ImageString($this->_canvas(), FONT, $x, $y, $text, $color);
                }
            }
        }

        if ($this->_borderStyle != null) {
            $this->_debug("Drawing border");
            ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, ((is_a($this->_borderStyle, "Image_Graph_Color")) ? $this->_borderStyle->_index : $this->_borderStyle->_getLineStyle()));
        }
        parent::_done();
        
        if ($this->_shadow) {
            $this->_displayShadow();
        }
    }
Example #11
0
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
define('ZBX_PAGE_NO_AUTHERIZATION', 1);
require_once "include/config.inc.php";
$page['file'] = 'vtext.php';
$page['type'] = PAGE_TYPE_IMAGE;
include_once "include/page_header.php";
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array("text" => array(T_ZBX_STR, O_OPT, P_SYS, null, null), "font" => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 5), null));
check_fields($fields);
$text = get_request("text", ' ');
$font = get_request("font", 3);
$width = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);
$im = imagecreate($height, $width);
$backgroud_color = ImageColorAllocate($im, 255, 255, 255);
$text_color = ImageColorAllocate($im, 0, 0, 0);
ImageStringUp($im, $font, 0, $width - 1, $text, $text_color);
imagecolortransparent($im, $backgroud_color);
ImageOut($im);
ImageDestroy($im);
include_once "include/page_footer.php";
Example #12
0
list($LangName, $valid) = ValidLangs($WhiteListLangs, TRUE);
list($Shapes, $valid) = ValidMatrix('s', 1, $valid);
for ($i = 0; $i < sizeof($Shapes); $i++) {
    $Shapes[$i] = log10($Shapes[$i]);
}
list($Centers, $valid) = ValidMatrix('c', 1, $valid);
for ($i = 0; $i < sizeof($Centers); $i++) {
    $Centers[$i] = log10($Centers[$i]);
}
// CHART //////////////////////////////////////////////////
$w = 150;
$h = 120;
$xo = 48;
$yo = MARGIN;
$chart = new ShapeChart();
if ($valid) {
    $chart->yAxis(log10axis(axis3_5_10()));
    $chart->xAxis(log10axis(axisOneTen()), 101.0);
    $chart->frame();
    $chart->title_($LangName[0], 2, CHAR_WIDTH_2);
    // hard-code a shortest programs example
    if (!isset($LangName[0])) {
        $chart->title_('Shortest C++', 2, CHAR_WIDTH_2);
    }
    $chart->shapes($Shapes, $Centers);
    $label = 'concise';
    ImageString($chart->im, 2, $xo, $h - $yo + 4, $label, $chart->colour[DARK_GRAY]);
    $label = 'fast';
    ImageStringUp($chart->im, 2, 30, $h, $label, $chart->colour[DARK_GRAY]);
}
$chart->complete();
Example #13
0
/**
 * print ancestors on a fan chart
 *
 * @param array $treeid ancestry pid
 * @param int $fanw fan width in px (default=640)
 * @param int $fandeg fan size in deg (default=270)
 */
function print_fan_chart($treeid, $fanw = 640, $fandeg = 270)
{
    global $PEDIGREE_GENERATIONS, $fan_width, $fan_style;
    global $name, $pgv_lang, $SHOW_ID_NUMBERS, $view, $TEXT_DIRECTION;
    global $stylesheet, $print_stylesheet;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $LINK_ICONS, $GEDCOM;
    // check for GD 2.x library
    if (!defined("IMG_ARC_PIE")) {
        print "<span class=\"error\">" . $pgv_lang["gd_library"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    if (!function_exists("ImageTtfBbox")) {
        print "<span class=\"error\">" . $pgv_lang["gd_freetype"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    // parse CSS file
    include "includes/cssparser.inc.php";
    $css = new cssparser(false);
    if ($view == "preview") {
        $css->Parse($print_stylesheet);
    } else {
        $css->Parse($stylesheet);
    }
    // check for fontfile
    $fontfile = $css->Get(".fan_chart", "font-family");
    $fontsize = $css->Get(".fan_chart", "font-size");
    $fontfile = str_replace("url(", "", $fontfile);
    $fontfile = str_replace(")", "", $fontfile);
    if (!file_exists($fontfile)) {
        if (!empty($fontfile)) {
            print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        }
        $fontfile = "./includes/fonts/DejaVuSans.ttf";
    }
    if ($fontfile[0] != '/') {
        $fontfile = dirname(__FILE__) . "/" . $fontfile;
    }
    if (!file_exists($fontfile)) {
        print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        return false;
    }
    if (intval($fontsize) < 2) {
        $fontsize = 7;
    }
    $treesize = count($treeid);
    if ($treesize < 1) {
        return;
    }
    // generations count
    $gen = log($treesize) / log(2) - 1;
    $sosa = $treesize - 1;
    // fan size
    if ($fandeg == 0) {
        $fandeg = 360;
    }
    $fandeg = min($fandeg, 360);
    $fandeg = max($fandeg, 90);
    $cx = $fanw / 2 - 1;
    // center x
    $cy = $cx;
    // center y
    $rx = $fanw - 1;
    $rw = $fanw / ($gen + 1);
    $fanh = $fanw;
    // fan height
    if ($fandeg == 180) {
        $fanh = round($fanh * ($gen + 1) / ($gen * 2));
    }
    if ($fandeg == 270) {
        $fanh = round($fanh * 0.86);
    }
    $scale = $fanw / 640;
    // image init
    $image = ImageCreate($fanw, $fanh);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
    ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
    ImageColorTransparent($image, $white);
    $rgb = $css->Get(".fan_chart", "color");
    if (empty($rgb)) {
        $rgb = "#000000";
    }
    $color = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart", "background-color");
    if (empty($rgb)) {
        $rgb = "#EEEEEE";
    }
    $bgcolor = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_box", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0D0AC";
    }
    $bgcolorM = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_boxF", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0ACD0";
    }
    $bgcolorF = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // imagemap
    $imagemap = "<map id=\"fanmap\" name=\"fanmap\">";
    // loop to create fan cells
    while ($gen >= 0) {
        // clean current generation area
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $fandeg;
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
        $rx -= 3;
        // calculate new angle
        $p2 = pow(2, $gen);
        $angle = $fandeg / $p2;
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $angle;
        // special case for rootid cell
        if ($gen == 0) {
            $deg1 = 90;
            $deg2 = 360 + $deg1;
        }
        // draw each cell
        while ($sosa >= $p2) {
            $pid = $treeid[$sosa];
            if (!empty($pid)) {
                $indirec = find_person_record($pid);
                if (!$indirec) {
                    $indirec = find_updated_record($pid);
                }
                if ($sosa % 2) {
                    $bg = $bgcolorF;
                } else {
                    $bg = $bgcolorM;
                }
                if ($sosa == 1) {
                    $bg = $bgcolor;
                    // sex unknown
                    if (preg_match("/1 SEX F/", $indirec) > 0) {
                        $bg = $bgcolorF;
                    } else {
                        if (preg_match("/1 SEX M/", $indirec) > 0) {
                            $bg = $bgcolorM;
                        }
                    }
                }
                ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                $person = Person::getInstance($pid);
                $name = $person->getFullName();
                $addname = $person->getAddName();
                //$name = str_replace(array('<span class="starredname">', '</span>'), '', $name);
                //$addname = str_replace(array('<span class="starredname">', '</span>'), '', $addname);
                //$name = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $name); //@@
                //$addname = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $addname); //@@
                // ToDo - print starred names underlined - 1985154
                // Todo - print Arabic letters combined - 1360209
                $text = reverseText($name) . "\n";
                if (!empty($addname)) {
                    $text .= reverseText($addname) . "\n";
                }
                if (displayDetailsById($pid)) {
                    $birthrec = get_sub_record(1, "1 BIRT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $birthrec, $match);
                    if ($ct > 0) {
                        $text .= trim($match[1]);
                    }
                    $deathrec = get_sub_record(1, "1 DEAT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $deathrec, $match);
                    if ($ct > 0) {
                        $text .= "-" . trim($match[1]);
                    }
                }
                $text = unhtmlentitiesrtl($text);
                $text = strip_tags($text);
                //Do we still need?
                // split and center text by lines
                $wmax = floor($angle * 7 / $fontsize * $scale);
                $wmax = min($wmax, 35 * $scale);
                if ($gen == 0) {
                    $wmax = min($wmax, 17 * $scale);
                }
                $text = split_align_text($text, $wmax);
                // text angle
                $tangle = 270 - ($deg1 + $angle / 2);
                if ($gen == 0) {
                    $tangle = 0;
                }
                // calculate text position
                $bbox = ImageTtfBbox((double) $fontsize, 0, $fontfile, $text);
                $textwidth = $bbox[4];
                $deg = $deg1 + 0.44;
                if ($deg2 - $deg1 > 40) {
                    $deg = $deg1 + ($deg2 - $deg1) / 11;
                }
                if ($deg2 - $deg1 > 80) {
                    $deg = $deg1 + ($deg2 - $deg1) / 7;
                }
                if ($deg2 - $deg1 > 140) {
                    $deg = $deg1 + ($deg2 - $deg1) / 4;
                }
                if ($gen == 0) {
                    $deg = 180;
                }
                $rad = deg2rad($deg);
                $mr = ($rx - $rw / 4) / 2;
                if ($gen > 0 and $deg2 - $deg1 > 80) {
                    $mr = $rx / 2;
                }
                $tx = $cx + $mr * cos($rad);
                $ty = $cy - $mr * -sin($rad);
                if ($sosa == 1) {
                    $ty -= $mr / 2;
                }
                // print text
                ImageTtfText($image, (double) $fontsize, $tangle, $tx, $ty, $color, $fontfile, $text);
                $imagemap .= "<area shape=\"poly\" coords=\"";
                // plot upper points
                $mr = $rx / 2;
                $deg = $deg1;
                while ($deg <= $deg2) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg += ($deg2 - $deg1) / 6;
                }
                // plot lower points
                $mr = ($rx - $rw) / 2;
                $deg = $deg2;
                while ($deg >= $deg1) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg -= ($deg2 - $deg1) / 6;
                }
                // join first point
                $mr = $rx / 2;
                $deg = $deg1;
                $rad = deg2rad($deg);
                $tx = round($cx + $mr * cos($rad));
                $ty = round($cy - $mr * -sin($rad));
                $imagemap .= "{$tx}, {$ty}";
                // add action url
                $tempURL = "javascript://" . htmlspecialchars(strip_tags($name));
                if ($SHOW_ID_NUMBERS) {
                    $tempURL .= " (" . $pid . ")";
                }
                $imagemap .= "\" href=\"{$tempURL}\" ";
                $tempURL = "fanchart.php?rootid={$pid}&PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}&fan_width={$fan_width}&fan_style={$fan_style}";
                if (!empty($view)) {
                    $tempURL .= "&view={$view}";
                }
                $count = 0;
                $lbwidth = 200;
                print "<div id=\"I" . $pid . "." . $count . "links\" style=\"position:absolute; >";
                print "left:" . $tx . "px; top:" . $ty . "px; width: " . $lbwidth . "px; visibility:hidden; z-index:'100';\">";
                print "<table class=\"person_box\"><tr><td class=\"details1\">";
                print "<a href=\"individual.php?pid={$pid}\" class=\"name1\">" . PrintReady($name);
                if (!empty($addname)) {
                    print "<br />" . PrintReady($addname);
                }
                print "</a>";
                print "<br /><a href=\"pedigree.php?rootid={$pid}\" >" . $pgv_lang["index_header"] . "</a>";
                print "<br /><a href=\"descendancy.php?pid={$pid}\" >" . $pgv_lang["descend_chart"] . "</a>";
                if (PGV_USER_GEDCOM_ID) {
                    print "<br /><a href=\"" . encode_url("relationship.php?pid1=" . PGV_USER_GEDCOM_ID . "&pid2={$pid}&ged={$GEDCOM}") . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["relationship_to_me"] . "</a>";
                }
                print "<br /><a href=\"ancestry.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["ancestry_chart"] . "</a>";
                print "<br /><a href=\"compact.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["compact_chart"] . "</a>";
                print "<br /><a href=\"" . encode_url($tempURL) . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["fan_chart"] . "</a>";
                print "<br /><a href=\"hourglass.php?pid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["hourglass_chart"] . "</a>";
                if ($sosa >= 1) {
                    $famids = find_sfamily_ids($pid);
                    //-- make sure there is more than 1 child in the family with parents
                    $cfamids = find_family_ids($pid);
                    $num = 0;
                    for ($f = 0; $f < count($cfamids); $f++) {
                        $famrec = find_family_record($cfamids[$f]);
                        if ($famrec) {
                            $num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        }
                    }
                    if ($famids || $num > 1) {
                        //-- spouse(s) and children
                        for ($f = 0; $f < count($famids); $f++) {
                            $famrec = find_family_record(trim($famids[$f]));
                            if ($famrec) {
                                $parents = find_parents($famids[$f]);
                                if ($parents) {
                                    if ($pid != $parents["HUSB"]) {
                                        $spid = $parents["HUSB"];
                                    } else {
                                        $spid = $parents["WIFE"];
                                    }
                                    $person = Person::getInstance($spid);
                                    if ($person) {
                                        echo '<br /><a href="', $person->getLinkUrl(), '" class="name1">', $person->getFullName(), '</a>';
                                    }
                                }
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                for ($i = 0; $i < $num; $i++) {
                                    $person = Person::getInstance($smatch[$i][1]);
                                    if ($person) {
                                        echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1">&lt; ', $person->getFullName(), '</a>';
                                    }
                                }
                            }
                        }
                        //-- siblings
                        for ($f = 0; $f < count($cfamids); $f++) {
                            $famrec = find_family_record($cfamids[$f]);
                            if ($famrec) {
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                if ($num > 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["siblings"] . "</span>";
                                }
                                if ($num == 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["sibling"] . "</span>";
                                }
                                for ($i = 0; $i < $num; $i++) {
                                    $cpid = $smatch[$i][1];
                                    if ($cpid != $pid) {
                                        $person = Person::getInstance($cpid);
                                        if ($person) {
                                            echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1"> ', $person->getFullName(), '</a>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                print "</td></tr></table>";
                print "</div>";
                $imagemap .= " onclick=\"show_family_box('" . $pid . "." . $count . "', 'relatives'); return false;\"";
                $imagemap .= " onmouseout=\"family_box_timeout('" . $pid . "." . $count . "'); return false;\"";
                $imagemap .= " alt=\"" . PrintReady(strip_tags($name)) . "\" title=\"" . PrintReady(strip_tags($name)) . "\" />";
            }
            $deg1 -= $angle;
            $deg2 -= $angle;
            $sosa--;
        }
        $rx -= $rw;
        $gen--;
    }
    $imagemap .= "</map>";
    echo $imagemap;
    // PGV banner ;-)
    ImageStringUp($image, 1, $fanw - 10, $fanh / 3, PGV_PHPGEDVIEW_URL, $color);
    // here we cannot send image to browser ('header already sent')
    // and we dont want to use a tmp file
    // step 1. save image data in a session variable
    ob_start();
    ImagePng($image);
    $image_data = ob_get_contents();
    ob_end_clean();
    $image_data = serialize($image_data);
    unset($_SESSION['image_data']);
    $_SESSION['image_data'] = $image_data;
    // step 2. call imageflush.php to read this session variable and display image
    // note: arg "image_name=" is to avoid image miscaching
    $image_name = "V" . time();
    unset($_SESSION[$image_name]);
    // statisticsplot.php uses this to hold a file name to send to browser
    $image_title = preg_replace("~<.*>~", "", $name) . " " . $pgv_lang["fan_chart"];
    echo "<p align=\"center\" >";
    echo "<img src=\"imageflush.php?image_type=png&amp;image_name={$image_name}&amp;height={$fanh}&amp;width={$fanw}\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\" />";
    echo "</p>";
    ImageDestroy($image);
}
Example #14
0
    $x += 20;
    $x1 = $x;
    $chart->xo = $x;
    $chart->barspace = 3;
    $chart->barwidth = 5;
    $x = $chart->bars(DARK_GRAY, $gz, FALSE);
    $label = 'Code';
    $z = $x1 + ($x - $x1 - strlen($label) * CHAR_WIDTH_2) / 2.0;
    ImageString($chart->im, 2, $z, $chart->h - 30, $label, $chart->colour[BLACK]);
    ImageString($chart->im, 2, $z, 23, $label, $chart->colour[BLACK]);
    $chart->xo = $chart->defaultOriginX();
    // Y AXIS LABEL
    $names0 = explode(' ', $LangName[0]);
    $names1 = explode(' ', $LangName[1]);
    $label = $names0[0] == $names1[0] ? $LangName[0] : $names0[0];
    $size = $chart->yo - MARGIN;
    $labelsize = strlen($label) * CHAR_WIDTH_3;
    if ($size < $labelsize) {
        $label = $names0[1];
        $labelsize = strlen($label) * CHAR_WIDTH_3;
    }
    $inset = $size / 2.0 + $labelsize / 2.0;
    $label = $label . ' used';
    $labelsize = strlen($label) * CHAR_WIDTH_3;
    ImageStringUp($chart->im, 3, 0, $chart->yo - MARGIN / 2.0 + $labelsize / 2.0, $label, $chart->colour[BLACK]);
    //
    $chart->title($LangName[0] . ' ÷ ' . $LangName[1]);
    $chart->notice($Mark);
}
$chart->frame();
$chart->complete();
Example #15
0
function Draw($site)
{
    global $image, $racks, $devices, $links, $port_count, $ports;
    $rack_count = CountRacksInSite($site);
    // Define the modifiers
    $modifier = 3;
    $top_modifier = 0;
    $dev_modifier = array();
    $side_modifier = array();
    $rack_buffer = (CountLinks($site) + 2) * $modifier;
    // Space between racks
    $rack_margin = $rack_buffer;
    // Space between the racks and edge of page
    $y_top_margin = 100 + CountLinks($site) * 1.25;
    $y_bot_margin = 75;
    $page_size = 7;
    $page_counter = 0;
    $x_offset = 25;
    $y_offset = 50;
    $height = 100;
    $rack_width = 300;
    $rack_height = CountDevicesInRack($site) * $height;
    $width = $rack_width;
    $x_buffer = $width + intval($width * 0.5);
    $y_buffer = 50;
    ksort($racks);
    ksort($devices);
    $x_max = $rack_count * $rack_width + $rack_count * $rack_buffer + $rack_margin * 2;
    $y_max = $rack_height + $y_top_margin + intval(ImageFontHeight(2) * (CountLinks($site) * 1.25) + 0.5);
    $image = ImageCreate($x_max, $y_max) or die("Cannot Create image");
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $pink = ImageColorAllocate($image, 255, 105, 180);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $red = ImageColorAllocate($image, 255, 0, 0);
    $green = ImageColorAllocate($image, 89, 200, 180);
    $blue = ImageColorAllocate($image, 34, 68, 228);
    $grey = ImageColorAllocate($image, 225, 225, 225);
    $title = "RackTables Visualised ({$site})";
    $title_font = 5;
    $title_font_width = ImageFontWidth($title_font);
    ImageString($image, $title_font, $x_max / 2 - $title_font_width * strlen($title) / 2, $title_font_width * 2, $title, $black);
    // Draw racks
    $rc = 1;
    ksort($racks, SORT_STRING);
    foreach ($racks as $rackname => $sitename) {
        if ($site != $sitename) {
            continue;
        }
        $y = $y_top_margin;
        $x = $rack_margin + ($rc - 1) * $rack_width + $rc * $rack_buffer;
        $x = ($rc - 1) * $rack_width + $rc * $rack_buffer;
        ImageRectangle($image, $x, $y, $x + $rack_width, $y + $rack_height, $black);
        $rack_name_width = ImageFontWidth($rackname);
        $rack_name_font = 2;
        ImageString($image, $rack_name_font, $x + ($rack_width - $rack_name_width * strlen($rackname)) / 2, $y - intval(ImageFontHeight($rack_name_font) * 1.25), $rackname, $black);
        // Draw devices
        foreach ($devices as $device_name => $installed_rack) {
            if ($installed_rack != $rackname) {
                continue;
            }
            ImageRectangle($image, $x, $y, $x + $width, $y + $height, $black);
            ImageString($image, 2, $x + 5, $y + 3, strtoupper($device_name), $black);
            $unit = $width / ($port_count[$device_name] + 1);
            for ($i = 0; $i < $port_count[$device_name]; $i++) {
                $cx = $x + $unit * ($i + 1);
                $coord[$device_name][$ports[$device_name][$i]][0] = $cx;
                $coord[$device_name][$ports[$device_name][$i]][1] = intval($y + $height / 2);
                ImageFilledEllipse($image, $cx, $coord[$device_name][$ports[$device_name][$i]][1], 3, 3, $black);
                ImageStringUp($image, 1, $cx - intval(ImageFontWidth(1) / 2), $coord[$device_name][$ports[$device_name][$i]][1] - 5, $ports[$device_name][$i], $black);
            }
            $y = $y + $height;
        }
        $rc++;
    }
    unset($rc);
    $line_tracker = array();
    $index = 0;
    $label = "Device Inter-Connections";
    ImageString($image, 3, $rack_margin, $y_top_margin + $rack_height + 20, $label, $black);
    ImageLine($image, $rack_margin, $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $rack_margin + ImageFontWidth(3) * strlen($label), $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $black);
    unset($label);
    $y = $y_top_margin - intval(ImageFontHeight(2) * 1.25);
    $text_x_coord['data'] = $rack_margin;
    $text_x_coord['power'] = $rack_margin + 320;
    $text_x_coord['kvm'] = $rack_margin + 640;
    // Iterate through the links
    foreach ($links as $link) {
        switch ($link['Type']) {
            case 16:
                // Power
                $colour = $red;
                $type = 'power';
                break;
            case 19:
                // Fast Ethernet
                $colour = $blue;
                $type = 'data';
                break;
            case 24:
                // GB Ethernet
                $colour = $blue;
                $type = 'data';
                break;
            case 1077:
                // SFF
                $colour = $blue;
                $type = 'data';
                break;
            case 33:
                // KVM
                $colour = $green;
                $type = 'kvm';
                break;
            case 446:
                // KVM
                $colour = $green;
                $type = 'kvm';
                break;
        }
        // Filter out devices with un-linked ports
        if (isset($coord[$link['Device1']][$link['Port1']][0]) and isset($coord[$link['Device1']][$link['Port1']][1]) and isset($coord[$link['Device2']][$link['Port2']][0]) and isset($coord[$link['Device2']][$link['Port2']][1])) {
            $d1x = $coord[$link['Device1']][$link['Port1']][0];
            $d1y = $coord[$link['Device1']][$link['Port1']][1];
            $d2x = $coord[$link['Device2']][$link['Port2']][0];
            $d2y = $coord[$link['Device2']][$link['Port2']][1];
            //			$port_list = $port_list + intval(ImageFontHeight(2) * 1.25);
            if (isset($text_y_coord[$type])) {
                $text_y_coord[$type] += intval(ImageFontHeight(2) * 1.25);
            } else {
                $text_y_coord[$type] = $y_top_margin + $rack_height + 20 + intval(ImageFontHeight(2) * 1.25);
            }
            // Print the link information and darw a simple table
            ImageString($image, 2, $text_x_coord[$type], $text_y_coord[$type], $link['Device1'] . ":" . $link['Port1'], $colour);
            ImageString($image, 2, $text_x_coord[$type] + 150, $text_y_coord[$type], $link['Device2'] . ":" . $link['Port2'], $colour);
            ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type], $text_x_coord[$type] + 300, $text_y_coord[$type], $grey);
            if ($text_y_coord[$type] != $y_top_margin + $rack_height + 20 + intval(ImageFontHeight(2) * 1.25)) {
                ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $text_x_coord[$type] + 300, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey);
            }
            ImageLine($image, $text_x_coord[$type] - 10, $text_y_coord[$type], $text_x_coord[$type] - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey);
            ImageLine($image, $text_x_coord[$type] + 150 - 10, $text_y_coord[$type], $text_x_coord[$type] + 150 - 10, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey);
            ImageLine($image, $text_x_coord[$type] + 300, $text_y_coord[$type], $text_x_coord[$type] + 300, $text_y_coord[$type] + intval(ImageFontHeight(2) * 1.25), $grey);
            if (isset($side_modifier[$link['Rack1']])) {
                $side_modifier[$link['Rack1']] += $modifier;
            } else {
                $side_modifier[$link['Rack1']] = $modifier;
            }
            if (isset($side_modifier[$link['Rack2']])) {
                $side_modifier[$link['Rack2']] += $modifier;
            } else {
                $side_modifier[$link['Rack2']] = $modifier;
            }
            if (isset($dev_modifier[$link['Device1']])) {
                $dev_modifier[$link['Device1']] += $modifier;
            } else {
                $dev_modifier[$link['Device1']] = $modifier;
            }
            if (isset($dev_modifier[$link['Device2']])) {
                $dev_modifier[$link['Device2']] += $modifier;
            } else {
                $dev_modifier[$link['Device2']] = $modifier;
            }
            $r1x = $d1x - $rack_margin;
            $i = 0;
            while ($r1x > 0) {
                $r1x = $r1x - $rack_width - $rack_buffer;
                $i++;
            }
            $r1x = $rack_margin + $rack_width * $i + $rack_buffer * $i;
            $r1x = $rack_width * $i + $rack_buffer * $i;
            $r2x = $d2x - $rack_margin;
            $j = 0;
            while ($r2x > 0) {
                $r2x = $r2x - $rack_width - $rack_buffer;
                $j++;
            }
            $r2x = $rack_margin + $rack_width * ($j - 1) + $rack_buffer * $j;
            $r2x = $rack_width * ($j - 1) + $rack_buffer * $j;
            ImageLine($image, $d1x, $d1y, $d1x, $d1y + $dev_modifier[$link['Device1']], $colour);
            ImageLine($image, $d1x, $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $colour);
            if ($link['Rack1'] == $link['Rack2']) {
                ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d2y + $dev_modifier[$link['Device2']], $colour);
                ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y + $dev_modifier[$link['Device2']], $colour);
                //				ImageLine($image, $d2x, $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y, $colour);
            } else {
                $top_modifier += $modifier;
                //				ImageLine($image, $d1x, $d1y, $d1x, $d1y + $dev_modifier[$link['Device1']], $colour);
                //				ImageLine($image, $d1x, $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $colour);
                ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $d1y + $dev_modifier[$link['Device1']], $r1x + $side_modifier[$link['Rack1']], $y - $top_modifier, $colour);
                ImageLine($image, $r1x + $side_modifier[$link['Rack1']], $y - $top_modifier, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $y - $top_modifier, $colour);
                ImageLine($image, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $y - $top_modifier, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $d2y + $dev_modifier[$link['Device2']], $colour);
                ImageLine($image, $d2x - ($d2x - $r2x) + $rack_width + $side_modifier[$link['Rack2']], $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y + $dev_modifier[$link['Device2']], $colour);
            }
            ImageLine($image, $d2x, $d2y + $dev_modifier[$link['Device2']], $d2x, $d2y, $colour);
            unset($i, $j, $r1x, $r2x, $ry);
        }
    }
    ob_start();
    ImagePng($image);
    $contents = ob_get_contents();
    ob_end_clean();
    $new_site = str_replace(' ', '_', $site);
    $fh = fopen("/tmp/{$new_site}.png", "w");
    fwrite($fh, $contents);
    fclose($fh);
}
Example #16
0
    $str_print = $LDFillByLab;
} else {
    $str_print = $LDFillByWard;
}
require_once $root_path . 'include/inc_ttf_check.php';
if ($ttf_render) {
    //ImageColorTransparent($im,$green);
    // *******************************************************************
    // * the following code is for ttf fonts use only for php machines with ttf support
    // *******************************************************************
    /*
    /* -------------- START ----------------------------------------------*/
    if ($lang == 'ar' || $lang == 'fa') {
        // Modified on ( 22/01/2004) By Walid Fathalla
        include_once $root_path . 'include/inc_ttf_ar2uni.php';
        //To actvate function of show arabic
        ImageTTFText($im, 14, 90, 16, 390, $black, $arial, ar2uni($str_print));
    } else {
        ImageTTFText($im, 14, 90, 16, 390, $black, $arial, $str_print);
    }
    /* -------------- END -------------------------------------------------*/
    // ******************************************************************
    // * the following code is the default - uses system fonts
    // ******************************************************************
} else {
    /* -------------- START  ----------------------*/
    ImageStringUp($im, 5, 2, 390, $str_print, $black);
    /* -------------- END --------------------------*/
}
Imagepng($im);
ImageDestroy($im);
ImageFilledRectangle($im, $sx, $sy + 10, $sx + 10, $sy + $vdiv * 5 - 6, $yellow);
ImageStringUp($im, 1, $sx - 15, $sy + $vdiv * 5 - 6, $LDUrine, $dark_pink);
// white
$sx = $left_border + $hdiv * 40;
ImageFilledRectangle($im, $sx, $sy + 10, $sx + 10, $sy + $vdiv * 5 - 6, $white);
ImageStringUp($im, 1, $sx - 15, $sy + $vdiv * 5 - 6, $LDSerum, $dark_pink);
/* Write the vertical batch nr.s */
for ($i = 23, $n = 0; $i < 42; $i += 6, $n++) {
    $sx = $left_border + $hdiv * $i - 10;
    ImageStringUp($im, 2, $sx - 13, $sy + $vdiv * 5 - 6, $stored_request['batch_nr'], $black);
    if ($n == 3) {
        $i = 17;
        $sy += $vdiv * 4;
    }
    if ($n > 2) {
        ImageStringUp($im, 1, $sx - 22, $sy + $vdiv * 5 - 6, $LDSerum, $dark_pink);
    }
}
/* Create the Urin,Serum,etc. label barcodes */
$sx = $left_border + $hdiv * 17;
$sy = $top_border + $vdiv * 72;
/* Copy the lab barcode into the form */
for ($i = 0; $i < 8; $i++) {
    ImageCopy($im, $lab_bc, $sx, $sy, 38, 16, 73, 41);
    if ($i == 3) {
        $sx = $left_border + $hdiv * 17;
        $sy = $top_border + $vdiv * 76;
    } else {
        $sx += $hdiv * 6;
    }
}
Example #18
0
for ($ii = $gleft; $ii <= $gright; $ii += ($gright - $gleft) / 8) {
    ImageLine($png, $ii, $gtop, $ii, $gbot, $black);
    if ($xhi < 10 || $xhi - $xlo < 50.0) {
        $buf = sprintf("%.3f", ($xhi - $xlo) / 8.0 * (double) $y1 + $xlo);
    } else {
        $buf = sprintf("%.0f", ($xhi - $xlo) / 8.0 * (double) $y1 + $xlo);
    }
    $x = $ii - $fwidth2 * strlen($buf) / 2;
    ImageString($png, 2, $x, $gbot + 5, $buf, $black);
    $y1++;
}
$y1 = $fwidth2 / 2 * strlen($xlabel);
ImageString($png, 2, $WIDTH / 2 - $y1, $gbot + 30, $xlabel, $black);
ImageStringUp($png, 2, $gleft - 50, ($HEIGHT - $gtop - 100) / 2 + $fwidth2 / 2 * strlen($ylabel1), $ylabel1, $black);
if ($vswr) {
    ImageStringUp($png, 2, $gright + 35, ($HEIGHT - $gtop - 100) / 2 + $fwidth2 / 2 * strlen("VSWR"), "VSWR", $blue);
}
// Horizontal Gridlines
$y2 = $yticks;
for ($ii = $gtop; $ii <= $gbot; $ii += ($gbot - $gtop) / $yticks) {
    ImageLine($png, $gleft, $ii, $gright, $ii, $black);
    $yf1 = (double) ((double) ($ghi - $glo) / (double) $yticks * (double) $y2);
    $yf1 += (double) $glo;
    if ($ghi < 10.0) {
        $buf = sprintf("%.2f", $yf1);
    } else {
        $buf = sprintf("%.0f", $yf1);
    }
    ImageString($png, 1, $gleft - strlen($buf) * $fwidth1 - 2, $ii - $fheight1 / 2, $buf, $black);
    if ($vswr) {
        $yf1 = (double) ((double) $dd / (double) $yticks * (double) $y2);
 /**
  * Generate both the HTML and PNG components of the fan chart
  *
  * The HTML and PNG components both require the same co-ordinate calculations,
  * so we generate them using the same code, but we send them in separate
  * HTTP requests.
  *
  * @param string $what "png" or "html"
  *
  * @return string
  */
 public function generateFanChart($what)
 {
     $treeid = $this->sosaAncestors($this->generations);
     $fanw = 640 * $this->fan_width / 100;
     $fandeg = 90 * $this->fan_style;
     $html = '';
     $treesize = count($treeid) + 1;
     // generations count
     $gen = log($treesize) / log(2) - 1;
     $sosa = $treesize - 1;
     // fan size
     if ($fandeg == 0) {
         $fandeg = 360;
     }
     $fandeg = min($fandeg, 360);
     $fandeg = max($fandeg, 90);
     $cx = $fanw / 2 - 1;
     // center x
     $cy = $cx;
     // center y
     $rx = $fanw - 1;
     $rw = $fanw / ($gen + 1);
     $fanh = $fanw;
     // fan height
     if ($fandeg == 180) {
         $fanh = round($fanh * ($gen + 1) / ($gen * 2));
     }
     if ($fandeg == 270) {
         $fanh = round($fanh * 0.86);
     }
     $scale = $fanw / 640;
     // image init
     $image = ImageCreate($fanw, $fanh);
     $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
     ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
     ImageColorTransparent($image, $white);
     $color = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-font-color'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 4, 2)));
     $bgcolor = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-u'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 4, 2)));
     $bgcolorM = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-m'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 4, 2)));
     $bgcolorF = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-f'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 4, 2)));
     // imagemap
     $imagemap = '<map id="fanmap" name="fanmap">';
     // loop to create fan cells
     while ($gen >= 0) {
         // clean current generation area
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $fandeg;
         ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
         $rx -= 3;
         // calculate new angle
         $p2 = pow(2, $gen);
         $angle = $fandeg / $p2;
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $angle;
         // special case for rootid cell
         if ($gen == 0) {
             $deg1 = 90;
             $deg2 = 360 + $deg1;
         }
         // draw each cell
         while ($sosa >= $p2) {
             $person = $treeid[$sosa];
             if ($person) {
                 $name = $person->getFullName();
                 $addname = $person->getAddName();
                 $text = I18N::reverseText($name);
                 if ($addname) {
                     $text .= "\n" . I18N::reverseText($addname);
                 }
                 $text .= "\n" . I18N::reverseText($person->getLifeSpan());
                 switch ($person->getSex()) {
                     case 'M':
                         $bg = $bgcolorM;
                         break;
                     case 'F':
                         $bg = $bgcolorF;
                         break;
                     default:
                         $bg = $bgcolor;
                         break;
                 }
                 ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                 // split and center text by lines
                 $wmax = (int) ($angle * 7 / Theme::theme()->parameter('chart-font-size') * $scale);
                 $wmax = min($wmax, 35 * $scale);
                 if ($gen == 0) {
                     $wmax = min($wmax, 17 * $scale);
                 }
                 $text = $this->splitAlignText($text, $wmax);
                 // text angle
                 $tangle = 270 - ($deg1 + $angle / 2);
                 if ($gen == 0) {
                     $tangle = 0;
                 }
                 // calculate text position
                 $deg = $deg1 + 0.44;
                 if ($deg2 - $deg1 > 40) {
                     $deg = $deg1 + ($deg2 - $deg1) / 11;
                 }
                 if ($deg2 - $deg1 > 80) {
                     $deg = $deg1 + ($deg2 - $deg1) / 7;
                 }
                 if ($deg2 - $deg1 > 140) {
                     $deg = $deg1 + ($deg2 - $deg1) / 4;
                 }
                 if ($gen == 0) {
                     $deg = 180;
                 }
                 $rad = deg2rad($deg);
                 $mr = ($rx - $rw / 4) / 2;
                 if ($gen > 0 && $deg2 - $deg1 > 80) {
                     $mr = $rx / 2;
                 }
                 $tx = $cx + $mr * cos($rad);
                 $ty = $cy - $mr * -sin($rad);
                 if ($sosa == 1) {
                     $ty -= $mr / 2;
                 }
                 // print text
                 ImageTtfText($image, Theme::theme()->parameter('chart-font-size'), $tangle, $tx, $ty, $color, Theme::theme()->parameter('chart-font-name'), $text);
                 $imagemap .= '<area shape="poly" coords="';
                 // plot upper points
                 $mr = $rx / 2;
                 $deg = $deg1;
                 while ($deg <= $deg2) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg += ($deg2 - $deg1) / 6;
                 }
                 // plot lower points
                 $mr = ($rx - $rw) / 2;
                 $deg = $deg2;
                 while ($deg >= $deg1) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg -= ($deg2 - $deg1) / 6;
                 }
                 // join first point
                 $mr = $rx / 2;
                 $deg = $deg1;
                 $rad = deg2rad($deg);
                 $tx = round($cx + $mr * cos($rad));
                 $ty = round($cy - $mr * -sin($rad));
                 $imagemap .= "{$tx},{$ty}";
                 // add action url
                 $pid = $person->getXref();
                 $imagemap .= '" href="#' . $pid . '"';
                 $tempURL = 'fanchart.php?rootid=' . $pid . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;fan_style=' . $this->fan_style . '&amp;ged=' . $person->getTree()->getNameUrl();
                 $html .= '<div id="' . $pid . '" class="fan_chart_menu">';
                 $html .= '<div class="person_box"><div class="details1">';
                 $html .= '<a href="' . $person->getHtmlUrl() . '" class="name1">' . $name;
                 if ($addname) {
                     $html .= $addname;
                 }
                 $html .= '</a>';
                 $html .= '<ul class="charts">';
                 $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Pedigree') . '</a></li>';
                 if (Module::getModuleByName('googlemap')) {
                     $html .= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Pedigree map') . '</a></li>';
                 }
                 $gedcomid = $person->getTree()->getUserPreference(Auth::user(), 'gedcomid');
                 if ($gedcomid && $gedcomid != $pid) {
                     $html .= '<li><a href="relationship.php?pid1=' . $gedcomid . '&amp;pid2=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Relationship to me') . '</a></li>';
                 }
                 $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Descendants') . '</a></li>';
                 $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Ancestors') . '</a></li>';
                 $html .= '<li><a href="compact.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Compact tree') . '</a></li>';
                 $html .= '<li><a href="' . $tempURL . '">' . I18N::translate('Fan chart') . '</a></li>';
                 $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Hourglass chart') . '</a></li>';
                 if (Module::getModuleByName('tree')) {
                     $html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . $person->getTree()->getNameUrl() . '&amp;rootid=' . $pid . '">' . I18N::translate('Interactive tree') . '</a></li>';
                 }
                 $html .= '</ul>';
                 // spouse(s) and children
                 foreach ($person->getSpouseFamilies() as $family) {
                     $spouse = $family->getSpouse($person);
                     if ($spouse) {
                         $html .= '<a href="' . $spouse->getHtmlUrl() . '" class="name1">' . $spouse->getFullName() . '</a>';
                         $kids = $family->getChildren();
                         if ($kids) {
                             $html .= '<ul class="children">';
                             foreach ($kids as $child) {
                                 $html .= '<li><a href="' . $child->getHtmlUrl() . '" class="name1">' . $child->getFullName() . '</a></li>';
                             }
                             $html .= '</ul>';
                         }
                     }
                 }
                 // siblings
                 foreach ($person->getChildFamilies() as $family) {
                     $children = $family->getChildren();
                     if ($children) {
                         $html .= '<div class="name1">';
                         // With two children in a family, you have only one sibling.
                         $html .= count($children) > 2 ? I18N::translate('Siblings') : I18N::translate('Sibling');
                         $html .= '</div>';
                         $html .= '<ul class="siblings">';
                         foreach ($children as $sibling) {
                             if ($sibling !== $person) {
                                 $html .= '<li><a href="' . $sibling->getHtmlUrl() . '" class="name1"> ' . $sibling->getFullName() . '</a></li>';
                             }
                         }
                         $html .= '</ul>';
                     }
                 }
                 $html .= '</div></div>';
                 $html .= '</div>';
                 $imagemap .= ' alt="' . strip_tags($person->getFullName()) . '" title="' . strip_tags($person->getFullName()) . '">';
             }
             $deg1 -= $angle;
             $deg2 -= $angle;
             $sosa--;
         }
         $rx -= $rw;
         $gen--;
     }
     $imagemap .= '</map>';
     switch ($what) {
         case 'html':
             return $html . $imagemap . '<div id="fan_chart_img"><img src="' . WT_SCRIPT_NAME . '?rootid=' . $this->root->getXref() . '&amp;fan_style=' . $this->fan_style . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;img=1" width="' . $fanw . '" height="' . $fanh . '" alt="' . strip_tags($this->getPageTitle()) . '" usemap="#fanmap"></div>';
         case 'png':
             ImageStringUp($image, 1, $fanw - 10, $fanh / 3, WT_BASE_URL, $color);
             ob_start();
             ImagePng($image);
             ImageDestroy($image);
             return ob_get_clean();
         default:
             throw new \InvalidArgumentException(__METHOD__ . ' ' . $what);
     }
 }
        //  ImageFilledRectangle($Image, ($i * 7) + 38 - $reduction_factor, 250 - ($mydata[$i] * $gap), ($i * 7) + 43 - $reduction_factor, 250, $red);
        //} else {
        ImageFilledRectangle($Image, $i * 7 + 38 - $reduction_factor, 250 - $mydata[$i] * $gap, $i * 7 + 43 - $reduction_factor, 250, $dkgreen);
        //}
    }
}
if (isset($_GET['plotuser'])) {
    ImageString($Image, 2, 50, 260, "Worst", $black);
    ImageString($Image, 2, 700 - $reduction_factor, 260, "Best", $black);
    ImageString($Image, 3, 345 - $reduction_factor / 2, 278, "Performance", $black);
} else {
    if ($_GET['rndmk'] == 1) {
        ImageString($Image, 3, 345, 278, "Adjusted Percentage Mark", $black);
    } else {
        ImageString($Image, 3, 355, 278, "Percentage Mark", $black);
    }
}
ImageStringUp($Image, 3, 0, 166, "Occurrance", $black);
if ($_GET['plotuser'] != '') {
    if ($label < 100) {
        ImageString($Image, 2, $_GET['plotuser'] * 7 + 32 - $reduction_factor, 10, "You", $blue);
        ImageString($Image, 2, $mean * 7 + 32 - $reduction_factor, 0, "Mean", $red);
    } else {
        ImageString($Image, 2, $_GET['plotuser'] * 7 + 26 - $reduction_factor, 10, "You", $blue);
        ImageString($Image, 2, $mean * 7 + 26 - $reduction_factor, 0, "Mean", $red);
    }
    ImageLine($Image, $_GET['plotuser'] * 7 + 40 - $reduction_factor, 22, $_GET['plotuser'] * 7 + 40 - $reduction_factor, 250, $blue);
    ImageLine($Image, $mean * 7 + 40 - $reduction_factor, 12, $mean * 7 + 40 - $reduction_factor, 250, $red);
}
ImagePNG($Image);
ImageDestroy($Image);
Example #21
0
            //elseif(($mod/5)>1 && $i%($mod/5)==0)
            //{
            //	imageline($canvas, $c4['x'], $c4['y']+$increment, $c4['x']+10, $c4['y']+$increment, $grey);
            //}
            //because these lines begin at the bottom we want to subtract
            $increment -= $sqH;
        }
        //------------------------------------------------
        // Making the vertical bars
        //------------------------------------------------
        $increment = 0;
        //resetting the increment value
        $barWidth = $sqW * 0.2;
        //setting a width size for the bars, play with this number
        foreach ($data as $assoc => $value) {
            $yPos = $c4['y'] - $value * $sqH;
            $xPos = $c4['x'] + $increment + $verticalPadding - $barWidth / 2;
            imagefilledrectangle($canvas, $xPos, $c4['y'], $xPos + $barWidth, $yPos, $grey);
            $increment += $sqW;
        }
        //Graph Title
        ImageString($canvas, 2, $canvasWidth / 2 - strlen($graphTitle) * $fontwidth / 2, $c1['y'] - $perimeter / 2, $graphTitle, $green);
        //X-Axis
        ImageString($canvas, 2, $canvasWidth / 2 - strlen($xLabel) * $fontwidth / 2, $c4['y'] + $perimeter / 2, $xLabel, $green);
        //Y-Axis
        ImageStringUp($canvas, 2, $c1['x'] - $fontheight * 3, $canvasHeight / 2 + strlen($yLabel) * $fontwidth / 2, $yLabel, $green);
        header("content-type: image/jpg");
        imagejpeg($canvas, 'images/feedback_graph.jpg');
        imagedestroy($canvas);
    }
}
Example #22
0
 function backgroundText($a)
 {
     $x = $this->xo + 2;
     $count = 0;
     $need = floor(($this->h - 15) / CHAR_WIDTH_3) - 1;
     foreach ($a as $s) {
         $s = '  ' . $s;
         $needrepeat = floor($need / strlen($s)) + 1;
         $label = substr(str_repeat($s, $needrepeat), 0, $need);
         ImageStringUp($this->im, 3, $x, $this->h - 12, $label, $this->colour[GRAY]);
         $x = $x + $this->boxwidth + $this->boxspace;
         if ($count == $this->maxboxes) {
             break;
         } else {
             $count++;
         }
     }
 }
Example #23
0
    ImageTTFText($im, 10, 0, $leftmargin + 360, $topm2 - 3, $black, $arial, $full_en);
    ImageTTFText($im, 11, 90, $leftmargin + 340, $topm + 77, $black, $arial, $full_en);
} else {
    ImageString($im, 2, $leftmargin + 175, $topm - 13, $full_en, $black);
    ImageString($im, 2, $leftmargin + 355, $topm2 - 13, $full_en, $black);
    ImageStringUp($im, 5, $leftmargin + 325, $topm + 78, $full_en, $black);
}
$topm += $yoffset;
ImageCopy($im, $bc, $leftmargin + 200, $topm, 9, 9, 170, 37);
# Print admit nr vertically
if ($ttf_ok) {
    ImageTTFText($im, 10, 0, $leftmargin + 210, $topm - 1, $black, $arial, $full_en);
    ImageTTFText($im, 11, 90, $leftmargin + 385, $topm + 77, $black, $arial, $full_en);
} else {
    ImageString($im, 2, $leftmargin + 215, $topm - 13, $full_en, $black);
    ImageStringUp($im, 5, $leftmargin + 370, $topm + 78, $full_en, $black);
}
//* Place the name labels*/
$topm = $topmargin + 53;
$topm2 = $topmargin + 5;
ImageCopy($im, $namelabel, $leftmargin + 225, $topm, 0, 0, 144, 39);
ImageCopy($im, $namelabel, $leftmargin + 485, $topm2, 0, 0, 144, 39);
$topm += $yoffset;
$topm2 += $yoffset;
ImageCopy($im, $namelabel, $leftmargin + 205, $topm, 0, 0, 144, 39);
ImageCopy($im, $namelabel, $leftmargin + 435, $topm2, 0, 0, 144, 39);
$topm += $yoffset;
$topm2 += $yoffset;
ImageCopy($im, $namelabel, $leftmargin + 175, $topm, 0, 0, 144, 39);
ImageCopy($im, $namelabel, $leftmargin + 355, $topm2, 0, 0, 144, 39);
$topm += $yoffset;
Example #24
0
 /**
  * Generate both the HTML and PNG components of the fan chart
  *
  * The HTML and PNG components both require the same co-ordinate calculations,
  * so we generate them using the same code, but we send them in separate
  * HTTP requests.
  *
  * @param string   $what     "png" or "html"
  * @param string[] $fanChart Presentation parameters, provided by the theme.
  *
  * @return string
  */
 public function generate_fan_chart($what, $fanChart)
 {
     $treeid = ancestry_array($this->root->getXref(), $this->generations);
     $fanw = 640 * $this->fan_width / 100;
     $fandeg = 90 * $this->fan_style;
     $html = '';
     $treesize = count($treeid);
     // generations count
     $gen = log($treesize) / log(2) - 1;
     $sosa = $treesize - 1;
     // fan size
     if ($fandeg == 0) {
         $fandeg = 360;
     }
     $fandeg = min($fandeg, 360);
     $fandeg = max($fandeg, 90);
     $cx = $fanw / 2 - 1;
     // center x
     $cy = $cx;
     // center y
     $rx = $fanw - 1;
     $rw = $fanw / ($gen + 1);
     $fanh = $fanw;
     // fan height
     if ($fandeg == 180) {
         $fanh = round($fanh * ($gen + 1) / ($gen * 2));
     }
     if ($fandeg == 270) {
         $fanh = round($fanh * 0.86);
     }
     $scale = $fanw / 640;
     // image init
     $image = ImageCreate($fanw, $fanh);
     $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
     ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
     ImageColorTransparent($image, $white);
     $color = ImageColorAllocate($image, hexdec(substr($fanChart['color'], 1, 2)), hexdec(substr($fanChart['color'], 3, 2)), hexdec(substr($fanChart['color'], 5, 2)));
     $bgcolor = ImageColorAllocate($image, hexdec(substr($fanChart['bgColor'], 1, 2)), hexdec(substr($fanChart['bgColor'], 3, 2)), hexdec(substr($fanChart['bgColor'], 5, 2)));
     $bgcolorM = ImageColorAllocate($image, hexdec(substr($fanChart['bgMColor'], 1, 2)), hexdec(substr($fanChart['bgMColor'], 3, 2)), hexdec(substr($fanChart['bgMColor'], 5, 2)));
     $bgcolorF = ImageColorAllocate($image, hexdec(substr($fanChart['bgFColor'], 1, 2)), hexdec(substr($fanChart['bgFColor'], 3, 2)), hexdec(substr($fanChart['bgFColor'], 5, 2)));
     // imagemap
     $imagemap = '<map id="fanmap" name="fanmap">';
     // loop to create fan cells
     while ($gen >= 0) {
         // clean current generation area
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $fandeg;
         ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
         $rx -= 3;
         // calculate new angle
         $p2 = pow(2, $gen);
         $angle = $fandeg / $p2;
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $angle;
         // special case for rootid cell
         if ($gen == 0) {
             $deg1 = 90;
             $deg2 = 360 + $deg1;
         }
         // draw each cell
         while ($sosa >= $p2) {
             $pid = $treeid[$sosa];
             $person = WT_Individual::getInstance($pid);
             if ($person) {
                 $name = $person->getFullName();
                 $addname = $person->getAddName();
                 $text = WT_I18N::reverseText($name);
                 if ($addname) {
                     $text .= "\n" . WT_I18N::reverseText($addname);
                 }
                 $text .= "\n" . WT_I18N::reverseText($person->getLifeSpan());
                 switch ($person->getSex()) {
                     case 'M':
                         $bg = $bgcolorM;
                         break;
                     case 'F':
                         $bg = $bgcolorF;
                         break;
                     case 'U':
                         $bg = $bgcolor;
                         break;
                 }
                 ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                 // split and center text by lines
                 $wmax = (int) ($angle * 7 / $fanChart['size'] * $scale);
                 $wmax = min($wmax, 35 * $scale);
                 if ($gen == 0) {
                     $wmax = min($wmax, 17 * $scale);
                 }
                 $text = $this->split_align_text($text, $wmax);
                 // text angle
                 $tangle = 270 - ($deg1 + $angle / 2);
                 if ($gen == 0) {
                     $tangle = 0;
                 }
                 // calculate text position
                 $deg = $deg1 + 0.44;
                 if ($deg2 - $deg1 > 40) {
                     $deg = $deg1 + ($deg2 - $deg1) / 11;
                 }
                 if ($deg2 - $deg1 > 80) {
                     $deg = $deg1 + ($deg2 - $deg1) / 7;
                 }
                 if ($deg2 - $deg1 > 140) {
                     $deg = $deg1 + ($deg2 - $deg1) / 4;
                 }
                 if ($gen == 0) {
                     $deg = 180;
                 }
                 $rad = deg2rad($deg);
                 $mr = ($rx - $rw / 4) / 2;
                 if ($gen > 0 && $deg2 - $deg1 > 80) {
                     $mr = $rx / 2;
                 }
                 $tx = $cx + $mr * cos($rad);
                 $ty = $cy - $mr * -sin($rad);
                 if ($sosa == 1) {
                     $ty -= $mr / 2;
                 }
                 // print text
                 ImageTtfText($image, (double) $fanChart['size'], $tangle, $tx, $ty, $color, $fanChart['font'], $text);
                 $imagemap .= '<area shape="poly" coords="';
                 // plot upper points
                 $mr = $rx / 2;
                 $deg = $deg1;
                 while ($deg <= $deg2) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg += ($deg2 - $deg1) / 6;
                 }
                 // plot lower points
                 $mr = ($rx - $rw) / 2;
                 $deg = $deg2;
                 while ($deg >= $deg1) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg -= ($deg2 - $deg1) / 6;
                 }
                 // join first point
                 $mr = $rx / 2;
                 $deg = $deg1;
                 $rad = deg2rad($deg);
                 $tx = round($cx + $mr * cos($rad));
                 $ty = round($cy - $mr * -sin($rad));
                 $imagemap .= "{$tx},{$ty}";
                 // add action url
                 $imagemap .= '" href="#' . $pid . '"';
                 $tempURL = 'fanchart.php?rootid=' . $pid . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;fan_style=' . $this->fan_style . '&amp;ged=' . WT_GEDURL;
                 $html .= '<div id="' . $pid . '" class="fan_chart_menu">';
                 $html .= '<div class="person_box"><div class="details1">';
                 $html .= '<a href="' . $person->getHtmlUrl() . '" class="name1">' . $name;
                 if ($addname) {
                     $html .= $addname;
                 }
                 $html .= '</a>';
                 $html .= '<ul class="charts">';
                 $html .= "<li><a href=\"pedigree.php?rootid={$pid}&amp;amp;ged=" . WT_GEDURL . "\" >" . WT_I18N::translate('Pedigree') . "</a></li>";
                 if (array_key_exists('googlemap', WT_Module::getActiveModules())) {
                     $html .= "<li><a href=\"module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=" . $pid . "&amp;ged=" . WT_GEDURL . "\">" . WT_I18N::translate('Pedigree map') . "</a></li>";
                 }
                 if (WT_USER_GEDCOM_ID && WT_USER_GEDCOM_ID != $pid) {
                     $html .= "<li><a href=\"relationship.php?pid1=" . WT_USER_GEDCOM_ID . "&amp;pid2={$pid}&amp;ged=" . WT_GEDURL . "\">" . WT_I18N::translate('Relationship to me') . "</a></li>";
                 }
                 $html .= "<li><a href=\"descendancy.php?rootid={$pid}&amp;ged=" . WT_GEDURL . "\" >" . WT_I18N::translate('Descendants') . "</a></li>";
                 $html .= "<li><a href=\"ancestry.php?rootid={$pid}&amp;ged=" . WT_GEDURL . "\">" . WT_I18N::translate('Ancestors') . "</a></li>";
                 $html .= "<li><a href=\"compact.php?rootid={$pid}&amp;ged=" . WT_GEDURL . "\">" . WT_I18N::translate('Compact tree') . "</a></li>";
                 $html .= "<li><a href=\"" . $tempURL . "\">" . WT_I18N::translate('Fan chart') . "</a></li>";
                 $html .= "<li><a href=\"hourglass.php?rootid={$pid}&amp;ged=" . WT_GEDURL . "\">" . WT_I18N::translate('Hourglass chart') . "</a></li>";
                 if (array_key_exists('tree', WT_Module::getActiveModules())) {
                     $html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . WT_GEDURL . '&amp;rootid=' . $pid . '">' . WT_I18N::translate('Interactive tree') . '</a></li>';
                 }
                 $html .= '</ul>';
                 // spouse(s) and children
                 foreach ($person->getSpouseFamilies() as $family) {
                     $spouse = $family->getSpouse($person);
                     if ($spouse) {
                         $html .= '<a href="' . $spouse->getHtmlUrl() . '" class="name1">' . $spouse->getFullName() . '</a>';
                         $kids = $family->getChildren();
                         if ($kids) {
                             $html .= '<ul class="children">';
                             foreach ($kids as $child) {
                                 $html .= '<li><a href="' . $child->getHtmlUrl() . '" class="name1">' . $child->getFullName() . '</a></li>';
                             }
                             $html .= '</ul>';
                         }
                     }
                 }
                 // siblings
                 foreach ($person->getChildFamilies() as $family) {
                     $children = $family->getChildren();
                     if ($children) {
                         $html .= '<div class="name1">' . WT_I18N::plural('Sibling', 'Siblings', count($children) - 1) . '</div>';
                         $html .= '<ul class="siblings">';
                         foreach ($children as $sibling) {
                             if ($sibling !== $person) {
                                 $html .= '<li><a href="' . $sibling->getHtmlUrl() . '" class="name1"> ' . $sibling->getFullName() . '</a></li>';
                             }
                         }
                         $html .= '</ul>';
                     }
                 }
                 $html .= '</div></div>';
                 $html .= '</div>';
                 $imagemap .= ' alt="' . strip_tags($person->getFullName()) . '" title="' . strip_tags($person->getFullName()) . '">';
             }
             $deg1 -= $angle;
             $deg2 -= $angle;
             $sosa--;
         }
         $rx -= $rw;
         $gen--;
     }
     $imagemap .= '</map>';
     switch ($what) {
         case 'html':
             $image_title = WT_I18N::translate('Fan chart of %s', strip_tags($person->getFullName()));
             return $html . $imagemap . '<div id="fan_chart_img"><img src="' . WT_SCRIPT_NAME . '?rootid=' . $this->rootid . '&amp;fan_style=' . $this->fan_style . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;img=1" width="' . $fanw . '" height="' . $fanh . '" alt="' . $image_title . '" title="' . $image_title . '" usemap="#fanmap"></div>';
         case 'png':
             header('Content-Type: image/png');
             ImageStringUp($image, 1, $fanw - 10, $fanh / 3, WT_SERVER_NAME . WT_SCRIPT_PATH, $color);
             ImagePng($image);
             ImageDestroy($image);
     }
 }
Example #25
0
 /**
  * Writes text
  *
  * Parameter array:
  * 
  * 'x': int X-point of text
  * 
  * 'y': int Y-point of text
  * 
  * 'text': string The text to add
  * 
  * 'alignment': array [optional] Alignment
  * 
  * 'color': mixed [optional] The color of the text
  */
 function addText($params)
 {
     $x0 = $this->_getX($params['x']);
     $y0 = $this->_getY($params['y']);
     $text = $params['text'];
     $color = isset($params['color']) ? $params['color'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     $text = str_replace("\r", '', $text);
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if (isset($this->_font['size'])) {
         $textHeight = $this->_font['size'] + 2;
     } else {
         $textHeight = $this->textHeight('A');
     }
     $lines = explode("\n", $text);
     foreach ($lines as $line) {
         $x = $x0;
         $y = $y0;
         $y0 += $textHeight + 2;
         if ($color === false && isset($this->_font['color'])) {
             $color = $this->_font['color'];
         }
         if ($color != 'transparent') {
             if (isset($this->_font['file'])) {
                 $result = $this->_getAbsolutePosition($x, $y, $line, $alignment);
                 ImageTTFText($this->_canvas, $this->_font['size'], $this->_font['angle'], $result['x'], $result['y'], $this->_color($color), $this->_font['file'], $line);
             } else {
                 $width = $this->textWidth($line);
                 $height = $this->textHeight($line);
                 if ($alignment['horizontal'] == 'right') {
                     $x -= $width;
                 } else {
                     if ($alignment['horizontal'] == 'center') {
                         $x -= $width / 2;
                     }
                 }
                 if ($alignment['vertical'] == 'bottom') {
                     $y -= $height;
                 } else {
                     if ($alignment['vertical'] == 'center') {
                         $y -= $height / 2;
                     }
                 }
                 if (isset($this->_font['vertical']) && $this->_font['vertical']) {
                     ImageStringUp($this->_canvas, $this->_font['font'], $x, $y + $this->textHeight($text), $line, $this->_color($color));
                 } else {
                     ImageString($this->_canvas, $this->_font['font'], $x, $y, $line, $this->_color($color));
                 }
             }
         }
     }
     parent::addText($params);
 }
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $get_var)
 {
     //from table
     //setting color
     $config_table = $common->prefix_table("config");
     $color_qry = "select admin_color,rater1_color,rater2_color,rater3_color,self_color,\n\t\t\t\toverall_color from {$config_table} where id='1'";
     $res = $db_object->get_a_line($color_qry);
     $ad_col = $res['admin_color'];
     $rt1_col = $res['rater1_color'];
     $rt2_col = $res['rater2_color'];
     $rt3_col = $res['rater3_color'];
     $self_col = $res['self_color'];
     $over_col = $res['overall_color'];
     $admin = $common->split_color($db_object, $ad_col);
     $rt1 = $common->split_color($db_object, $rt1_col);
     $rt2 = $common->split_color($db_object, $rt2_col);
     $rt3 = $common->split_color($db_object, $rt3_col);
     $slf = $common->split_color($db_object, $self_col);
     $ovr = $common->split_color($db_object, $over_col);
     //for raters
     //rater1
     $col1_1 = "0x{$rt1['0']}";
     $col1_2 = "0x{$rt1['1']}";
     $col1_3 = "0x{$rt1['2']}";
     $col1_1 = hexdec($col1_1);
     $col1_2 = hexdec($col1_2);
     $col1_3 = hexdec($col1_3);
     //rater2
     $col2_1 = "0x{$rt2['0']}";
     $col2_2 = "0x{$rt2['1']}";
     $col2_3 = "0x{$rt2['2']}";
     $col2_1 = hexdec($col2_1);
     $col2_2 = hexdec($col2_2);
     $col2_3 = hexdec($col2_3);
     //rater3
     $col3_1 = "0x{$rt3['0']}";
     $col3_2 = "0x{$rt3['1']}";
     $col3_3 = "0x{$rt3['2']}";
     $col3_1 = hexdec($col3_1);
     $col3_2 = hexdec($col3_2);
     $col3_3 = hexdec($col3_3);
     //self
     $col4_1 = "0x{$slf['0']}";
     $col4_2 = "0x{$slf['1']}";
     $col4_3 = "0x{$slf['2']}";
     $col4_1 = hexdec($col4_1);
     $col4_2 = hexdec($col4_2);
     $col4_3 = hexdec($col4_3);
     //for admin
     $col5_1 = "0x{$admin['0']}";
     $col5_2 = "0x{$admin['1']}";
     $col5_3 = "0x{$admin['2']}";
     $col5_1 = hexdec($col5_1);
     $col5_2 = hexdec($col5_2);
     $col5_3 = hexdec($col5_3);
     //overall
     $col6_1 = "0x{$ovr['0']}";
     $col6_2 = "0x{$ovr['1']}";
     $col6_3 = "0x{$ovr['2']}";
     $col6_1 = hexdec($col6_1);
     $col6_2 = hexdec($col6_2);
     $col6_3 = hexdec($col6_3);
     //color setting ends
     $width = 340;
     $height = 270;
     $labelfont = 2;
     $labelfont1 = 1;
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($get_var)) {
         ${$kk} = $vv;
     }
     $bgcolor = imagecolorallocate($image, 0xff, 0xff, 0xff);
     $border = ImageColorAllocate($image, 0, 0, 0);
     $rater1 = imagecolorallocate($image, $col1_1, $col1_2, $col1_3);
     $rater2 = imagecolorallocate($image, $col2_1, $col2_2, $col2_3);
     $rater3 = imagecolorallocate($image, $col3_1, $col3_2, $col3_3);
     $self = imagecolorallocate($image, $col4_1, $col4_2, $col4_3);
     $boss = imagecolorallocate($image, $col5_1, $col5_2, $col5_3);
     $over = imagecolorallocate($image, $col6_1, $col6_2, $col6_3);
     /* to check 
     		$fromdate="2003-11-13";
     		$todate="2003-11-22";
     		$ratername="emp,bharathi,admin,karthik";
     		$raterval="0,1,2:1,0:1,0,2:1,2,0,2";
     		$date="2003-11-13,2003-11-17,2003-11-22:2003-11-13,2003-11-22:2003-11-13,2003-11-20,2003-11-22:2003-11-13,2003-11-15,2003-11-19,2003-11-22";
     		*/
     $fdate = $fromdate;
     $tdate = $todate;
     if ($ratername != "") {
         $rname = @split(",", $ratername);
     }
     $rt_val = @split(":", $raterval);
     $rt_date = @split(":", $date);
     $from = @split("-", $fdate);
     $to = @split("-", $tdate);
     $dt1 = mktime(0, 0, 0, $to[1], $to[2], $to[0]);
     $dt2 = mktime(0, 0, 0, $from[1], $from[2], $from[0]);
     $dt3 = $dt1 - $dt2;
     $daydiff = $dt3 / 60 / 60 / 24;
     $avg_array = @split(",", $avgrating);
     $ch_name = @split(":", $combine);
     $combine_array = array();
     for ($na = 0; $na < count($ch_name); $na++) {
         $cl_name = $ch_name[$na];
         $sp_clname = @split("=", $cl_name);
         $ky = trim($sp_clname[0]);
         $vl = $sp_clname[1];
         $combine_array[$ky] = $vl;
     }
     //na loop
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate}";
     ImageRectangle($image, 65, 24, 315, 180, $border);
     ImageString($image, $labelfont, 15, 19, $error_msg['cExceeds'], $border);
     ImageString($image, $labelfont, 40, 94, $error_msg['cMet'], $border);
     ImageString($image, $labelfont, 5, 170, $error_msg['cFellshort'], $border);
     ImageString($image, $labeltitlefont, 70, 182, "{$days}", $border);
     Imageline($image, 65, 102, 315, 102, $border);
     ImageStringUp($image, $labeltitlefont, 15, 140, $error_msg['cExpectation'], $border);
     $x1 = 65;
     //$y1 = 180;
     $startx_val = $x1;
     $starty_val = 180;
     //$x2 = 130;
     //$y2 = 95;
     $min = 63;
     $max = 311;
     $tot = $max - $min;
     $count = $daydiff;
     $interval = @($tot / $count);
     $interval = sprintf("%01.0f", $interval);
     ImageString($image, $labelfont, 15, 24, "", $border);
     for ($j = 0; $j <= $count; $j++) {
         if ($min <= $max) {
             ImageString($image, $labelfont1, $min, 176, "|", $border);
         }
         $min = $min + $interval;
     }
     $d_array = array();
     $inc = 50;
     $im_dates = split("-", $fdate);
     //ImageString($image, $labelfont, 50,80,"$im_dates[2]", $border);
     //to calculate the x2 value.
     $odd = array("01", "03", "05", "07", "08", "10", "12");
     //Odd months
     $even = array("04", "06", "09", "11");
     //even months
     //ImageString($image, $labelfont, 50,80,"$rt_date[0]", $border);
     for ($f = 0; $f < count($rt_date); $f++) {
         $date_arr = $rt_date[$f];
         $date_array = @split(",", $date_arr);
         for ($d = 0; $d < count($date_array); $d++) {
             $start_date = $im_dates[2];
             $ar = $date_array[$d];
             $im_da = split("-", $ar);
             $dte = $im_da[2];
             $m = $im_da[1];
             for ($c = 0; $c <= $daydiff; $c++) {
                 if ($dte == $start_date) {
                     $dt_array[] = $c;
                 }
                 $start_date = $start_date + 1;
                 if (in_array($m, $odd)) {
                     if ($start_date == 32) {
                         $start_date = 1;
                         $m = $m + 1;
                         if ($m == 13) {
                             $m = 1;
                         }
                     }
                 } elseif (in_array($m, $even)) {
                     if ($start_date == 31) {
                         $start_date = 1;
                         $m = $m + 1;
                         if ($m == 13) {
                             $m = 1;
                         }
                     }
                 } else {
                     if ($start_date == 29) {
                         $start_date = 1;
                         $m = $m + 1;
                     }
                 }
             }
         }
         //d loop
     }
     //f loop
     $d_inc = 0;
     $color1 = $red;
     $color2 = $blue;
     $color3 = $green;
     $color4 = $rose;
     $n_inc = 200;
     for ($i = 0; $i < count($rname); $i++) {
         $name = $rname[$i];
         $avg = $avg_array[$i];
         $rtval = $rt_val[$i];
         $rtdate = $rt_date[$i];
         $rval = @split(",", $rtval);
         $rdate = @split(",", $rtdate);
         $pl = $i + 1;
         $colour = $combine_array[$name];
         $colour = trim($colour);
         $color = ${$colour};
         for ($j = 0; $j < count($rval) - 1; $j++) {
             $ful = $rval[$j];
             $dt_val = $dt_array[$d_inc];
             $dt_val1 = $dt_array[$d_inc + 1];
             //echo $d_inc.($d_inc + 1)."<br>";
             //echo "$dt_val $dt_val1<br>";
             $y1 = $starty_val - 78 * $ful;
             $x1 = $startx_val + $interval * $dt_val;
             //cal using No of Days
             $x2 = $startx_val + $interval * $dt_val1;
             $ful2 = $rval[$j + 1];
             $y2 = $starty_val - 78 * $ful2;
             ImageLine($image, $x1, $y1, $x2, $y2, $color);
             //ImageString($image, $labelfont1,80,$inc,"$ful" ,$col);
             $inc = $inc + 10;
             $x1 = $x2;
             //$y1 = $y2;
             $nor = 1;
             $ct = count($rval) - 1;
             if ($j == $ct - 1) {
                 $nor = $nor + 1;
             }
             $d_inc = $d_inc + $nor;
         }
         //j loop
         ImageString($image, $labelfont1, 130, $n_inc, "{$colour} {$name}  {$error_msg['cAvg']}={$avg}", $color);
         $n_inc += 10;
     }
     // i loop
     if ($overall != "") {
         ImageString($image, $labelfont1, 130, 250, "{$error_msg['cOverallavg']} = {$overall}", $over);
     }
     header("Content-type: image/png");
     Imagepng($image);
     ImageDestroy($image);
 }
 function DrawXDataLabel($xlab, $xpos)
 {
     //xpos comes in in PIXELS not in world coordinates.
     //Draw an x data label centered at xlab
     if ($this->use_ttf) {
         $xlab_size = $this->TTFBBoxSize($this->axis_ttffont_size, $this->x_datalabel_angle, $this->axis_ttffont, $xlab);
         //An array
         $y = $this->plot_area[3] + $xlab_size[1] + 4;
         //in pixels
         $x = $xpos - $xlab_size[0] / 2;
         ImageTTFText($this->img, $this->axis_ttffont_size, $this->x_datalabel_angle, $x, $y, $this->ndx_text_color, $this->axis_ttffont, $xlab);
     } else {
         $xlab_size = array(ImageFontWidth($this->axis_font) * StrLen($xlab), $this->small_font_height * 3);
         if ($this->x_datalabel_angle == 90) {
             $y = $this->plot_area[3] + ImageFontWidth($this->axis_font) * StrLen($xlab);
             //in pixels
             $x = $xpos - $this->small_font_height;
             ImageStringUp($this->img, $this->axis_font, $x, $y, $xlab, $this->ndx_text_color);
         } else {
             $y = $this->plot_area[3] + ImageFontHeight($this->axis_font);
             //in pixels
             $x = $xpos - ImageFontWidth($this->axis_font) * StrLen($xlab) / 2;
             ImageString($this->img, $this->axis_font, $x, $y, $xlab, $this->ndx_text_color);
         }
     }
 }
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $get_var)
 {
     $width = 340;
     $height = 220;
     $labelfont = 2;
     $labelfont1 = 1;
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($get_var)) {
         ${$kk} = $vv;
     }
     //from table
     $config_table = $common->prefix_table("config");
     $color_qry = "select commit_color,accomplish_color from {$config_table} where id='1'";
     $res = $db_object->get_a_line($color_qry);
     $ccolor = $res['commit_color'];
     $acolor = $res['accomplish_color'];
     $com = $common->split_color($db_object, $ccolor);
     $accom = $common->split_color($db_object, $acolor);
     $p1 = "0x{$com['0']}";
     $p2 = "0x{$com['1']}";
     $p3 = "0x{$com['2']}";
     $p1 = hexdec($p1);
     $p2 = hexdec($p2);
     $p3 = hexdec($p3);
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $commit_color = imagecolorallocate($image, $p1, $p2, $p3);
     $red = imagecolorallocate($image, 0xff, 0x0, 0x0);
     $green = imagecolorallocate($image, 0x33, 0xcc, 0x0);
     /* to check 
     		$date_array = "2003-11-15,2003-11-20,2003-11-30";
     		$fulfilled_array = "25,150,10";
     		$fromdate = "2003-11-13";
     		$todate	="2003-12-01";	*/
     $fdate = $fromdate;
     $tdate = $todate;
     $fulfilled_array = @explode(",", $fulfilled_array);
     $date_array = @explode(",", $date_array);
     $to = split("-", $tdate);
     $from = split("-", $fdate);
     $dt1 = mktime(0, 0, 0, $to[1], $to[2], $to[0]);
     $dt2 = mktime(0, 0, 0, $from[1], $from[2], $from[0]);
     $dt3 = $dt1 - $dt2;
     $daydiff = $dt3 / 60 / 60 / 24;
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     ImageRectangle($image, 65, 24, 315, 180, $border);
     ImageString($image, $labelfont, 15, 19, $error_msg['cExceeds'], $border);
     ImageString($image, $labelfont, 40, 94, $error_msg['cMet'], $border);
     ImageString($image, $labelfont, 5, 170, $error_msg['cFellshort'], $border);
     ImageString($image, $labeltitlefont, 70, 182, "{$days}", $border);
     Imageline($image, 65, 102, 315, 102, $commit_color);
     ImageStringUp($image, $labeltitlefont, 15, 140, $error_msg['cExpectation'], $border);
     $x1 = 65;
     //$y1 = 180;
     $startx_val = $x1;
     $starty_val = 180;
     //$x2 = 130;
     //$y2 = 95;
     $p1 = "0x{$accom['0']}";
     $p2 = "0x{$accom['1']}";
     $p3 = "0x{$accom['2']}";
     $p1 = hexdec($p1);
     $p2 = hexdec($p2);
     $p3 = hexdec($p3);
     $accomplish_color = imagecolorallocate($image, $p1, $p2, $p3);
     $min = 63;
     $max = 311;
     $tot = $max - $min;
     $count = $daydiff;
     $interval = @($tot / $count);
     $interval = sprintf("%01.0f", $interval);
     //ImageString($image, $labelfont, 15,40, "$fulfilled_array", $border);
     for ($j = 0; $j <= $count; $j++) {
         if ($min <= $max) {
             ImageString($image, $labelfont1, $min, 176, "|", $border);
         }
         $min = $min + $interval;
     }
     $d_array = array();
     $inc = 40;
     $im_dates = split("-", $fdate);
     //to calculate the x2 value
     $odd = array("01", "03", "05", "07", "08", "10", "12");
     //Odd months
     $even = array("04", "06", "09", "11");
     //even months
     for ($d = 0; $d < count($date_array); $d++) {
         $start_date = $im_dates[2];
         $ar = $date_array[$d];
         $im_da = split("-", $ar);
         $dte = $im_da[2];
         $m = $im_da[1];
         for ($c = 0; $c <= $daydiff; $c++) {
             if ($dte == $start_date) {
                 $dt_array[] = $c;
             }
             $start_date = $start_date + 1;
             if (in_array($m, $odd)) {
                 if ($start_date == 32) {
                     $start_date = 1;
                     $m = $m + 1;
                     if ($m == 13) {
                         $m = 1;
                     }
                 }
             } elseif (in_array($m, $even)) {
                 if ($start_date == 31) {
                     $start_date = 1;
                     $m = $m + 1;
                     if ($m == 13) {
                         $m = 1;
                     }
                 }
             } else {
                 if ($start_date == 29) {
                     $start_date = 1;
                     $m = $m + 1;
                 }
             }
             //ImageString($image, $labelfont, 50,$inc,"$start_date", $border);
             $inc = $inc + 15;
         }
     }
     $inc = 50;
     for ($i = 0; $i < count($fulfilled_array) - 1; $i++) {
         $ful = $fulfilled_array[$i];
         $dt_val = $dt_array[$i + 1];
         $x2 = $startx_val + $interval * $dt_val;
         //cal using No of Days
         $div = $ful / 25;
         $y1 = $starty_val - 19.5 * $div;
         $ful2 = $fulfilled_array[$i + 1];
         $div2 = $ful2 / 25;
         $y2 = $starty_val - 19.5 * $div2;
         ImageLine($image, $x1, $y1, $x2, $y2, $accomplish_color);
         $x1 = $x2;
         //$y1 = $y2;
         $d_array = "";
         //ImageString($image, $labelfont1,80,$inc,"$x1 : $y1 : $x2 : $y2",$border);
         $inc = $inc + 10;
     }
     header("Content-type: image/png");
     Imagepng($image);
     ImageDestroy($image);
 }
Example #29
0
 function DrawText($which_font, $which_angle, $which_xpos, $which_ypos, $which_color, $which_text, $which_halign = 'left', $which_valign = 'bottom')
 {
     // TTF:
     if ($this->use_ttf) {
         $size = $this->TTFBBoxSize($which_font['size'], $which_angle, $which_font['font'], $which_text);
         $rads = deg2rad($which_angle);
         if ($which_valign == 'center') {
             $which_ypos += $size[1] / 2;
         } elseif ($which_valign == 'bottom') {
             $which_ypos += $size[1];
         }
         if ($which_halign == 'center') {
             $which_xpos -= $size[0] / 2 * cos($rads);
         } elseif ($which_halign == 'left') {
             $which_xpos += $size[0] * sin($rads);
         } elseif ($which_halign == 'right') {
             $which_xpos -= $size[0] * cos($rads);
         }
         ImageTTFText($this->img, $which_font['size'], $which_angle, $which_xpos, $which_ypos, $which_color, $which_font['font'], $which_text);
     } else {
         // Split the text by its lines, and count them
         $which_text = ereg_replace("\r", "", $which_text);
         $str = split("\n", $which_text);
         $nlines = count($str);
         $spacing = $this->line_spacing * ($nlines - 1);
         // Vertical text:
         // (Remember the alignment convention with vertical text)
         if ($which_angle == 90) {
             // The text goes around $which_xpos.
             if ($which_halign == 'center') {
                 $which_xpos -= $nlines * ($which_font['height'] + $spacing) / 2;
             } elseif ($which_halign == 'right') {
                 $which_xpos -= $nlines * ($which_font['height'] + $spacing);
             }
             $ypos = $which_ypos;
             for ($i = 0; $i < $nlines; $i++) {
                 // Center the text vertically around $which_ypos (each line)
                 if ($which_valign == 'center') {
                     $ypos = $which_ypos + strlen($str[$i]) * $which_font['width'] / 2;
                 }
                 // Make the text finish (vertically) at $which_ypos
                 if ($which_valign == 'bottom') {
                     $ypos = $which_ypos + strlen($str[$i]) * $which_font['width'];
                 }
                 ImageStringUp($this->img, $which_font['font'], $i * ($which_font['height'] + $spacing) + $which_xpos, $ypos, $str[$i], $which_color);
             }
         } else {
             // The text goes above $which_ypos
             if ($which_valign == 'top') {
                 $which_ypos -= $nlines * ($which_font['height'] + $spacing);
             }
             // The text is centered around $which_ypos
             if ($which_valign == 'center') {
                 $which_ypos -= $nlines * ($which_font['height'] + $spacing) / 2;
             }
             // valign = 'bottom' requires no modification
             $xpos = $which_xpos;
             for ($i = 0; $i < $nlines; $i++) {
                 // center the text around $which_xpos
                 if ($which_halign == 'center') {
                     $xpos = $which_xpos - strlen($str[$i]) * $which_font['width'] / 2;
                 }
                 // make the text finish at $which_xpos
                 if ($which_halign == 'right') {
                     $xpos = $which_xpos - strlen($str[$i]) * $which_font['width'];
                 }
                 ImageString($this->img, $which_font['font'], $xpos, $i * ($which_font['height'] + $spacing) + $which_ypos, $str[$i], $which_color);
             }
         }
     }
     return TRUE;
 }
 function DrawText($params)
 {
     $text = $params['text'];
     $direction = isset($params['direction']) ? $params['direction'] : '';
     $justification = isset($params['justification']) ? $params['justification'] : 'center';
     $margin_left = isset($params['margin_left']) ? $params['margin_left'] : '';
     $textwidth = ImageFontWidth($this->font) * strlen($text);
     /*if (isset($margin_left) && $textwidth >= $margin_left)
     		{
     			$text = strlen($text) - 1 . '.';
     		}*/
     if ($justification == 'center') {
         if ($direction == 'up') {
             $this->cur_y += $textwidth / 2;
             if ($this->cur_y > $this->height) {
                 $this->cur_y = $this->height;
             }
         } else {
             $this->cur_x -= $textwidth / 2;
             if ($this->cur_x < 0) {
                 $this->cur_x = 0;
             }
         }
     } else {
         if ($justification == 'right') {
             if ($direction == 'up') {
                 $this->cur_y += $textwidth;
                 if ($this->cur_y > $this->height) {
                     $this->cur_y = $this->height;
                 }
             } else {
                 $this->cur_x -= $textwidth;
                 if ($this->cur_x < 0) {
                     $this->cur_x = 0;
                 }
             }
         }
     }
     if ($direction == 'up') {
         ImageStringUp($this->hImage, $this->font, $this->cur_x, $this->cur_y, $text, $this->hColor);
     } else {
         ImageString($this->hImage, $this->font, $this->cur_x, $this->cur_y, $text, $this->hColor);
     }
     return true;
 }