Ejemplo n.º 1
0
 function Add($aObj)
 {
     if (is_array($aObj) && count($aObj) > 0) {
         $cl = $aObj[0];
     } else {
         $cl = $aObj;
     }
     if ($cl instanceof Text) {
         $this->AddText($aObj);
     } elseif (class_exists('IconPlot', false) && $cl instanceof IconPlot) {
         $this->AddIcon($aObj);
     } elseif ($cl instanceof MatrixPlot || $cl instanceof LayoutRect || $cl instanceof LayoutHor) {
         if (is_array($aObj)) {
             $this->plots = array_merge($this->plots, $aObj);
         } else {
             $this->plots[] = $aObj;
         }
     } else {
         JpgraphError::RaiseL(29206);
     }
 }
Ejemplo n.º 2
0
 function StrokeCSIM($aScriptName = '', $aCSIMName = '', $aBorder = 0)
 {
     global $_REQUEST;
     if ($aCSIMName == '') {
         // create a random map name
         srand((double) microtime() * 1000000);
         $r = rand(0, 100000);
         $aCSIMName = '__mapname' . $r . '__';
     }
     if (empty($_REQUEST[_CSIM_DISPLAY])) {
         // First determine if we need to check for a cached version
         // This differs from the standard cache in the sense that the
         // image and CSIM map HTML file is written relative to the directory
         // the script executes in and not the specified cache directory.
         // The reason for this is that the cache directory is not necessarily
         // accessible from the HTTP server.
         if ($this->csimcachename != '') {
             $dir = dirname($this->csimcachename);
             $base = basename($this->csimcachename);
             $base = strtok($base, '.');
             $suffix = strtok('.');
             $basecsim = $dir . '/' . $base . '_csim_.html';
             $baseimg = $base . '.' . $this->img->img_format;
             // Check that apache can write to directory specified
             if (file_exists($dir) && !is_writeable($dir)) {
                 JpgraphError::Raise('Apache/PHP does not have permission to write to the CSIM cache directory (' . $dir . '). Check permissions.');
             }
             // Make sure directory exists
             $this->cache->MakeDirs($dir);
             // Write the image file
             $this->Stroke(CSIMCACHE_DIR . $baseimg);
             // Construct wrapper HTML and write to file and send it back to browser
             $htmlwrap = $this->GetHTMLImageMap($aCSIMName) . "\n" . '<img src="' . CSIMCACHE_HTTP_DIR . $baseimg . '" ISMAP USEMAP="#' . $aCSIMName . '" border=' . $aBorder . '>' . "\n";
             if ($fh = @fopen($basecsim, 'w')) {
                 fwrite($fh, $htmlwrap);
                 fclose($fh);
                 echo $htmlwrap;
             } else {
                 JpGraphError::Raise(" Can't write CSIM \"{$basecsim}\" for writing. Check free space and permissions.");
             }
         } else {
             if ($aScriptName == '') {
                 JpGraphError::Raise('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().');
                 exit;
             }
             // Construct the HTML wrapper page
             // Get all user defined URL arguments
             reset($_REQUEST);
             // This is a JPGRAPH internal defined that prevents
             // us from recursively coming here again
             $urlarg = '?' . _CSIM_DISPLAY . '=1';
             while (list($key, $value) = each($_REQUEST)) {
                 if (is_array($value)) {
                     $n = count($value);
                     for ($i = 0; $i < $n; ++$i) {
                         $urlarg .= '&' . $key . '%5B%5D=' . urlencode($value[$i]);
                     }
                 } else {
                     $urlarg .= '&' . $key . '=' . urlencode($value);
                 }
             }
             echo $this->GetHTMLImageMap($aCSIMName);
             echo "<img src='" . $aScriptName . $urlarg . "' ISMAP USEMAP='#" . $aCSIMName . "' border={$aBorder}>";
         }
     } else {
         $this->Stroke();
     }
 }
Ejemplo n.º 3
0
 function StrokeCSIM($aScriptName = 'auto', $aCSIMName = '', $aBorder = 0)
 {
     if ($aCSIMName == '') {
         // create a random map name
         srand((double) microtime() * 1000000);
         $r = rand(0, 100000);
         $aCSIMName = '__mapname' . $r . '__';
     }
     if ($aScriptName == 'auto') {
         $aScriptName = basename($_SERVER['PHP_SELF']);
     }
     $urlarg = $this->GetURLArguments(true);
     if (empty($_GET[_CSIM_DISPLAY])) {
         // First determine if we need to check for a cached version
         // This differs from the standard cache in the sense that the
         // image and CSIM map HTML file is written relative to the directory
         // the script executes in and not the specified cache directory.
         // The reason for this is that the cache directory is not necessarily
         // accessible from the HTTP server.
         if ($this->csimcachename != '') {
             $dir = dirname($this->csimcachename);
             $base = basename($this->csimcachename);
             $base = strtok($base, '.');
             $suffix = strtok('.');
             $basecsim = $dir . '/' . $base . '?' . $urlarg . '_csim_.html';
             $baseimg = $base . '?' . $urlarg . '.' . $this->img->img_format;
             // Check that apache can write to directory specified
             if (file_exists($dir) && !is_writeable($dir)) {
                 JpgraphError::RaiseL(25028, $dir);
                 //('Apache/PHP does not have permission to write to the CSIM cache directory ('.$dir.'). Check permissions.');
             }
             // Make sure directory exists
             $this->cache->MakeDirs($dir);
             // Write the image file
             $this->Stroke(CSIMCACHE_DIR . $baseimg);
             // Construct wrapper HTML and write to file and send it back to browser
             // In the src URL we must replace the '?' with its encoding to prevent the arguments
             // to be converted to real arguments.
             $tmp = str_replace('?', '%3f', $baseimg);
             $htmlwrap = $this->GetHTMLImageMap($aCSIMName) . "\n" . '<img src="' . CSIMCACHE_HTTP_DIR . $tmp . '" ismap="ismap" usemap="#' . $aCSIMName . ' width="' . $this->img->width . '" height="' . $this->img->height . "\" alt=\"" . $this->iCSIMImgAlt . "\" />\n";
             if ($fh = @fopen($basecsim, 'w')) {
                 fwrite($fh, $htmlwrap);
                 fclose($fh);
                 echo $htmlwrap;
             } else {
                 JpGraphError::RaiseL(25029, $basecsim);
                 //(" Can't write CSIM \"$basecsim\" for writing. Check free space and permissions.");
             }
         } else {
             if ($aScriptName == '') {
                 JpGraphError::RaiseL(25030);
                 //('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().');
             }
             echo $this->GetHTMLImageMap($aCSIMName) . $this->GetCSIMImgHTML($aCSIMName, $aScriptName, $aBorder);
         }
     } else {
         $this->Stroke();
     }
 }
Ejemplo n.º 4
0
 function Add($aObj)
 {
     if (is_array($aObj) && count($aObj) > 0) {
         $cl = $aObj[0];
     } else {
         $cl = $aObj;
     }
     if ($cl instanceof Text) {
         $this->AddText($aObj);
     } elseif ($cl instanceof IconPlot) {
         $this->AddIcon($aObj);
     } elseif ($cl instanceof WindrosePlot || $cl instanceof LayoutRect || $cl instanceof LayoutHor) {
         $this->plots[] = $aObj;
     } else {
         JpgraphError::RaiseL(22021);
     }
 }
Ejemplo n.º 5
0
 function Enc($aData)
 {
     parent::Enc($aData);
     $cn = $this->GetChecksum($aData);
     $aData .= $cn;
     $e = new BarcodePrintSpec();
     $e->iEncoding = $this->GetName();
     $e->iData = $aData;
     $e->iLeftData = substr($aData, 0, 1);
     $e->iRightData = substr($aData, 11, 1);
     $ns = substr($aData, 0, 1) + 0;
     $p = $this->iParity[$cn + 0];
     $e->iInfo = " Parity={$p}, Type={$this->iType}";
     $e->iBar[0] = array(0, 1, 1, $this->iGuards[0]);
     $n = count($this->iOrder[$this->iType]);
     for ($i = 0; $i < $n; ++$i) {
         $c = substr($aData, $this->iOrder[$this->iType][$i], 1);
         $pi = $ns == 0 ? substr($p, $i, 1) + 0 : 1 - substr($p, $i, 1);
         $e->iBar[$i + 1] = array($c, 0, 0, $this->iSymbols[$pi][$c + 0]);
     }
     switch ($this->iType) {
         case 0:
         case 3:
             break;
         case 1:
             $pi = $ns == 0 ? substr($p, 5, 1) + 0 : 1 - substr($p, 5, 1);
             $e->iBar[6] = array('3', 0, 0, $this->iSymbols[$pi][3]);
             break;
         case 2:
             $pi = $ns == 0 ? substr($p, 5, 1) + 0 : 1 - substr($p, 5, 1);
             $e->iBar[6] = array('4', 0, 0, $this->iSymbols[$pi][4]);
             break;
         default:
             JpgraphError::RaiseL(1004, $this->iType);
     }
     $e->iBar[7] = array(0, 0, 1, $this->iGuards[1]);
     return $e;
 }
 function AutoSize()
 {
     if ($this->img->img == null) {
         // The predefined left, right, top, bottom margins.
         // Note that the top margin might incease depending on
         // the title.
         $lm = $this->img->left_margin;
         $rm = $this->img->right_margin;
         $rm += 2;
         $tm = $this->img->top_margin;
         $bm = $this->img->bottom_margin;
         $bm += 1;
         if (BRAND_TIMING) {
             $bm += 10;
         }
         // First find out the height
         $n = $this->GetBarMaxLineNumber() + 1;
         $m = max($this->GetMaxLabelHeight(), $this->GetMaxBarAbsHeight());
         $height = $n * ((1 + $this->iLabelVMarginFactor) * $m);
         // Add the height of the scale titles
         $h = $this->scale->GetHeaderHeight();
         $height += $h;
         // Calculate the top margin needed for title and subtitle
         if ($this->title->t != "") {
             $tm += $this->title->GetFontHeight($this->img);
         }
         if ($this->subtitle->t != "") {
             $tm += $this->subtitle->GetFontHeight($this->img);
         }
         // ...and then take the bottom and top plot margins into account
         $height += $tm + $bm + $this->scale->iTopPlotMargin + $this->scale->iBottomPlotMargin;
         // Now find the minimum width for the chart required
         // If day scale or smaller is shown then we use the day font width
         // as the base size unit.
         // If only weeks or above is displayed we use a modified unit to
         // get a smaller image.
         if ($this->scale->IsDisplayHour() || $this->scale->IsDisplayMinute()) {
             // Add 2 pixel margin on each side
             $fw = $this->scale->day->GetFontWidth($this->img) + 4;
         } elseif ($this->scale->IsDisplayWeek()) {
             $fw = 8;
         } elseif ($this->scale->IsDisplayMonth()) {
             $fw = 4;
         } else {
             $fw = 2;
         }
         $nd = $this->scale->GetNumberOfDays();
         if ($this->scale->IsDisplayDay()) {
             // If the days are displayed we also need to figure out
             // how much space each day's title will require.
             switch ($this->scale->day->iStyle) {
                 case DAYSTYLE_LONG:
                     $txt = "Monday";
                     break;
                 case DAYSTYLE_LONGDAYDATE1:
                     $txt = "Monday 23 Jun";
                     break;
                 case DAYSTYLE_LONGDAYDATE2:
                     $txt = "Monday 23 Jun 2003";
                     break;
                 case DAYSTYLE_SHORT:
                     $txt = "Mon";
                     break;
                 case DAYSTYLE_SHORTDAYDATE1:
                     $txt = "Mon 23/6";
                     break;
                 case DAYSTYLE_SHORTDAYDATE2:
                     $txt = "Mon 23 Jun";
                     break;
                 case DAYSTYLE_SHORTDAYDATE3:
                     $txt = "Mon 23";
                     break;
                 case DAYSTYLE_SHORTDATE1:
                     $txt = "23/6";
                     break;
                 case DAYSTYLE_SHORTDATE2:
                     $txt = "23 Jun";
                     break;
                 case DAYSTYLE_SHORTDATE3:
                     $txt = "Mon 23";
                     break;
                 case DAYSTYLE_SHORTDATE4:
                     $txt = "88";
                     break;
                 case DAYSTYLE_CUSTOM:
                     $txt = date($this->scale->day->iLabelFormStr, strtotime('2003-12-20 18:00'));
                     break;
                 case DAYSTYLE_ONELETTER:
                 default:
                     $txt = "M";
                     break;
             }
             $fw = $this->scale->day->GetStrWidth($this->img, $txt) + 6;
         }
         // If we have hours enabled we must make sure that each day has enough
         // space to fit the number of hours to be displayed.
         if ($this->scale->IsDisplayHour()) {
             // Depending on what format the user has choose we need different amount
             // of space. We therefore create a typical string for the choosen format
             // and determine the length of that string.
             switch ($this->scale->hour->iStyle) {
                 case HOURSTYLE_HMAMPM:
                     $txt = '12:00pm';
                     break;
                 case HOURSTYLE_H24:
                     // 13
                     $txt = '24';
                     break;
                 case HOURSTYLE_HAMPM:
                     $txt = '12pm';
                     break;
                 case HOURSTYLE_CUSTOM:
                     $txt = date($this->scale->hour->iLabelFormStr, strtotime('2003-12-20 18:00'));
                     break;
                 case HOURSTYLE_HM24:
                 default:
                     $txt = '24:00';
                     break;
             }
             $hfw = $this->scale->hour->GetStrWidth($this->img, $txt) + 6;
             $mw = $hfw;
             if ($this->scale->IsDisplayMinute()) {
                 // Depending on what format the user has choose we need different amount
                 // of space. We therefore create a typical string for the choosen format
                 // and determine the length of that string.
                 switch ($this->scale->minute->iStyle) {
                     case HOURSTYLE_CUSTOM:
                         $txt2 = date($this->scale->minute->iLabelFormStr, strtotime('2005-05-15 18:55'));
                         break;
                     case MINUTESTYLE_MM:
                     default:
                         $txt2 = '15';
                         break;
                 }
                 $mfw = $this->scale->minute->GetStrWidth($this->img, $txt2) + 6;
                 $n2 = ceil(60 / $this->scale->minute->GetIntervall());
                 $mw = $n2 * $mfw;
             }
             $hfw = $hfw < $mw ? $mw : $hfw;
             $n = ceil(24 * 60 / $this->scale->TimeToMinutes($this->scale->hour->GetIntervall()));
             $hw = $n * $hfw;
             $fw = $fw < $hw ? $hw : $fw;
         }
         // We need to repeat this code block here as well.
         // THIS iS NOT A MISTAKE !
         // We really need it since we need to adjust for minutes both in the case
         // where hour scale is shown and when it is not shown.
         if ($this->scale->IsDisplayMinute()) {
             // Depending on what format the user has choose we need different amount
             // of space. We therefore create a typical string for the choosen format
             // and determine the length of that string.
             switch ($this->scale->minute->iStyle) {
                 case HOURSTYLE_CUSTOM:
                     $txt = date($this->scale->minute->iLabelFormStr, strtotime('2005-05-15 18:55'));
                     break;
                 case MINUTESTYLE_MM:
                 default:
                     $txt = '15';
                     break;
             }
             $mfw = $this->scale->minute->GetStrWidth($this->img, $txt) + 6;
             $n = ceil(60 / $this->scale->TimeToMinutes($this->scale->minute->GetIntervall()));
             $mw = $n * $mfw;
             $fw = $fw < $mw ? $mw : $fw;
         }
         // If we display week we must make sure that 7*$fw is enough
         // to fit up to 10 characters of the week font (if the week is enabled)
         if ($this->scale->IsDisplayWeek()) {
             // Depending on what format the user has choose we need different amount
             // of space
             $fsw = strlen($this->scale->week->iLabelFormStr);
             if ($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAY2WNBR) {
                 $fsw += 8;
             } elseif ($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAYWNBR) {
                 $fsw += 7;
             } else {
                 $fsw += 4;
             }
             $ww = $fsw * $this->scale->week->GetFontWidth($this->img);
             if (7 * $fw < $ww) {
                 $fw = ceil($ww / 7);
             }
         }
         if (!$this->scale->IsDisplayDay() && !$this->scale->IsDisplayHour() && !(($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAYWNBR || $this->scale->week->iStyle == WEEKSTYLE_FIRSTDAY2WNBR) && $this->scale->IsDisplayWeek())) {
             // If we don't display the individual days we can shrink the
             // scale a little bit. This is a little bit pragmatic at the
             // moment and should be re-written to take into account
             // a) What scales exactly are shown and
             // b) what format do they use so we know how wide we need to
             // make each scale text space at minimum.
             $fw /= 2;
             if (!$this->scale->IsDisplayWeek()) {
                 $fw /= 1.8;
             }
         }
         $cw = $this->GetMaxActInfoColWidth();
         $this->scale->actinfo->SetMinColWidth($cw);
         if ($this->img->width <= 0) {
             // Now determine the width for the activity titles column
             // Firdst find out the maximum width of each object column
             $titlewidth = max(max($this->GetMaxLabelWidth(), $this->scale->tableTitle->GetWidth($this->img)), $this->scale->actinfo->GetWidth($this->img));
             // Add the width of the vertivcal divider line
             $titlewidth += $this->scale->divider->iWeight * 2;
             // Now get the total width taking
             // titlewidth, left and rigt margin, dayfont size
             // into account
             $width = $titlewidth + $nd * $fw + $lm + $rm;
         } else {
             $width = $this->img->width;
         }
         $width = round($width);
         $height = round($height);
         // Make a sanity check on image size
         if ($width > MAX_GANTTIMG_SIZE_W || $height > MAX_GANTTIMG_SIZE_H) {
             JpgraphError::RaiseL(6007, $width, $height);
             //("Sanity check for automatic Gantt chart size failed. Either the width (=$width) or height (=$height) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.");
         }
         $this->img->CreateImgCanvas($width, $height);
         $this->img->SetMargin($lm, $rm, $tm, $bm);
     }
 }
Ejemplo n.º 7
0
 function StrokeCSIM($aScriptName = 'auto', $aCSIMName = '', $aBorder = 0)
 {
     if ($aCSIMName == '') {
         // create a random map name
         srand((double) microtime() * 1000000);
         $r = rand(0, 100000);
         $aCSIMName = '__mapname' . $r . '__';
     }
     if ($aScriptName == 'auto') {
         $aScriptName = basename($_SERVER['PHP_SELF']);
     }
     if (empty($_GET[_CSIM_DISPLAY])) {
         // First determine if we need to check for a cached version
         // This differs from the standard cache in the sense that the
         // image and CSIM map HTML file is written relative to the directory
         // the script executes in and not the specified cache directory.
         // The reason for this is that the cache directory is not necessarily
         // accessible from the HTTP server.
         if ($this->csimcachename != '') {
             $dir = dirname($this->csimcachename);
             $base = basename($this->csimcachename);
             $base = strtok($base, '.');
             $suffix = strtok('.');
             $basecsim = $dir . '/' . $base . '_csim_.html';
             $baseimg = $base . '.' . $this->img->img_format;
             // Check that apache can write to directory specified
             if (file_exists($dir) && !is_writeable($dir)) {
                 JpgraphError::RaiseL(25028, $dir);
                 //('Apache/PHP does not have permission to write to the CSIM cache directory ('.$dir.'). Check permissions.');
             }
             // Make sure directory exists
             $this->cache->MakeDirs($dir);
             // Write the image file
             $this->Stroke(CSIMCACHE_DIR . $baseimg);
             // Construct wrapper HTML and write to file and send it back to browser
             $htmlwrap = $this->GetHTMLImageMap($aCSIMName) . "\n" . '<img src="' . htmlentities(CSIMCACHE_HTTP_DIR . $baseimg) . '" ismap usemap="#' . $aCSIMName . '" border=' . $aBorder . ' width=' . $this->img->width . ' height=' . $this->img->height . " alt=\"\" />\n";
             if ($fh = @fopen($basecsim, 'w')) {
                 fwrite($fh, $htmlwrap);
                 fclose($fh);
                 echo $htmlwrap;
             } else {
                 JpGraphError::RaiseL(25029, $basecsim);
             }
             //(" Can't write CSIM \"$basecsim\" for writing. Check free space and permissions.");
         } else {
             if ($aScriptName == '') {
                 JpGraphError::RaiseL(25030);
                 //('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().');
                 exit;
             }
             // This is a JPGRAPH internal defined that prevents
             // us from recursively coming here again
             $urlarg = '?' . _CSIM_DISPLAY . '=1';
             // Now reconstruct any user URL argument
             reset($_GET);
             while (list($key, $value) = each($_GET)) {
                 if (is_array($value)) {
                     $n = count($value);
                     for ($i = 0; $i < $n; ++$i) {
                         $urlarg .= '&' . $key . '%5B%5D=' . urlencode($value[$i]);
                     }
                 } else {
                     $urlarg .= '&' . $key . '=' . urlencode($value);
                 }
             }
             // It's not ideal to convert POST argument to GET arguments
             // but there is little else we can do. One idea for the
             // future might be recreate the POST header in case.
             reset($_POST);
             while (list($key, $value) = each($_POST)) {
                 if (is_array($value)) {
                     $n = count($value);
                     for ($i = 0; $i < $n; ++$i) {
                         $urlarg .= '&' . $key . '%5B%5D=' . urlencode($value[$i]);
                     }
                 } else {
                     $urlarg .= '&' . $key . '=' . urlencode($value);
                 }
             }
             echo $this->GetHTMLImageMap($aCSIMName);
             echo "<img src='" . htmlentities($aScriptName . $urlarg) . "' ismap usemap='#" . $aCSIMName . '\' border=' . $aBorder . '  width=' . $this->img->width . ' height=' . $this->img->height . " alt=\"\" />\n";
         }
     } else {
         $this->Stroke();
     }
 }
Ejemplo n.º 8
0
 function Add(&$aObj)
 {
     if (is_array($aObj) && count($aObj) > 0) {
         $cl = $aObj[0];
     } else {
         $cl = $aObj;
     }
     if (is_a($cl, 'Text')) {
         $this->AddText($aObj);
     } elseif (is_a($cl, 'IconPlot')) {
         $this->AddIcon($aObj);
     } elseif (!is_a($cl, 'WindrosePlot')) {
         JpgraphError::RaiseL(22021);
     } else {
         $this->plots[] =& $aObj;
     }
 }
Ejemplo n.º 9
0
 function GetBarMinMax()
 {
     $start = 0;
     $n = count($this->iObj);
     while ($this->iObj[$start]->GetMaxDate() === false && $start < $n) {
         ++$start;
     }
     if ($start >= $n) {
         JpgraphError::Raise('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]');
     }
     $max = $this->scale->NormalizeDate($this->iObj[$start]->GetMaxDate());
     $min = $this->scale->NormalizeDate($this->iObj[$start]->GetMinDate());
     for ($i = $start + 1; $i < $n; ++$i) {
         $rmax = $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate());
         if ($rmax != false) {
             $max = Max($max, $rmax);
         }
         $rmin = $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate());
         if ($rmin != false) {
             $min = Min($min, $rmin);
         }
     }
     $minDate = date("Y-m-d", $min);
     $min = strtotime($minDate);
     $maxDate = date("Y-m-d 23:59", $max);
     $max = strtotime($maxDate);
     return array($min, $max);
 }
Ejemplo n.º 10
0
 function Enc($aData)
 {
     parent::Enc($aData);
     $cn = $this->GetChecksum($aData);
     $aData .= $cn;
     // Now encode the data
     $e = new BarcodePrintSpec();
     $e->iEncoding = $this->GetName();
     $e->iData = $aData;
     $e->iLeftData = substr($aData, 0, 1);
     // Number system
     $e->iRightData = substr($aData, 11, 1);
     // Get parity pattern
     $ns = substr($aData, 0, 1) + 0;
     $p = $this->iParity[$cn + 0];
     $e->iInfo = " Parity={$p}, Type={$this->iType}";
     $e->iBar[0] = array(0, 1, 1, $this->iGuards[0]);
     $n = count($this->iOrder[$this->iType]);
     for ($i = 0; $i < $n; ++$i) {
         $c = substr($aData, $this->iOrder[$this->iType][$i], 1);
         $pi = $ns == 0 ? substr($p, $i, 1) + 0 : 1 - substr($p, $i, 1);
         $e->iBar[$i + 1] = array($c, 0, 0, $this->iSymbols[$pi][$c + 0]);
     }
     switch ($this->iType) {
         case 0:
         case 3:
             break;
         case 1:
             // Last symbol is always '3' for type 1
             $pi = $ns == 0 ? substr($p, 5, 1) + 0 : 1 - substr($p, 5, 1);
             $e->iBar[6] = array('3', 0, 0, $this->iSymbols[$pi][3]);
             break;
         case 2:
             // Last symbol is always '4' for type 2
             $pi = $ns == 0 ? substr($p, 5, 1) + 0 : 1 - substr($p, 5, 1);
             $e->iBar[6] = array('4', 0, 0, $this->iSymbols[$pi][4]);
             break;
         default:
             JpgraphError::RaiseL(1004, $this->iType);
             //('Internal barcode error. Unknown UPC-E encoding type:'.$this->iType);
     }
     $e->iBar[7] = array(0, 0, 1, $this->iGuards[1]);
     return $e;
 }
 function GanttGraph($aWidth = 0, $aHeight = 0, $aCachedName = "", $aTimeOut = 0, $aInline = true)
 {
     // Backward compatibility
     if ($aWidth == -1) {
         $aWidth = 0;
     }
     if ($aHeight == -1) {
         $aHeight = 0;
     }
     if ($aWidth < 0 || $aHeight < 0) {
         JpgraphError::Raise("You can't specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.");
     }
     Graph::Graph($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline);
     $this->scale = new GanttScale($this->img);
     if ($aWidth > 0) {
         $this->img->SetMargin($aWidth / 17, $aWidth / 17, $aHeight / 7, $aHeight / 10);
     }
     $this->scale->ShowHeaders(GANTT_HWEEK | GANTT_HDAY);
     $this->SetBox();
 }
Ejemplo n.º 12
0
 /**
  * Set the specification of the color backgrounds and also the
  * optional exact colors to be used
  * 
  * @param mixed $aSpec  An array of 3 1x2 arrays. Each array specify the 
  * color indication value at x=0 and x=max x in order to determine the slope
  * @param mixed $aColors  An array with four elements specifying the colors
  * of each color indicator
  */
 public function SetColorIndication(array $aSpec, array $aColors = null)
 {
     if (count($aSpec) !== 3) {
         JpgraphError::Raise('Specification of scale values for background indicators must be an array with three elements.');
     }
     $this->iColorInd = $aSpec;
     if ($aColors !== null) {
         if (is_array($aColors) && count($aColors) == 4) {
             $this->iColorSpec = $aColors;
         } else {
             JpGraphError::Raise('Color specification for background indication must have four colors.');
         }
     }
 }
Ejemplo n.º 13
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_bar.php';
$l1datay = array(11, 9, 2, 4, 3, 13, 17);
$l2datay = array(23, 12, 5, 19, 17, 10, 15);
JpgraphError::SetImageFlag(false);
JpGraphError::SetLogFile('syslog');
// Create the graph.
$graph = new Graph(400, 200);
$graph->SetScale('intlin');
$graph->img->SetMargin(40, 130, 20, 40);
$graph->SetShadow();
// Create the linear error plot
$l1plot = new LinePlot($l1datay);
$l1plot->SetColor('red');
$l1plot->SetWeight(2);
$l1plot->SetLegend('Prediction');
// Create the bar plot
$bplot = new BarPlot($l2datay);
$bplot->SetFillColor('orange');
$bplot->SetLegend('Result');
// Add the plots to t'he graph
$graph->Add($bplot);
$graph->Add($l1plot);
$graph->title->Set('Adding a line plot to a bar graph v3');
$graph->xaxis->title->Set('X-title');
$graph->yaxis->title->Set('Y-title');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
Ejemplo n.º 14
0
 function AutoSize()
 {
     if ($this->img->img == null) {
         $lm = $this->img->left_margin;
         $rm = $this->img->right_margin;
         $rm += 2;
         $tm = $this->img->top_margin;
         $bm = $this->img->bottom_margin;
         $bm += 1;
         if (BRAND_TIMING) {
             $bm += 10;
         }
         $n = $this->GetBarMaxLineNumber() + 1;
         $m = max($this->GetMaxLabelHeight(), $this->GetMaxBarAbsHeight());
         $height = $n * ((1 + $this->iLabelVMarginFactor) * $m);
         $h = $this->scale->GetHeaderHeight();
         $height += $h;
         if ($this->title->t != "") {
             $tm += $this->title->GetFontHeight($this->img);
         }
         if ($this->subtitle->t != "") {
             $tm += $this->subtitle->GetFontHeight($this->img);
         }
         $height += $tm + $bm + $this->scale->iTopPlotMargin + $this->scale->iBottomPlotMargin;
         if ($this->scale->IsDisplayHour() || $this->scale->IsDisplayMinute()) {
             $fw = $this->scale->day->GetFontWidth($this->img) + 4;
         } elseif ($this->scale->IsDisplayWeek()) {
             $fw = 8;
         } elseif ($this->scale->IsDisplayMonth()) {
             $fw = 4;
         } else {
             $fw = 2;
         }
         $nd = $this->scale->GetNumberOfDays();
         if ($this->scale->IsDisplayDay()) {
             switch ($this->scale->day->iStyle) {
                 case DAYSTYLE_LONG:
                     $txt = "Monday";
                     break;
                 case DAYSTYLE_LONGDAYDATE1:
                     $txt = "Monday 23 Jun";
                     break;
                 case DAYSTYLE_LONGDAYDATE2:
                     $txt = "Monday 23 Jun 2003";
                     break;
                 case DAYSTYLE_SHORT:
                     $txt = "Mon";
                     break;
                 case DAYSTYLE_SHORTDAYDATE1:
                     $txt = "Mon 23/6";
                     break;
                 case DAYSTYLE_SHORTDAYDATE2:
                     $txt = "Mon 23 Jun";
                     break;
                 case DAYSTYLE_SHORTDAYDATE3:
                     $txt = "Mon 23";
                     break;
                 case DAYSTYLE_SHORTDATE1:
                     $txt = "23/6";
                     break;
                 case DAYSTYLE_SHORTDATE2:
                     $txt = "23 Jun";
                     break;
                 case DAYSTYLE_SHORTDATE3:
                     $txt = "Mon 23";
                     break;
                 case DAYSTYLE_SHORTDATE4:
                     $txt = "88";
                     break;
                 case DAYSTYLE_CUSTOM:
                     $txt = date($this->scale->day->iLabelFormStr, strtotime('2003-12-20 18:00'));
                     break;
                 case DAYSTYLE_ONELETTER:
                 default:
                     $txt = "M";
                     break;
             }
             $fw = $this->scale->day->GetStrWidth($this->img, $txt) + 6;
         }
         if ($this->scale->IsDisplayHour()) {
             switch ($this->scale->hour->iStyle) {
                 case HOURSTYLE_HMAMPM:
                     $txt = '12:00pm';
                     break;
                 case HOURSTYLE_H24:
                     $txt = '24';
                     break;
                 case HOURSTYLE_HAMPM:
                     $txt = '12pm';
                     break;
                 case HOURSTYLE_CUSTOM:
                     $txt = date($this->scale->hour->iLabelFormStr, strtotime('2003-12-20 18:00'));
                     break;
                 case HOURSTYLE_HM24:
                 default:
                     $txt = '24:00';
                     break;
             }
             $hfw = $this->scale->hour->GetStrWidth($this->img, $txt) + 6;
             $mw = $hfw;
             if ($this->scale->IsDisplayMinute()) {
                 switch ($this->scale->minute->iStyle) {
                     case HOURSTYLE_CUSTOM:
                         $txt2 = date($this->scale->minute->iLabelFormStr, strtotime('2005-05-15 18:55'));
                         break;
                     case MINUTESTYLE_MM:
                     default:
                         $txt2 = '15';
                         break;
                 }
                 $mfw = $this->scale->minute->GetStrWidth($this->img, $txt2) + 6;
                 $n2 = ceil(60 / $this->scale->minute->GetIntervall());
                 $mw = $n2 * $mfw;
             }
             $hfw = $hfw < $mw ? $mw : $hfw;
             $n = ceil(24 * 60 / $this->scale->TimeToMinutes($this->scale->hour->GetIntervall()));
             $hw = $n * $hfw;
             $fw = $fw < $hw ? $hw : $fw;
         }
         if ($this->scale->IsDisplayMinute()) {
             switch ($this->scale->minute->iStyle) {
                 case HOURSTYLE_CUSTOM:
                     $txt = date($this->scale->minute->iLabelFormStr, strtotime('2005-05-15 18:55'));
                     break;
                 case MINUTESTYLE_MM:
                 default:
                     $txt = '15';
                     break;
             }
             $mfw = $this->scale->minute->GetStrWidth($this->img, $txt) + 6;
             $n = ceil(60 / $this->scale->TimeToMinutes($this->scale->minute->GetIntervall()));
             $mw = $n * $mfw;
             $fw = $fw < $mw ? $mw : $fw;
         }
         if ($this->scale->IsDisplayWeek()) {
             $fsw = strlen($this->scale->week->iLabelFormStr);
             if ($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAY2WNBR) {
                 $fsw += 8;
             } elseif ($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAYWNBR) {
                 $fsw += 7;
             } else {
                 $fsw += 4;
             }
             $ww = $fsw * $this->scale->week->GetFontWidth($this->img);
             if (7 * $fw < $ww) {
                 $fw = ceil($ww / 7);
             }
         }
         if (!$this->scale->IsDisplayDay() && !$this->scale->IsDisplayHour() && !(($this->scale->week->iStyle == WEEKSTYLE_FIRSTDAYWNBR || $this->scale->week->iStyle == WEEKSTYLE_FIRSTDAY2WNBR) && $this->scale->IsDisplayWeek())) {
             $fw /= 2;
             if (!$this->scale->IsDisplayWeek()) {
                 $fw /= 1.8;
             }
         }
         $cw = $this->GetMaxActInfoColWidth();
         $this->scale->actinfo->SetMinColWidth($cw);
         if ($this->img->width <= 0) {
             $titlewidth = max(max($this->GetMaxLabelWidth(), $this->scale->tableTitle->GetWidth($this->img)), $this->scale->actinfo->GetWidth($this->img));
             $titlewidth += $this->scale->divider->iWeight * 2;
             $width = $titlewidth + $nd * $fw + $lm + $rm;
         } else {
             $width = $this->img->width;
         }
         $width = round($width);
         $height = round($height);
         if ($width > MAX_GANTTIMG_SIZE_W || $height > MAX_GANTTIMG_SIZE_H) {
             JpgraphError::RaiseL(6007, $width, $height);
         }
         $this->img->CreateImgCanvas($width, $height);
         $this->img->SetMargin($lm, $rm, $tm, $bm);
     }
 }
Ejemplo n.º 15
0
 function StrokeCSIM($aScriptName = 'auto', $aCSIMName = '', $aBorder = 0)
 {
     if ($aCSIMName == '') {
         srand((double) microtime() * 1000000);
         $r = rand(0, 100000);
         $aCSIMName = '__mapname' . $r . '__';
     }
     if ($aScriptName == 'auto') {
         $aScriptName = basename($_SERVER['PHP_SELF']);
     }
     $urlarg = $this->GetURLArguments();
     if (empty($_GET[_CSIM_DISPLAY])) {
         if ($this->csimcachename != '') {
             $dir = dirname($this->csimcachename);
             $base = basename($this->csimcachename);
             $base = strtok($base, '.');
             $suffix = strtok('.');
             $basecsim = $dir . '/' . $base . '?' . $urlarg . '_csim_.html';
             $baseimg = $base . '?' . $urlarg . '.' . $this->img->img_format;
             if (file_exists($dir) && !is_writeable($dir)) {
                 JpgraphError::RaiseL(25028, $dir);
             }
             $this->cache->MakeDirs($dir);
             $this->Stroke(CSIMCACHE_DIR . $baseimg);
             $tmp = str_replace('?', '%3f', $baseimg);
             $htmlwrap = $this->GetHTMLImageMap($aCSIMName) . "\n" . '<img src="' . CSIMCACHE_HTTP_DIR . $tmp . '" ismap="ismap" usemap="#' . $aCSIMName . '" border="' . $aBorder . '" width="' . $this->img->width . '" height="' . $this->img->height . "\" alt=\"" . $this->iCSIMImgAlt . "\" />\n";
             if ($fh = @fopen($basecsim, 'w')) {
                 fwrite($fh, $htmlwrap);
                 fclose($fh);
                 echo $htmlwrap;
             } else {
                 JpGraphError::RaiseL(25029, $basecsim);
             }
         } else {
             if ($aScriptName == '') {
                 JpGraphError::RaiseL(25030);
             }
             echo $this->GetHTMLImageMap($aCSIMName);
             echo "<img src=\"" . $aScriptName . '?' . $urlarg . "\" ismap=\"ismap\" usemap=\"#" . $aCSIMName . '" border="' . $aBorder . '" width="' . $this->img->width . '" height="' . $this->img->height . "\" alt=\"" . $this->iCSIMImgAlt . "\" />\n";
         }
     } else {
         $this->Stroke();
     }
 }