📄 jpgraph.php
字号:
var $titlebackground_color = "lightblue";
var $titlebackground_style = 1;
var $titlebackground_framecolor = "blue";
var $titlebackground_framestyle = 2;
var $titlebackground_frameweight = 1;
var $titlebackground_bevelheight = 3;
var $titlebkg_fillstyle = TITLEBKG_FILLSTYLE_SOLID;
var $titlebkg_scolor1 = "black";
var $titlebkg_scolor2 = "white";
var $framebevel = false;
var $framebeveldepth = 2;
var $framebevelborder = false;
var $framebevelbordercolor = "black";
var $framebevelcolor1 = "white@0.4";
var $framebevelcolor2 = "black@0.4";
var $background_image_mix = 100;
var $background_cflag = "";
var $background_cflag_type = BGIMG_FILLPLOT;
var $background_cflag_mix = 100;
var $iImgTrans = false;
var $iImgTransHorizon = 100;
var $iImgTransSkewDist = 150;
var $iImgTransDirection = 1;
var $iImgTransMinSize = true;
var $iImgTransFillColor = "white";
var $iImgTransHighQ = false;
var $iImgTransBorder = false;
var $iImgTransHorizonPos = 0.5;
var $iYAxisDeltaPos = 50;
var $iIconDepth = DEPTH_BACK;
function graph( $aWidth = 300, $aHeight = 200, $aCachedName = "", $aTimeOut = 0, $aInline = true )
{
global $gJpgBrandTiming;
if ( $gJpgBrandTiming )
{
global $tim;
$tim = new jpgtimer( );
$tim->push( );
}
if ( !is_numeric( $aWidth ) || !is_numeric( $aHeight ) )
{
jpgrapherror::raise( "Image width/height argument in Graph::Graph() must be numeric" );
}
if ( $aCachedName == "auto" )
{
$aCachedName = genimgname( );
}
$this->inline = $aInline;
$this->img = new rotimage( $aWidth, $aHeight );
$this->cache = new imgstreamcache( $this->img );
$this->cache->settimeout( $aTimeOut );
$this->title = new text( );
$this->title->paragraphalign( "center" );
$this->title->setfont( FF_FONT2, FS_BOLD );
$this->title->setmargin( 3 );
$this->title->setalign( "center" );
$this->subtitle = new text( );
$this->subtitle->paragraphalign( "center" );
$this->subtitle->setmargin( 2 );
$this->subtitle->setalign( "center" );
$this->subsubtitle = new text( );
$this->subsubtitle->paragraphalign( "center" );
$this->subsubtitle->setmargin( 2 );
$this->subsubtitle->setalign( "center" );
$this->legend = new legend( );
$this->footer = new footer( );
$aCachedName = str_replace( "?", "_", $aCachedName );
if ( $aCachedName != "" && READ_CACHE && $aInline && $this->cache->getandstream( $aCachedName ) )
{
exit( );
}
$this->cache_name = $aCachedName;
$this->settickdensity( );
$this->tabtitle = new graphtabtitle( );
}
function set3dperspective( $aDir = 1, $aHorizon = 100, $aSkewDist = 120, $aQuality = false, $aFillColor = "#FFFFFF", $aBorder = false, $aMinSize = true, $aHorizonPos = 0.5 )
{
$this->iImgTrans = true;
$this->iImgTransHorizon = $aHorizon;
$this->iImgTransSkewDist = $aSkewDist;
$this->iImgTransDirection = $aDir;
$this->iImgTransMinSize = $aMinSize;
$this->iImgTransFillColor = $aFillColor;
$this->iImgTransHighQ = $aQuality;
$this->iImgTransBorder = $aBorder;
$this->iImgTransHorizonPos = $aHorizonPos;
}
function setgriddepth( $aDepth )
{
$this->grid_depth = $aDepth;
}
function seticondepth( $aDepth )
{
$this->iIconDepth = $aDepth;
}
function setangle( $aAngle )
{
$this->img->setangle( $aAngle );
}
function setalphablending( $aFlg = true )
{
$this->img->setalphablending( $aFlg );
}
function setmargin( $lm, $rm, $tm, $bm )
{
$this->img->setmargin( $lm, $rm, $tm, $bm );
}
function sety2orderback( $aBack = true )
{
$this->y2orderback = $aBack;
}
function set90andmargin( $lm = 0, $rm = 0, $tm = 0, $bm = 0 )
{
$lm = $lm == 0 ? floor( 0.2 * $this->img->width ) : $lm;
$rm = $rm == 0 ? floor( 0.1 * $this->img->width ) : $rm;
$tm = $tm == 0 ? floor( 0.2 * $this->img->height ) : $tm;
$bm = $bm == 0 ? floor( 0.1 * $this->img->height ) : $bm;
$adj = ( $this->img->height - $this->img->width ) / 2;
$this->img->setmargin( $tm - $adj, $bm - $adj, $rm + $adj, $lm + $adj );
$this->img->setcenter( floor( $this->img->width / 2 ), floor( $this->img->height / 2 ) );
$this->setangle( 90 );
if ( empty( $this->yaxis ) || empty( $this->xaxis ) )
{
jpgrapherror::raise( "You must specify what scale to use with a call to Graph::SetScale()" );
}
$this->xaxis->setlabelalign( "right", "center" );
$this->yaxis->setlabelalign( "center", "bottom" );
}
function setclipping( $aFlg = true )
{
$this->iDoClipping = $aFlg;
}
function add( &$aPlot )
{
if ( $aPlot == null )
{
jpgrapherror::raise( "Graph::Add() You tried to add a null plot to the graph." );
}
if ( is_array( $aPlot ) && 0 < count( $aPlot ) )
{
$cl = strtolower( get_class( $aPlot[0] ) );
}
else
{
$cl = strtolower( get_class( $aPlot ) );
}
if ( $cl == "text" )
{
$this->addtext( $aPlot );
}
else if ( $cl == "plotline" )
{
$this->addline( $aPlot );
}
else if ( $cl == "plotband" )
{
$this->addband( $aPlot );
}
else if ( $cl == "iconplot" )
{
$this->addicon( $aPlot );
}
else
{
$this->plots[] =& $aPlot;
}
}
function addicon( &$aIcon )
{
if ( is_array( $aIcon ) )
{
$i = 0;
for ( ; $i < count( $aIcon ); ++$i )
{
$this->iIcons[] =& $aIcon[$i];
}
}
else
{
$this->iIcons[] = $aIcon;
}
}
function addy2( &$aPlot )
{
if ( $aPlot == null )
{
jpgrapherror::raise( "Graph::AddY2() You tried to add a null plot to the graph." );
}
if ( is_array( $aPlot ) && 0 < count( $aPlot ) )
{
$cl = strtolower( get_class( $aPlot[0] ) );
}
else
{
$cl = strtolower( get_class( $aPlot ) );
}
if ( $cl == "text" )
{
$this->addtext( $aPlot, true );
}
else if ( $cl == "plotline" )
{
$this->addline( $aPlot, true );
}
else if ( $cl == "plotband" )
{
$this->addband( $aPlot, true );
}
else
{
$this->y2plots[] =& $aPlot;
}
}
function addy( $aN, &$aPlot )
{
if ( $aPlot == null )
{
jpgrapherror::raise( "Graph::AddYN() You tried to add a null plot to the graph." );
}
if ( is_array( $aPlot ) && 0 < count( $aPlot ) )
{
$cl = strtolower( get_class( $aPlot[0] ) );
}
else
{
$cl = strtolower( get_class( $aPlot ) );
}
if ( $cl == "text" || $cl == "plotline" || $cl == "plotband" )
{
jpgraph::raise( "You can only add standard plots to multiple Y-axis" );
}
else
{
$this->ynplots[$aN][] =& $aPlot;
}
}
function addtext( &$aTxt, $aToY2 = false )
{
if ( $aTxt == null )
{
jpgrapherror::raise( "Graph::AddText() You tried to add a null text to the graph." );
}
if ( $aToY2 )
{
if ( is_array( $aTxt ) )
{
$i = 0;
for ( ; $i < count( $aTxt ); ++$i )
{
$this->y2texts[] =& $aTxt[$i];
}
}
else
{
$this->y2texts[] =& $aTxt;
}
}
else if ( is_array( $aTxt ) )
{
$i = 0;
for ( ; $i < count( $aTxt ); ++$i )
{
$this->texts[] =& $aTxt[$i];
}
}
else
{
$this->texts[] =& $aTxt;
}
}
function addline( &$aLine, $aToY2 = false )
{
if ( $aLine == null )
{
jpgrapherror::raise( "Graph::AddLine() You tried to add a null line to the graph." );
}
if ( $aToY2 )
{
if ( is_array( $aLine ) )
{
$i = 0;
for ( ; $i < count( $aLine ); ++$i )
{
$this->y2lines[] =& $aLine[$i];
}
}
else
{
$this->y2lines[] =& $aLine;
}
}
else if ( is_array( $aLine ) )
{
$i = 0;
for ( ; $i < count( $aLine ); ++$i )
{
$this->lines[] =& $aLine[$i];
}
}
else
{
$this->lines[] =& $aLine;
}
}
function addband( &$aBand, $aToY2 = false )
{
if ( $aBand == null )
{
jpgrapherror::raise( " Graph::AddBand() You tried to add a null band to the graph." );
}
if ( $aToY2 )
{
if ( is_array( $aBand ) )
{
$i = 0;
for ( ; $i < count( $aBand ); ++$i )
{
$this->y2bands[] =& $aBand[$i];
}
}
else
{
$this->y2bands[] =& $aBand;
}
}
else if ( is_array( $aBand ) )
{
$i = 0;
for ( ; $i < count( $aBand ); ++$i )
{
$this->bands[] =& $aBand[$i];
}
}
else
{
$this->bands[] =& $aBand;
}
}
function setbackgroundgradient( $aFrom = "navy", $aTo = "silver", $aGradType = 2, $aStyle = BGRAD_FRAME )
{
$this->bkg_gradtype = $aGradType;
$this->bkg_gradstyle = $aStyle;
$this->bkg_gradfrom = $aFrom;
$this->bkg_gradto = $aTo;
}
function setbackgroundcflag( $aName, $aBgType = BGIMG_FILLPLOT, $aMix = 100 )
{
$this->background_cflag = $aName;
$this->background_cflag_type = $aBgType;
$this->background_cflag_mix = $aMix;
}
function setbackgroundcountryflag( $aName, $aBgType = BGIMG_FILLPLOT, $aMix = 100 )
{
$this->background_cflag = $aName;
$this->background_cflag_type = $aBgType;
$this->background_cflag_mix = $aMix;
}
function setbackgroundimage( $aFileName, $aBgType = BGIMG_FILLPLOT, $aImgFormat = "auto" )
{
if ( $gd2 && !USE_TRUECOLOR )
{
jpgrapherror::raise( "You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x you <b>must</b> enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts." );
}
if ( $aImgFormat == "auto" )
{
$e = explode( ".", $aFileName );
if ( !$e )
{
jpgrapherror::raise( "Incorrect file name for Graph::SetBackgroundImage() : ".$aFileName." Must have a valid image extension (jpg,gif,png) when using autodetection of image type" );
}
$valid_formats = array( "png", "jpg", "gif" );
$aImgFormat = strtolower( $e[count( $e ) - 1] );
if ( $aImgFormat == "jpeg" )
{
$aImgFormat = "jpg";
}
else if ( !in_array( $aImgFormat, $valid_formats ) )
{
jpgrapherror::raise( "Unknown file extension (\$aImgFormat) in Graph::SetBackgroundImage() for filename: ".$aFileName );
}
}
$this->background_image = $aFileName;
$this->background_image_type = $aBgType;
$this->background_image_format = $aImgFormat;
}
function setbackgroundimagemix( $aMix )
{
$this->background_image_mix = $aMix;
}
function adjbackgroundimage( $aBright, $aContr = 0, $aSat = 0 )
{
$this->background_image_bright = $aBright;
$this->background_image_contr = $aContr;
$this->background_image_sat = $aSat;
}
function adjimage( $aBright, $aContr = 0, $aSat = 0 )
{
$this->image_bright = $aBright;
$this->image_contr = $aContr;
$this->image_sat = $aSat;
}
function setaxisstyle( $aStyle )
{
$this->iAxisStyle = $aStyle;
}
function setbox( $aDrawPlotFrame = true, $aPlotFrameColor = array
(
0 => 0,
1 => 0,
2 => 0
), $aPlotFrameWeight = 1 )
{
$this->boxed = $aDrawPlotFrame;
$this->box_weight = $aPlotFrameWeight;
$this->box_color = $aPlotFrameColor;
}
function setcolor( $aColor )
{
$this->plotarea_color = $aColor;
}
function setmargincolor( $aColor )
{
$this->margin_color = $aColor;
}
function setframe( $aDrawImgFrame = true, $aImgFrameColor = array
(
0 => 0,
1 => 0,
2 => 0
), $aImgFrameWeight = 1 )
{
$this->doframe = $aDrawImgFrame;
$this->frame_color = $aImgFrameColor;
$this->frame_weight = $aImgFrameWeight;
}
function setframebevel( $aDepth = 3, $aBorder = false, $aBorderColor = "black", $aColor1 = "white@0.4", $aColor2 = "darkgray@0.4", $aFlg = true )
{
$this->framebevel = $aFlg;
$this->framebeveldepth = $aDepth;
$this->framebevelborder = $aBorder;
$this->framebevelbordercolor = $aBorderColor;
$this->framebevelcolor1 = $aColor1;
$this->framebevelcolor2 = $aColor2;
$this->doshadow = false;
}
function setshadow( $aShowShadow = true, $aShadowWidth = 5, $aShadowColor = array
(
0 => 102,
1 => 102,
2 => 102
) )
{
$this->doshadow = $aShowShadow;
$this->shadow_color = $aShadowColor;
$this->shadow_width = $aShadowWidth;
$this->footer->iBottomMargin += $aShadowWidth;
$this->footer->iRightMargin += $aShadowWidth;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -