⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpgraph.php

📁 极限网络智能办公系统 Office Automation V3.0官方100%源代码.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
     // Create the error icon GD 
     $erricon = Image::CreateFromString(base64_decode($img_iconerror)); 

     // Create an image that contains the error text. 
     $w=400;       
     $h=100 + 15*max(0,$lines-3); 

     $img = new Image($w,$h); 

     // Drop shadow 
     $img->SetColor("gray"); 
     $img->FilledRectangle(5,5,$w-1,$h-1,10); 
     $img->SetColor("gray:0.7"); 
     $img->FilledRectangle(5,5,$w-3,$h-3,10); 
      
     // Window background 
     $img->SetColor("lightblue"); 
     $img->FilledRectangle(1,1,$w-5,$h-5); 
     $img->CopyCanvasH($img->img,$erricon,5,30,0,0,40,40); 

     // Window border 
     $img->SetColor("black"); 
     $img->Rectangle(1,1,$w-5,$h-5); 
     $img->Rectangle(0,0,$w-4,$h-4); 
      
     // Window top row 
     $img->SetColor("darkred"); 
     for($y=3; $y < 18; $y += 2 ) 
      $img->Line(1,$y,$w-6,$y); 

     // "White shadow" 
     $img->SetColor("white"); 

     // Left window edge 
     $img->Line(2,2,2,$h-5); 
     $img->Line(2,2,$w-6,2); 

     // "Gray button shadow" 
     $img->SetColor("darkgray"); 

     // Gray window shadow 
     $img->Line(2,$h-6,$w-5,$h-6); 
     $img->Line(3,$h-7,$w-5,$h-7); 

     // Window title 
     $m = floor($w/2-5); 
     $l = 100; 
     $img->SetColor("lightgray:1.3"); 
     $img->FilledRectangle($m-$l,2,$m+$l,16); 

     // Stroke text 
     $img->SetColor("darkred"); 
     $img->SetFont(FF_FONT2,FS_BOLD); 
     $img->StrokeText($m-50,15,$this->iTitle); 
     $img->SetColor("black"); 
     $img->SetFont(FF_FONT1,FS_NORMAL); 
     $txt = new Text($aMsg,52,25); 
     $txt->Align("left","top"); 
     $txt->Stroke($img); 
     if ($this->iDest) { 
$img->Stream($this->iDest); 
     } else { 
      $img->Headers(); 
      $img->Stream(); 
     } 
     if( $aHalt ) 
      die(); 
} 
} 

// 
// Setup PHP error handler 
// 
function _phpErrorHandler($errno,$errmsg,$filename, $linenum, $vars) { 
// Respect current error level 
if( $errno & error_reporting() ) { 
     JpGraphError::Raise('In '.basename($filename).'#'.$linenum."\n".$errmsg); 
} 
} 

if( INSTALL_PHP_ERR_HANDLER ) { 
set_error_handler("_phpErrorHandler"); 
} 

// 
//Check if there were any warnings, perhaps some wrong includes by the 
//user 
// 
if( isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG ) { 
JpGraphError::Raise("General PHP error : ".$GLOBALS['php_errormsg']); 
} 


// Useful mathematical function 
function sign($a) {return $a >= 0 ? 1 : -1;} 

// Utility function to generate an image name based on the filename we 
// are running from and assuming we use auto detection of graphic format 
// (top level), i.e it is safe to call this function 
// from a script that uses JpGraph 
function GenImgName() { 
global $_SERVER; 

// Determine what format we should use when we save the images 
$supported = imagetypes(); 
if( $supported & IMG_PNG )      $img_format="png"; 
elseif( $supported & IMG_GIF ) $img_format="gif"; 
elseif( $supported & IMG_JPG ) $img_format="jpeg"; 

if( !isset($_SERVER['PHP_SELF']) ) 
     JpGraphError::Raise(" Can't access PHP_SELF, PHP global variable. You can't run PHP from command line if you want to use the 'auto' naming of cache or image files."); 
$fname = basename($_SERVER['PHP_SELF']); 
if( !empty($_SERVER['QUERY_STRING']) ) { 
     $q = @$_SERVER['QUERY_STRING']; 
     $fname .= '?'.preg_replace("/\W/", "_", $q).'.'.$img_format; 
} 
else { 
     $fname = substr($fname,0,strlen($fname)-4).'.'.$img_format; 
} 
return $fname; 
} 

