?? jpgraph.php
字號:
<?php
class jpgrapherror
{
function install( $aErrObject )
{
global $__jpg_err;
$__jpg_err = $aErrObject;
}
function raise( $aMsg, $aHalt = true )
{
global $__jpg_err;
$tmp = new $__jpg_err( );
$tmp->raise( $aMsg, $aHalt );
}
}
class jpgrapherrobject
{
var $iTitle = "JpGraph Error";
var $iDest = false;
function jpgrapherrobject( )
{
}
function settitle( $aTitle )
{
$this->iTitle = $aTitle;
}
function setstrokedest( $aDest )
{
$this->iDest = $aDest;
}
function raise( $aMsg, $aHalt = true )
{
$aMsg = $this->iTitle." ".$aMsg;
if ( $this->iDest )
{
$f = @fopen( $this->iDest, "a" );
if ( $f )
{
@fwrite( $f, $aMsg );
@fclose( $f );
}
}
if ( $aHalt )
{
exit( );
}
}
}
class jpgrapherrobjectimg extends jpgrapherrobject
{
var $iTitle = "JpGraph Error";
var $iDest = false;
function raise( $aMsg, $aHalt = true )
{
$img_iconerror = "iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaVBMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpYiYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjeaAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR42tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db06Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtSIXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjkYcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfcvd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMxqL72fwAAAABJRU5ErkJggg==";
if ( function_exists( "imagetypes" ) )
{
$supported = imagetypes( );
}
else
{
$supported = 0;
}
if ( !function_exists( "imagecreatefromstring" ) )
{
$supported = 0;
}
if ( ob_get_length( ) || headers_sent( ) || !( $supported & IMG_PNG ) )
{
exit( $this->iTitle." ".$aMsg );
}
$aMsg = wordwrap( $aMsg, 55 );
$lines = substr_count( $aMsg, "\n" );
$erricon = image::createfromstring( base64_decode( $img_iconerror ) );
$w = 400;
$h = 100 + 15 * max( 0, $lines - 3 );
$img = new image( $w, $h );
$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 );
$img->setcolor( "lightblue" );
$img->filledrectangle( 1, 1, $w - 5, $h - 5 );
$img->copycanvash( $img->img, $erricon, 5, 30, 0, 0, 40, 40 );
$img->setcolor( "black" );
$img->rectangle( 1, 1, $w - 5, $h - 5 );
$img->rectangle( 0, 0, $w - 4, $h - 4 );
$img->setcolor( "darkred" );
$y = 3;
for ( ; $y < 18; $y += 2 )
{
$img->line( 1, $y, $w - 6, $y );
}
$img->setcolor( "white" );
$img->line( 2, 2, 2, $h - 5 );
$img->line( 2, 2, $w - 6, 2 );
$img->setcolor( "darkgray" );
$img->line( 2, $h - 6, $w - 5, $h - 6 );
$img->line( 3, $h - 7, $w - 5, $h - 7 );
$m = floor( $w / 2 - 5 );
$l = 100;
$img->setcolor( "lightgray:1.3" );
$img->filledrectangle( $m - $l, 2, $m + $l, 16 );
$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 )
{
exit( );
}
}
}
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;
}
else if ( $aFF === FF_SIMSUN )
{
if ( $this->g2312 == null )
{
include_once( "jpgraph_gb2312.php" );
$this->g2312 = new gb2312toutf8( );
}
return $this->g2312->gb2utf8( $aTxt );
}
else if ( $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;
}
}
function iso2uni( $isoline )
{
$uniline = "";
$i = 0;
for ( ; $i < strlen( $isoline ); ++$i )
{
$thischar = substr( $isoline, $i, 1 );
$charcode = ord( $thischar );
$uniline .= 175 < $charcode ? "&#".( 1040 + ( $charcode - 176 ) ).";" : $thischar;
}
return $uniline;
}
}
class jpgtimer
{
var $start;
var $idx;
function jpgtimer( )
{
$this->idx = 0;
}
function push( )
{
list( $ms, $s ) = explode( " ", microtime( ) );
$this->start[$this->idx++] = floor( $ms * 1000 ) + 1000 * $s;
}
function pop( )
{
assert( 0 < $this->idx );
list( $ms, $s ) = explode( " ", microtime( ) );
$etime = floor( $ms * 1000 ) + 1000 * $s;
--$this->idx;
return $etime - $this->start[$this->idx];
}
}
class datelocale
{
var $iLocale = "C";
var $iDayAbb = null;
var $iShortDay = null;
var $iShortMonth = null;
var $iMonthName = null;
function datelocale( )
{
settype( $this->iDayAbb, "array" );
settype( $this->iShortDay, "array" );
settype( $this->iShortMonth, "array" );
settype( $this->iMonthName, "array" );
$this->set( "C" );
}
function set( $aLocale )
{
if ( in_array( $aLocale, array_keys( $this->iDayAbb ) ) )
{
$this->iLocale = $aLocale;
return TRUE;
}
$pLocale = setlocale( LC_TIME, 0 );
$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;
$i = 0;
$ofs = 0 - strftime( "%w" );
for ( ; $i < 7; ++$i, ++$ofs )
{
$day = strftime( "%a", strtotime( "{$ofs} day" ) );
$day[0] = strtoupper( $day[0] );
$this->iDayAbb[$aLocale][] = $day[0];
$this->iShortDay[$aLocale][] = $day;
}
$i = 1;
for ( ; $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;
}
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];
}
}
class funcgenerator
{
var $iFunc = "";
var $iXFunc = "";
var $iMin;
var $iMax;
var $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.";}";
}
else if ( $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 ( empty( $xa ) || empty( $ya ) )
{
jpgrapherror::raise( "FuncGenerator : Syntax error in function specification " );
}
return array(
$xa,
$ya
);
}
}
class footer
{
var $left;
var $center;
var $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
{
var $cache = null;
var $img = null;
var $plots = array( );
var $y2plots = array( );
var $ynplots = array( );
var $xscale = null;
var $yscale = null;
var $y2scale = null;
var $ynscale = array( );
var $iIcons = array( );
var $cache_name;
var $xgrid = null;
var $ygrid = null;
var $y2grid = null;
var $yngrid = array( );
var $doframe = true;
var $frame_color = array
(
0 => 0,
1 => 0,
2 => 0
);
var $frame_weight = 1;
var $boxed = false;
var $box_color = array
(
0 => 0,
1 => 0,
2 => 0
);
var $box_weight = 1;
var $doshadow = false;
var $shadow_width = 4;
var $shadow_color = array
(
0 => 102,
1 => 102,
2 => 102
);
var $xaxis = null;
var $yaxis = null;
var $y2axis = null;
var $ynaxis = array( );
var $margin_color = array
(
0 => 200,
1 => 200,
2 => 200
);
var $plotarea_color = array
(
0 => 255,
1 => 255,
2 => 255
);
var $title;
var $subtitle;
var $subsubtitle;
var $axtype = "linlin";
var $xtick_factor;
var $texts = null;
var $y2texts = null;
var $lines = null;
var $y2lines = null;
var $bands = null;
var $y2bands = null;
var $text_scale_off = 0;
var $text_scale_abscenteroff = -1;
var $background_image = "";
var $background_image_type = -1;
var $background_image_format = "png";
var $background_image_bright = 0;
var $background_image_contr = 0;
var $background_image_sat = 0;
var $image_bright = 0;
var $image_contr = 0;
var $image_sat = 0;
var $inline;
var $showcsim = 0;
var $csimcolor = "red";
var $grid_depth = DEPTH_BACK;
var $iAxisStyle = AXSTYLE_SIMPLE;
var $iCSIMdisplay = false;
var $iHasStroked = false;
var $footer;
var $csimcachename = "";
var $csimcachetimeout = 0;
var $iDoClipping = false;
var $y2orderback = true;
var $tabtitle;
var $bkg_gradtype = -1;
var $bkg_gradstyle = BGRAD_MARGIN;
var $bkg_gradfrom = "navy";
var $bkg_gradto = "silver";
var $titlebackground = false;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -