Example #1
0
function mydie($errno, $errstr = '', $errfile = '', $errline = '')
{
    global $conf;
    $jpgraph = $conf->get_conf('jpgraph_path');
    include_once "{$jpgraph}/jpgraph.php";
    $err = $errstr ? $errstr : $errno;
    if ($errfile) {
        switch ($errno) {
            case 1:
                $errprefix = 'Error';
                break;
            case 2:
                $errprefix = 'Warning';
                break;
            case 8:
                $errprefix = 'Notice';
                break;
            default:
                return;
                // dont show E_STRICT errors
        }
        $err = "{$errprefix}: {$err} in '{$errfile}' line {$errline}";
    }
    $error = new JpGraphError();
    $error->Raise($err);
    echo "{$err}";
    exit;
}
 function Stroke(&$img, &$xscale, &$yscale)
 {
     $numpoints = count($this->coords[0]) / 2;
     $img->SetColor($this->color);
     $img->SetLineWeight($this->weight);
     if (isset($this->coords[1])) {
         if (count($this->coords[1]) != $numpoints) {
             JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:" . count($this->coords[1]) . " Number of Y-points:{$numpoints}");
         } else {
             $exist_x = true;
         }
     } else {
         $exist_x = false;
     }
     if ($exist_x) {
         $xs = $this->coords[1][0];
     } else {
         $xs = 0;
     }
     for ($i = 0; $i < $numpoints; ++$i) {
         if ($exist_x) {
             $x = $this->coords[1][$i];
         } else {
             $x = $i;
         }
         $xt = $xscale->Translate($x);
         $yt1 = $yscale->Translate($this->coords[0][$i * 2]);
         $yt2 = $yscale->Translate($this->coords[0][$i * 2 + 1]);
         $img->Line($xt, $yt1, $xt, $yt2);
         $img->Line($xt - $this->errwidth, $yt1, $xt + $this->errwidth, $yt1);
         $img->Line($xt - $this->errwidth, $yt2, $xt + $this->errwidth, $yt2);
     }
     return true;
 }
Example #3
0
 public function __construct($errcode, $a1 = null, $a2 = null, $a3 = null, $a4 = null, $a5 = null)
 {
     // make sure everything is assigned properly
     $errtxt = new ErrMsgText();
     JpGraphError::SetTitle('JpGraph Error: ' . $errcode);
     parent::__construct($errtxt->Get($errcode, $a1, $a2, $a3, $a4, $a5), 0);
 }
Example #4
0
 function GetCodewords($aData, $aLevel = 1)
 {
     $n = count($aData);
     if ($n == 0) {
         JpGraphError::RaiseL(25014);
     }
     //'No data to calculate codewords on.');
     $k = 1 << $aLevel + 1;
     $ck = array();
     $m = 929;
     for ($i = 0; $i < $k; ++$i) {
         $ck[$i] = 0;
     }
     $t1 = $t2 = 0;
     for ($i = 0; $i < $n; ++$i) {
         $t1 = ($aData[$i] + $ck[$k - 1]) % $m;
         for ($j = $k - 1; $j > 0; --$j) {
             $t2 = $t1 * $this->iPolCoeff[$aLevel][$j] % $m;
             $ck[$j] = ($ck[$j - 1] + ($m - $t2)) % $m;
         }
         $t2 = $t1 * $this->iPolCoeff[$aLevel][0] % $m;
         $ck[0] = ($m - $t2) % $m;
     }
     for ($i = 0; $i < $k; ++$i) {
         if ($ck[$i] > 0) {
             $ck[$i] = $m - $ck[$i];
         }
     }
     return array_reverse($ck);
 }
Example #5
0
 function GetPattern($aRow, $aCodeVal)
 {
     if (empty($this->iPatterns[$aRow % 3 * 3][$aCodeVal])) {
         JpGraphError::RaiseL(26007, $aCodeVal, $aRow);
     }
     //"GetPattern: Illegal Code Value = $aCodeVal (row=$aRow)\n\n");
     return $this->iPatterns[$aRow % 3 * 3][$aCodeVal];
 }
 function SetType($aType, $aFileName = '', $aScale = 1.0)
 {
     $this->type = $aType;
     if ($aType == MARK_IMG && $aFileName == '') {
         JpGraphError::RaiseL(23003);
     }
     $this->iFileName = $aFileName;
     $this->iScale = $aScale;
 }
Example #7
0
 function SetType($aType, $aFileName = '', $aScale = 1.0)
 {
     $this->type = $aType;
     if ($aType == MARK_IMG && $aFileName == '') {
         JpGraphError::RaiseL(23003);
         //('A filename must be specified if you set the mark type to MARK_IMG.');
     }
     $this->iFileName = $aFileName;
     $this->iScale = $aScale;
 }
 function ScatterPlot(&$datay, $datax = false)
 {
     if (count($datax) != count($datay) && is_array($datax)) {
         JpGraphError::Raise("Scatterplot must have equal number of X and Y points.");
     }
     $this->Plot($datay, $datax);
     $this->mark = new PlotMark();
     $this->mark->SetType(MARK_CIRCLE);
     $this->mark->SetColor($this->color);
 }
Example #9
0
 function execute()
 {
     $this->set_title($this->lang->stats);
     $this->tree($this->lang->stats);
     include '../lib/jpgraph/jpgraph.php';
     include '../lib/jpgraph/jpgraph_bar.php';
     if (!defined('IMG_PNG')) {
         JpGraphError::Raise("This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)");
     }
     /**
      * Posts
      */
     $query = $this->db->query("SELECT COUNT(post_id) AS posts, FROM_UNIXTIME(post_time, '%%b %%y') AS month\n\t\t\tFROM %pposts GROUP BY month\tORDER BY post_time");
     $data = array();
     while ($item = $this->db->nqfetch($query)) {
         $data[$item['month']] = $item['posts'];
     }
     if (!$data) {
         $data = array(0, 0);
     }
     $graph = new Graph(400, 300, 'auto');
     $graph->SetScale('textint');
     $graph->SetColor('aliceblue');
     $graph->SetMarginColor('white');
     $graph->xaxis->SetTickLabels(array_keys($data));
     $graph->yaxis->scale->SetGrace(20);
     $graph->title->Set($this->lang->stats_post_by_month);
     $temp = array_values($data);
     $barplot = new BarPlot($temp);
     $barplot->SetFillColor('darkorange');
     $graph->add($barplot);
     $graph->Stroke("../stats/{$this->time}1.png");
     /**
      * Registrations
      */
     $query = $this->db->query("SELECT COUNT(user_id) AS users, FROM_UNIXTIME(user_joined, '%%b %%y') AS month\n\t\t\tFROM %pusers\n\t\t\tWHERE user_joined != 0\n\t\t\tGROUP BY month\n\t\t\tORDER BY user_joined");
     $data = array();
     while ($item = $this->db->nqfetch($query)) {
         $data[$item['month']] = $item['users'];
     }
     $graph = new Graph(400, 300, 'auto');
     $graph->SetScale('textint');
     $graph->SetColor('aliceblue');
     $graph->SetMarginColor('white');
     $graph->xaxis->SetTickLabels(array_keys($data));
     $graph->yaxis->scale->SetGrace(20);
     $graph->title->Set($this->lang->stats_reg_by_month);
     $temp = array_values($data);
     $barplot = new BarPlot($temp);
     $barplot->SetFillColor('darkorange');
     $graph->add($barplot);
     $graph->Stroke("../stats/{$this->time}2.png");
     return $this->message($this->lang->stats, "<img src='../stats/{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='../stats/{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />");
 }
Example #10
0
 function Translate($a)
 {
     if ($a < 0) {
         JpGraphError::Raise("Negative data values can not be used in a log scale.");
         exit(1);
     }
     if ($a == 0) {
         $a = 1;
     }
     $a = log10($a);
     return floor($this->off + ($a * 1.0 - $this->scale[0]) * $this->scale_factor);
 }
Example #11
0
 public function Stroke()
 {
     if (JpGraphError::GetImageFlag()) {
         $errobj = new JpGraphErrObjectImg();
         $errobj->SetTitle(JpGraphError::GetTitle());
     } else {
         $errobj = new JpGraphErrObject();
         $errobj->SetTitle(JpGraphError::GetTitle());
         $errobj->SetStrokeDest(JpGraphError::GetLogFile());
     }
     $errobj->Raise($this->getMessage());
 }
Example #12
0
 /**
  *
  */
 function ApplyGraph($graph)
 {
     $this->graph = $graph;
     $method_name = '';
     if (get_class($graph) == 'Graph') {
         $method_name = 'SetupGraph';
     } else {
         $method_name = 'Setup' . get_class($graph);
     }
     if (method_exists($this, $method_name)) {
         $this->{$method_name}($graph);
     } else {
         JpGraphError::RaiseL(30001, $method_name, $method_name);
         //Theme::%s() is not defined. \nPlease make %s(\$graph) function in your theme classs.
     }
 }
Example #13
0
 function File($family, $style = FS_NORMAL)
 {
     $fam = @$this->font_files[$family];
     if (!$fam) {
         JpGraphError::RaiseL(25046, $family);
         //("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/");
     }
     $ff = @$fam[$style];
     // There are several optional file names. They are tried in order
     // and the first one found is used
     if (!is_array($ff)) {
         $ff = array($ff);
     }
     $jpgraph_font_dir = dirname(__FILE__) . '/fonts/';
     foreach ($ff as $font_file) {
         // All font families are guaranteed to have the normal style
         if ($font_file === '') {
             JpGraphError::RaiseL(25047, $this->style_names[$style], $this->font_files[$family][FS_NORMAL]);
         }
         //('Style "'.$this->style_names[$style].'" is not available for font family '.$this->font_files[$family][FS_NORMAL].'.');
         if (!$font_file) {
             JpGraphError::RaiseL(25048, $fam);
             //("Unknown font style specification [$fam].");
         }
         // check jpgraph/src/fonts dir
         $jpgraph_font_file = $jpgraph_font_dir . $font_file;
         if (file_exists($jpgraph_font_file) === true && is_readable($jpgraph_font_file) === true) {
             $font_file = $jpgraph_font_file;
             break;
         }
         // check OS font dir
         if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) {
             $font_file = MBTTF_DIR . $font_file;
         } else {
             $font_file = TTF_DIR . $font_file;
         }
         if (file_exists($font_file) === true && is_readable($font_file) === true) {
             break;
         }
     }
     if (!file_exists($font_file)) {
         JpGraphError::RaiseL(25049, $font_file);
         //("Font file \"$font_file\" is not readable or does not exist.");
     }
     return $font_file;
 }
Example #14
0
 function GetImg($aMark, $aIdx)
 {
     $n = $this->an[$aMark];
     if (is_string($aIdx)) {
         if (!in_array($aIdx, $this->colors)) {
             JpGraphError::RaiseL(23001, $this->name, $aIdx);
             //('This marker "'.($this->name).'" does not exist in color: '.$aIdx);
         }
         $idx = $this->index[$aIdx];
     } elseif (!is_integer($aIdx) || is_integer($aIdx) && $aIdx > $this->maxidx) {
         JpGraphError::RaiseL(23002, $this->name);
         //('Mark color index too large for marker "'.($this->name).'"');
     } else {
         $idx = $aIdx;
     }
     return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
 }
Example #15
0
 public function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_GREEK) {
         if (GREEK_FROM_WINDOWS) {
             $unistring = LanguageConv::gr_win2uni($aTxt);
         } else {
             $unistring = LanguageConv::gr_iso2uni($aTxt);
         }
         return $unistring;
     } elseif (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251'))) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         if (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
             $isostring = convert_cyr_string($aTxt, "k", "i");
             $unistring = LanguageConv::iso2uni($isostring);
         } else {
             $unistring = $aTxt;
         }
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_BIG5) {
         if (!function_exists('iconv')) {
             JpGraphError::RaiseL(25006);
             //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
         }
         return iconv('BIG5', 'UTF-8', $aTxt);
     } elseif (ASSUME_EUCJP_ENCODING && ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC)) {
         if (!function_exists('mb_convert_encoding')) {
             JpGraphError::RaiseL(25127);
         }
         return mb_convert_encoding($aTxt, 'UTF-8', 'EUC-JP');
     } elseif ($aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON) {
         return LanguageConv::heb_iso2uni($aTxt);
     } else {
         return $aTxt;
     }
 }
Example #16
0
 function Bezier($datax, $datay, $attraction_factor = 1)
 {
     $this->n = count($datax);
     if ($this->n !== count($datay)) {
         JpGraphError::RaiseL(19003);
     }
     $idx = 0;
     foreach ($datax as $datumx) {
         for ($i = 0; $i < $attraction_factor; $i++) {
             $this->datax[$idx++] = $datumx;
         }
     }
     $idx = 0;
     foreach ($datay as $datumy) {
         for ($i = 0; $i < $attraction_factor; $i++) {
             $this->datay[$idx++] = $datumy;
         }
     }
     $this->n *= $attraction_factor;
 }
Example #17
0
 public function Set($aLocale)
 {
     if (in_array($aLocale, array_keys($this->iDayAbb))) {
         $this->iLocale = $aLocale;
         return true;
         // already cached nothing else to do!
     }
     $pLocale = setlocale(LC_TIME, 0);
     // get current locale for LC_TIME
     if (is_array($aLocale)) {
         foreach ($aLocale as $loc) {
             $res = @setlocale(LC_TIME, $loc);
             if ($res) {
                 $aLocale = $loc;
                 break;
             }
         }
     } else {
         $res = @setlocale(LC_TIME, $aLocale);
     }
     if (!$res) {
         JpGraphError::RaiseL(25007, $aLocale);
         //("You are trying to use the locale ($aLocale) which your PHP installation does not support. Hint: Use '' to indicate the default locale for this geographic region.");
         return false;
     }
     $this->iLocale = $aLocale;
     for ($i = 0, $ofs = 0 - strftime('%w'); $i < 7; $i++, $ofs++) {
         $day = strftime('%a', strtotime("{$ofs} day"));
         $day[0] = strtoupper($day[0]);
         $this->iDayAbb[$aLocale][] = $day[0];
         $this->iShortDay[$aLocale][] = $day;
     }
     for ($i = 1; $i <= 12; ++$i) {
         list($short, $full) = explode('|', strftime("%b|%B", strtotime("2001-{$i}-01")));
         $this->iShortMonth[$aLocale][] = ucfirst($short);
         $this->iMonthName[$aLocale][] = ucfirst($full);
     }
     setlocale(LC_TIME, $pLocale);
     return true;
 }
Example #18
0
 public function E($aXMin, $aXMax, $aSteps = 50)
 {
     $this->iMin = $aXMin;
     $this->iMax = $aXMax;
     $this->iStepSize = ($aXMax - $aXMin) / $aSteps;
     if ($this->iXFunc != '') {
         $t = 'for($i=' . $aXMin . '; $i<=' . $aXMax . '; $i += ' . $this->iStepSize . ') {$ya[]=' . $this->iFunc . ';$xa[]=' . $this->iXFunc . ';}';
     } elseif ($this->iFunc != '') {
         $t = 'for($x=' . $aXMin . '; $x<=' . $aXMax . '; $x += ' . $this->iStepSize . ') {$ya[]=' . $this->iFunc . ';$xa[]=$x;} $x=' . $aXMax . ';$ya[]=' . $this->iFunc . ';$xa[]=$x;';
     } else {
         JpGraphError::RaiseL(24001);
     }
     //('FuncGenerator : No function specified. ');
     @eval($t);
     // If there is an error in the function specifcation this is the only
     // way we can discover that.
     if (empty($xa) || empty($ya)) {
         JpGraphError::RaiseL(24002);
     }
     //('FuncGenerator : Syntax error in function specification ');
     return array($xa, $ya);
 }
Example #19
0
 public function __construct($datax, $datay, $attraction_factor = 1)
 {
     // Adding control point multiple time will raise their attraction power over the curve
     $this->n = count($datax);
     if ($this->n !== count($datay)) {
         JpGraphError::RaiseL(19003);
         //('Bezier: Number of X and Y coordinates must be the same');
     }
     $idx = 0;
     foreach ($datax as $datumx) {
         for ($i = 0; $i < $attraction_factor; $i++) {
             $this->datax[$idx++] = $datumx;
         }
     }
     $idx = 0;
     foreach ($datay as $datumy) {
         for ($i = 0; $i < $attraction_factor; $i++) {
             $this->datay[$idx++] = $datumy;
         }
     }
     $this->n *= $attraction_factor;
 }
Example #20
0
 function Stroke($aImg)
 {
     if ($this->iFile != '' && $this->iCountryFlag != '') {
         JpGraphError::Raise('It is not possible to specify both an image file and a country flag for the same icon.');
     }
     if ($this->iFile != '') {
         $gdimg = Graph::LoadBkgImage('', $this->iFile);
     } else {
         if (!class_exists('FlagImages')) {
             JpGraphError::Raise('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
         }
         $fobj = new FlagImages($this->iCountryStdSize);
         $dummy = '';
         $gdimg = $fobj->GetImgByName($this->iCountryFlag, $dummy);
     }
     if ($this->iX >= 0 && $this->iX <= 1.0) {
         $w = imagesx($aImg->img);
         $this->iX = round($w * $this->iX);
     }
     if ($this->iY >= 0 && $this->iY <= 1.0) {
         $h = imagesy($aImg->img);
         $this->iY = round($h * $this->iY);
     }
     $iconw = imagesx($gdimg);
     $iconh = imagesy($gdimg);
     if ($this->iHorAnchor == 'center') {
         $this->iX -= round($iconw * $this->iScale / 2);
     }
     if ($this->iHorAnchor == 'right') {
         $this->iX -= round($iconw * $this->iScale);
     }
     if ($this->iVertAnchor == 'center') {
         $this->iY -= round($iconh * $this->iScale / 2);
     }
     if ($this->iVertAnchor == 'bottom') {
         $this->iY -= round($iconh * $this->iScale);
     }
     $aImg->CopyMerge($gdimg, $this->iX, $this->iY, 0, 0, round($iconw * $this->iScale), round($iconh * $this->iScale), $iconw, $iconh, $this->iMix);
 }
Example #21
0
 function Interpolate($xpoint)
 {
     $max = $this->n - 1;
     $min = 0;
     // Binary search to find interval
     while ($max - $min > 1) {
         $k = ($max + $min) / 2;
         if ($this->xdata[$k] > $xpoint) {
             $max = $k;
         } else {
             $min = $k;
         }
     }
     // Each interval is interpolated by a 3:degree polynom function
     $h = $this->xdata[$max] - $this->xdata[$min];
     if ($h == 0) {
         JpGraphError::Raise('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.');
     }
     $a = ($this->xdata[$max] - $xpoint) / $h;
     $b = ($xpoint - $this->xdata[$min]) / $h;
     return $a * $this->ydata[$min] + $b * $this->ydata[$max] + (($a * $a * $a - $a) * $this->y2[$min] + ($b * $b * $b - $b) * $this->y2[$max]) * ($h * $h) / 6.0;
 }
Example #22
0
 function __construct($datay, $datax = false)
 {
     if (count($datax) != count($datay) && is_array($datax)) {
         JpGraphError::RaiseL(20003);
         //("Scatterplot must have equal number of X and Y points.");
     }
     parent::__construct($datay, $datax);
     $this->mark = new PlotMark();
     $this->mark->SetType(MARK_SQUARE);
     $this->mark->SetColor($this->color);
     $this->value->SetAlign('center', 'center');
     $this->value->SetMargin(0);
     $this->link = new LineProperty(1, 'black', 'solid');
     $this->link->iShow = false;
 }
Example #23
0
 function Stroke(&$aImg, &$aXScale, &$aYScale)
 {
     $aImg->SetColor($this->color);
     $aImg->SetLineWeight($this->weight);
     if ($this->direction == VERTICAL) {
         $ymin_abs = $aYScale->Translate($aYScale->GetMinVal());
         $ymax_abs = $aYScale->Translate($aYScale->GetMaxVal());
         $xpos_abs = $aXScale->Translate($this->scaleposition);
         $aImg->Line($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs);
     } elseif ($this->direction == HORIZONTAL) {
         $xmin_abs = $aXScale->Translate($aXScale->GetMinVal());
         $xmax_abs = $aXScale->Translate($aXScale->GetMaxVal());
         $ypos_abs = $aYScale->Translate($this->scaleposition);
         $aImg->Line($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs);
     } else {
         JpGraphError::Raise(" Illegal direction for static line");
     }
 }
Example #24
0
 function SetTextLabelStart($aStart)
 {
     JpGraphError::RaiseL(11005);
     //('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.');
 }
Example #25
0
 function _TransVert3D($aGdImg, $aHorizon = 100, $aSkewDist = 120, $aDir = SKEW3D_DOWN, $aMinSize = true, $aFillColor = '#FFFFFF', $aQuality = false, $aBorder = false, $aHorizonPos = 0.5)
 {
     // Parameter check
     if ($aHorizonPos < 0 || $aHorizonPos > 1.0) {
         JpGraphError::Raise("Value for image transformation out of bounds.\nVanishing point on horizon must be specified as a value between 0 and 1.");
     }
     $w = imagesx($aGdImg);
     $h = imagesy($aGdImg);
     // Create new image
     $ww = $w;
     if ($aMinSize) {
         $hh = ceil($h * $aHorizon / ($aSkewDist + $h));
     } else {
         $hh = $h;
     }
     $newgdh = imagecreatetruecolor($ww, $hh);
     $crgb = new RGB($newgdh);
     $fillColor = $crgb->Allocate($aFillColor);
     imagefilledrectangle($newgdh, 0, 0, $ww - 1, $hh - 1, $fillColor);
     if ($aBorder) {
         $colidx = $crgb->Allocate($aBorder);
         imagerectangle($newgdh, 0, 0, $ww - 1, $hh - 1, $colidx);
     }
     $mid = round($w * $aHorizonPos);
     $last = $h;
     for ($y = 0; $y < $h; ++$y) {
         $yp = $h - $y - 1;
         $yt = floor($yp * $aHorizon / ($aSkewDist + $yp));
         if (!$aQuality) {
             if ($last <= $yt) {
                 continue;
             }
             $last = $yt;
         }
         for ($x = 0; $x < $w; ++$x) {
             $xt = ($x - $mid) * $aSkewDist / ($aSkewDist + $yp);
             if ($aDir == SKEW3D_UP) {
                 $rgb = imagecolorat($aGdImg, $x, $h - $y - 1);
             } else {
                 $rgb = imagecolorat($aGdImg, $x, $y);
             }
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $colidx = imagecolorallocate($newgdh, $r, $g, $b);
             $xt = round($xt + $mid);
             if ($aDir == SKEW3D_UP) {
                 $syt = $yt;
             } else {
                 $syt = $hh - $yt - 1;
             }
             if (!empty($set[$yt])) {
                 $nrgb = imagecolorat($newgdh, $xt, $syt);
                 $nr = $nrgb >> 16 & 0xff;
                 $ng = $nrgb >> 8 & 0xff;
                 $nb = $nrgb & 0xff;
                 $colidx = imagecolorallocate($newgdh, floor(($r + $nr) / 2), floor(($g + $ng) / 2), floor(($b + $nb) / 2));
             }
             imagesetpixel($newgdh, $xt, $syt, $colidx);
         }
         $set[$yt] = true;
     }
     return $newgdh;
 }
Example #26
0
 function SetScale($aScale, $rmax = 0)
 {
     if ($aScale == 'lin') {
         $this->scale = new PolarScale($rmax, $this);
     } elseif ($aScale == 'log') {
         $this->scale = new PolarLogScale($rmax, $this);
     } else {
         JpGraphError::Raise('Unknown scale type for polar graph. Must be "lin" or "log"');
     }
     $this->axis = new PolarAxis($this->img, $this->scale);
     $this->SetMargin(40, 40, 50, 40);
 }
Example #27
0
 function PreStrokeAdjust($aGraph)
 {
     if (substr($aGraph->axtype, 0, 4) == "text" && isset($this->coords[1])) {
         JpGraphError::RaiseL(25123);
         //("JpGraph: You can't use a text X-scale with specified X-coords. Use a \"int\" or \"lin\" scale instead.");
     }
     return true;
 }
Example #28
0
 function Stroke($aStrokeFileName = "")
 {
     $n = count($this->plots);
     // Set Y-scale
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax();
         $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor);
     }
     // Set start position end length of scale (in absolute pixels)
     $this->yscale->SetConstants($this->posx, $this->len);
     // We need as many axis as there are data points
     $nbrpnts = $this->plots[0]->GetCount();
     // If we have no titles just number the axis 1,2,3,...
     if ($this->axis_title == null) {
         for ($i = 0; $i < $nbrpnts; ++$i) {
             $this->axis_title[$i] = $i + 1;
         }
     } elseif (count($this->axis_title) < $nbrpnts) {
         JpGraphError::RaiseL(18007);
     }
     //("Number of titles does not match number of points in plot.");
     for ($i = 0; $i < $n; ++$i) {
         if ($nbrpnts != $this->plots[$i]->GetCount()) {
             JpGraphError::RaiseL(18008);
         }
     }
     //("Each radar plot must have the same number of data points.");
     if ($this->background_image != "") {
         $this->StrokeFrameBackground();
     } else {
         $this->StrokeFrame();
     }
     $astep = 2 * M_PI / $nbrpnts;
     // Prepare legends
     for ($i = 0; $i < $n; ++$i) {
         $this->plots[$i]->Legend($this);
     }
     $this->legend->Stroke($this->img);
     $this->footer->Stroke($this->img);
     if ($this->grid_depth == DEPTH_BACK) {
         // Draw axis and grid
         for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) {
             $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0);
         }
     }
     // Plot points
     $a = M_PI / 2;
     for ($i = 0; $i < $n; ++$i) {
         $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a);
     }
     if ($this->grid_depth != DEPTH_BACK) {
         // Draw axis and grid
         for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) {
             $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0);
         }
     }
     $this->grid->Stroke($this->img, $grid);
     $this->StrokeTitles();
     // Stroke texts
     if ($this->texts != null) {
         foreach ($this->texts as $t) {
             $t->Stroke($this->img);
         }
     }
     // Should we do any final image transformation
     if ($this->iImgTrans) {
         if (!class_exists('ImgTrans')) {
             require_once 'jpgraph_imgtrans.php';
         }
         $tform = new ImgTrans($this->img->img);
         $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder);
     }
     // If the filename is given as the special "__handle"
     // then the image handler is returned and the image is NOT
     // streamed back
     if ($aStrokeFileName == _IMG_HANDLER) {
         return $this->img->img;
     } else {
         // Finally stream the generated picture
         $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
     }
 }
Example #29
0
 function __construct($aDir, $aPattern, $aMin, $aMax, $aColor = "black", $aWeight = 1, $aDepth = DEPTH_BACK)
 {
     $f = new RectPatternFactory();
     $this->prect = $f->Create($aPattern, $aColor, $aWeight);
     if (is_numeric($aMin) && is_numeric($aMax) && $aMin > $aMax) {
         JpGraphError::RaiseL(16004);
     }
     //('Min value for plotband is larger than specified max value. Please correct.');
     $this->dir = $aDir;
     $this->min = $aMin;
     $this->max = $aMax;
     $this->depth = $aDepth;
 }
Example #30
0
 function _gdImgHandle($agdCanvas, $x, $y, $fx = 0, $fy = 0, $w = 0, $h = 0, $mix = 100)
 {
     if ($w == 0) {
         $w = @imagesx($agdCanvas);
     }
     if ($w === NULL) {
         JpGraphError::RaiseL(12007);
         //('Argument to MGraph::Add() is not a valid GD image handle.');
         return;
     }
     if ($h == 0) {
         $h = @imagesy($agdCanvas);
     }
     $this->iGraphs[$this->iCnt++] = array($agdCanvas, $x, $y, $fx, $fy, $w, $h, $mix);
 }