class LanguageConv { 
var $g2312 = null ; 

function Convert($aTxt,$aFF) { 
     if( LANGUAGE_CYRILLIC ) { 
      if( CYRILLIC_FROM_WINDOWS ) { 
          $aTxt = convert_cyr_string($aTxt, "w", "k"); 
      } 
      $isostring = convert_cyr_string($aTxt, "k", "i"); 
      $unistring = LanguageConv::iso2uni($isostring); 
      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_CHINESE ) { 
      if( !function_exists('iconv') ) { 
          JpGraphError::Raise('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); 
     } 
     else 
      return $aTxt; 
} 

// Translate iso encoding to unicode 
function iso2uni ($isoline){ 
     $uniline=''; 
     for ($i=0; $i < strlen($isoline); $i++){ 
      $thischar=substr($isoline,$i,1); 
      $charcode=ord($thischar); 
      $uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar; 
     } 
     return $uniline; 
} 
} 

//=================================================== 
// CLASS JpgTimer 
// Description: General timing utility class to handle 
// time measurement of generating graphs. Multiple 
// timers can be started. 
//=================================================== 
class JpgTimer { 
var $start; 
var $idx;      
//--------------- 
// CONSTRUCTOR 
function JpgTimer() { 
     $this->idx=0; 
} 

//--------------- 
// PUBLIC METHODS      

// Push a new timer start on stack 
function Push() { 
     list($ms,$s)=explode(" ",microtime());      
     $this->start[$this->idx++]=floor($ms*1000) + 1000*$s;      
} 

// Pop the latest timer start and return the diff with the 
// current time 
function Pop() { 
     assert($this->idx>0); 
     list($ms,$s)=explode(" ",microtime());      
     $etime=floor($ms*1000) + (1000*$s); 
     $this->idx--; 
     return $etime-$this->start[$this->idx]; 
} 
} // Class 

$gJpgBrandTiming = BRAND_TIMING; 
//=================================================== 
// CLASS DateLocale 
// Description: Hold localized text used in dates 
//=================================================== 
class DateLocale { 

var $iLocale = 'C'; // environmental locale be used by default 

var $iDayAbb = null; 
var $iShortDay = null; 
var $iShortMonth = null; 
var $iMonthName = null; 

//--------------- 
// CONSTRUCTOR      
function DateLocale() { 
     settype($this->iDayAbb, 'array'); 
     settype($this->iShortDay, 'array'); 
     settype($this->iShortMonth, 'array'); 
     settype($this->iMonthName, 'array'); 


     $this->Set('C'); 
} 

//--------------- 
// PUBLIC METHODS      
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 
     $res = @setlocale(LC_TIME, $aLocale); 
     if ( ! $res ){ 
      JpGraphError::Raise("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); 
     } 

     // Return to original locale 
     setlocale(LC_TIME, $pLocale); 

     return TRUE; 
} 


function GetDayAbb() { 
     return $this->iDayAbb[$this->iLocale]; 
} 
      
function GetShortDay() { 
     return $this->iShortDay[$this->iLocale]; 
} 

function GetShortMonth() { 
     return $this->iShortMonth[$this->iLocale]; 
} 
      
function GetShortMonthName($aNbr) { 
     return $this->iShortMonth[$this->iLocale][$aNbr]; 
} 

function GetLongMonthName($aNbr) { 
     return $this->iMonthName[$this->iLocale][$aNbr]; 
} 

function GetMonth() { 
     return $this->iMonthName[$this->iLocale]; 
} 
} 

$gDateLocale = new DateLocale(); 
$gJpgDateLocale = new DateLocale(); 


//=================================================== 
// CLASS FuncGenerator 
// Description: Utility class to help generate data for function plots. 
// The class supports both parametric and regular functions. 
//=================================================== 
class FuncGenerator { 
var $iFunc='',$iXFunc='',$iMin,$iMax,$iStepSize; 
      
function FuncGenerator($aFunc,$aXFunc='') { 
     $this->iFunc = $aFunc; 
     $this->iXFunc = $aXFunc; 
} 
      
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::Raise('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::Raise('FuncGenerator : Syntax error in function specification '); 
                     
     return array($xa,$ya); 
} 
} 

//======================================================= 
// CLASS Footer 
// Description: Encapsulates the footer line in the Graph 
//======================================================= 
class Footer { 
var $left,$center,$right; 
var $iLeftMargin = 3; 
var $iRightMargin = 3; 
var $iBottomMargin = 3; 

function Footer() { 
     $this->left = new Text(); 
     $this->left->ParagraphAlign('left'); 
     $this->center = new Text(); 
     $this->center->ParagraphAlign('center'); 
     $this->right = new Text(); 
     $this->right->ParagraphAlign('right'); 
} 

function Stroke($aImg) { 
     $y = $aImg->height - $this->iBottomMargin; 
     $x = $this->iLeftMargin; 
     $this->left->Align('left','bottom'); 
     $this->left->Stroke($aImg,$x,$y); 

     $x = ($aImg->width - $this->iLeftMargin - $this->iRightMargin)/2; 
     $this->center->Align('center','bottom'); 
     $this->center->Stroke($aImg,$x,$y); 

     $x = $aImg->width - $this->iRightMargin; 
     $this->right->Align('right','bottom'); 
     $this->right->Stroke($aImg,$x,$y); 
} 
} 


//=================================================== 
// CLASS Graph 
// Description: Main class to handle graphs 
//=================================================== 
class Graph { 
var $cache=null;          // Cache object (singleton) 
var $img=null;               // Img object (singleton) 
var $plots=array();     // Array of all plot object in the graph (for Y 1 axis) 
var $y2plots=array();// Array of all plot object in the graph (for Y 2 axis) 
var $ynplots=array(); 
var $xscale=null;          // X Scale object (could be instance of LinearScale or LogScale 
var $yscale=null,$y2scale=null, $ynscale=array(); 
var $iIcons = array(); // Array of Icons to add to 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -