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

📄 jpgraph.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php //=======================================================================// File:	JPGRAPH.PHP// Description:	PHP4 Graph Plotting library. Base module.// Created: 	2001-01-08// Author:	Johan Persson// Ver:		$Id: jpgraph.php,v 1.25 2004/02/11 20:32:13 deskpro Exp $//// License:	This code is released under QPL 1.0 // Copyright (C) 2001 - 2004 Johan Persson //========================================================================//------------------------------------------------------------------------// Directories for cache and font directory.// Leave them undefined to use default values. // // Default values used if these defines are left commented out are:// // UNIX: //   CACHE_DIR = /tmp/jpgraph_cache///   TTF_DIR   = /usr/X11R6/lib/X11/fonts/truetype///// WINDOWS://   CACHE_DIR = $SERVER_TEMP/jpgraph_cache///   TTF_DIR   = $SERVER_SYSTEMROOT/fonts///    ////------------------------------------------------------------------------// The full absolute name of the directory to be used to store the// cached image files. This directory will not be used if the USE_CACHE// define (further down) is false. If you enable the cache please note that// this directory MUST be readable and writable for the process running PHP. // Must end with '/'$tmpdir = INCLUDE_PATH . '../admin/graphs';DEFINE("CACHE_DIR",$tmpdir);// Directory for jpGraph TTF fonts. Must end with '/'// DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/");//-------------------------------------------------------------------------// Cache directory specification for use with CSIM graphs that are// using the cache.// The directory must be the filesysystem name as seen by PHP// and the 'http' version must be the same directory but as // seen by the HTTP server relative to the 'htdocs' ddirectory. // If a relative path is specified it is taken to be relative from where// the image script is executed.// Note: The default setting is to create a subdirectory in the // directory from where the image script is executed and store all files// there. As ususal this directory must be writeable by the PHP process.DEFINE("CSIMCACHE_DIR","csimcache/"); DEFINE("CSIMCACHE_HTTP_DIR","csimcache/");//------------------------------------------------------------------------// Various JpGraph Settings. Adjust accordingly to your// preferences. Note that cache functionality is turned off by// default (Enable by setting USE_CACHE to true)//------------------------------------------------------------------------// Deafult graphic format set to "auto" which will automatically// choose the best available format in the order png,gif,jpg// (The supported format depends on what your PHP installation supports)DEFINE("DEFAULT_GFORMAT","auto");// Should the image be a truecolor image? // Note 1: Has only effect with GD 2.0.1 and above.// Note 2: GD 2.0.1 + PHP 4.0.6 on Win32 crashes when trying to use // trucolor. Truecolor support is to be considered alpha since GD 2.x// is still not considered stable (especially on Win32). // Note 3: MUST be enabled to get background images working with GD2// Note 4: If enabled then truetype fonts will look very ugly with GD 2.0.1// => You can't have both background images and truetype fonts in the same// image until these bugs has been fixed in GD 2.01. There is a patch// available for GD 2.0.1 though. See the README file.DEFINE('USE_TRUECOLOR',true);// Specify what version of the GD library is installed.// If this is set to 'auto' the version will be automatically // determined.// However since determining the library takes ~1ms you can also // manually specify the version if you know what version you have. // This means that you should // set this define to true if you have GD 2.x installed to save 1ms. DEFINE("USE_LIBRARY_GD2",'auto');// Should the cache be used at all? By setting this to false no// files will be generated in the cache directory.  // The difference from READ_CACHE being that setting READ_CACHE to// false will still create the image in the cache directory// just not use it. By setting USE_CACHE=false no files will even// be generated in the cache directory.DEFINE("USE_CACHE",false);// Should we try to find an image in the cache before generating it? // Set this define to false to bypass the reading of the cache and always// regenerate the image. Note that even if reading the cache is // disabled the cached will still be updated with the newly generated// image. Set also "USE_CACHE" below.DEFINE("READ_CACHE",true);// Determine if the error handler should be image based or purely// text based. Image based makes it easier since the script will// always return an image even in case of errors.if (!defined('NO_GRAPHIC_HANDLER')) {	DEFINE("USE_IMAGE_ERROR_HANDLER",true);} else {	DEFINE("USE_IMAGE_ERROR_HANDLER",false);}// If the color palette is full should JpGraph try to allocate// the closest match? If you plan on using background images or// gradient fills it might be a good idea to enable this.// If not you will otherwise get an error saying that the color palette is // exhausted. The drawback of using approximations is that the colors // might not be exactly what you specified. // Note1: This does only apply to paletted images, not truecolor // images since they don't have the limitations of maximum number// of colors.DEFINE("USE_APPROX_COLORS",true);// Special unicode cyrillic language supportDEFINE("LANGUAGE_CYRILLIC",false);// If you are setting this config to true the conversion// will assume that the input text is windows 1251, if// false it will assume koi8-rDEFINE("CYRILLIC_FROM_WINDOWS",false);// Should usage of deprecated functions and parameters give a fatal error?// (Useful to check if code is future proof.)DEFINE("ERR_DEPRECATED",true);// Should the time taken to generate each picture be branded to the lower// left in corner in each generated image? Useful for performace measurements// generating graphsDEFINE("BRAND_TIMING",false);// What format should be used for the timing string?DEFINE("BRAND_TIME_FORMAT","(%01.3fs)");//------------------------------------------------------------------------// The following constants should rarely have to be changed !//------------------------------------------------------------------------// What group should the cached file belong to// (Set to "" will give the default group for the "PHP-user")// Please note that the Apache user must be a member of the// specified group since otherwise it is impossible for Apache// to set the specified group.DEFINE("CACHE_FILE_GROUP","wwwadmin");// What permissions should the cached file have// (Set to "" will give the default persmissions for the "PHP-user")DEFINE("CACHE_FILE_MOD",0664);// Decide if we should use the bresenham circle algorithm or the// built in Arc(). Bresenham gives better visual apperance of circles // but is more CPU intensive and slower then the built in Arc() function// in GD. Turned off by default for speedDEFINE("USE_BRESENHAM",false);// Special file name to indicate that we only want to calc// the image map in the call to Graph::Stroke() used// internally from the GetHTMLCSIM() method.DEFINE("_CSIM_SPECIALFILE","_csim_special_");// HTTP GET argument that is used with image map// to indicate to the script to just generate the image// and not the full CSIM HTML page.DEFINE("_CSIM_DISPLAY","_jpg_csimd");// Special filename for Graph::Stroke(). If this filename is given// then the image will NOT be streamed to browser of file. Instead the// Stroke call will return the handler for the created GD image.DEFINE("_IMG_HANDLER","__handle");// DON'T SET THIS FLAG YORSELF THIS IS ONLY FOR INTERNAL TESTING// PURPOSES. ENABLING THIS FLAG WILL MAKE SOME OF YOUR SCRIPT // STOP WORKING// Enable some extra debug information for CSIM etc to be shown. DEFINE("JPG_DEBUG",false);// Version infoDEFINE('JPG_VERSION','1.12');//------------------------------------------------------------------------// Automatic settings of path for cache and font directory// if they have not been previously specified//------------------------------------------------------------------------if (!defined('CACHE_DIR')) {    if ( strstr( PHP_OS, 'WIN') ) {        if( empty($_SERVER['TEMP']) ) {	    die('JpGraph Error: No path specified for CACHE_DIR. Please specify a path for that DEFINE in jpgraph.php');        }	else {	   DEFINE('CACHE_DIR', $_SERVER['TEMP'] . '/');        }    } else {	DEFINE('CACHE_DIR','/tmp/jpgraph_cache/');    }}if (!defined('TTF_DIR')) {    if (strstr( PHP_OS, 'WIN') ) {        if( empty($_SERVER['SystemRoot']) ) {	    die('JpGraph Error: No path specified for TTF_DIR. Please specify a path for that DEFINE in jpgraph.php');        }	else {	  DEFINE('TTF_DIR', $_SERVER['SystemRoot'] . '/fonts/');        }    } else {	DEFINE('TTF_DIR','/usr/X11R6/lib/X11/fonts/truetype/');    }}//------------------------------------------------------------------// Constants which are used as parameters for the method calls//------------------------------------------------------------------// TTF Font familiesDEFINE("FF_COURIER",10);DEFINE("FF_VERDANA",11);DEFINE("FF_TIMES",12);DEFINE("FF_COMIC",14);DEFINE("FF_ARIAL",15);DEFINE("FF_GEORGIA",16);DEFINE("FF_TREBUCHE",17);// Chinese fontDEFINE("FF_SIMSUN",18);// Gnome Vera fontDEFINE("FF_VERA",19);DEFINE("FF_VERAMONO",20);DEFINE("FF_VERASERIF",21);// Older deprecated fonts DEFINE("FF_BOOK",91);    // Deprecated fonts from 1.9DEFINE("FF_HANDWRT",92); // Deprecated fonts from 1.9// TTF Font stylesDEFINE("FS_NORMAL",9001);DEFINE("FS_BOLD",9002);DEFINE("FS_ITALIC",9003);DEFINE("FS_BOLDIT",9004);DEFINE("FS_BOLDITALIC",9004);//Definitions for internal font, new styleDEFINE("FF_FONT0",1);DEFINE("FF_FONT1",2);DEFINE("FF_FONT2",4);//Definitions for internal font, old style// (Only defined here to be able to generate an error mesage// when used)DEFINE("FONT0",99);		// Deprecated from 1.2DEFINE("FONT1",98);		// Deprecated from 1.2DEFINE("FONT1_BOLD",97);	// Deprecated from 1.2DEFINE("FONT2",96);		// Deprecated from 1.2DEFINE("FONT2_BOLD",95); 	// Deprecated from 1.2// Tick densityDEFINE("TICKD_DENSE",1);DEFINE("TICKD_NORMAL",2);DEFINE("TICKD_SPARSE",3);DEFINE("TICKD_VERYSPARSE",4);// Side for ticks and labels. DEFINE("SIDE_LEFT",-1);DEFINE("SIDE_RIGHT",1);DEFINE("SIDE_DOWN",-1);DEFINE("SIDE_BOTTOM",-1);DEFINE("SIDE_UP",1);DEFINE("SIDE_TOP",1);// Legend type stacked vertical or horizontalDEFINE("LEGEND_VERT",0);DEFINE("LEGEND_HOR",1);// Mark types for plot marksDEFINE("MARK_SQUARE",1);DEFINE("MARK_UTRIANGLE",2);DEFINE("MARK_DTRIANGLE",3);DEFINE("MARK_DIAMOND",4);DEFINE("MARK_CIRCLE",5);DEFINE("MARK_FILLEDCIRCLE",6);DEFINE("MARK_CROSS",7);DEFINE("MARK_STAR",8);DEFINE("MARK_X",9);DEFINE("MARK_LEFTTRIANGLE",10);DEFINE("MARK_RIGHTTRIANGLE",11);DEFINE("MARK_FLASH",12);DEFINE("MARK_IMG",13);// Builtin imagesDEFINE("MARK_IMG_PUSHPIN",50);DEFINE("MARK_IMG_SPUSHPIN",50);DEFINE("MARK_IMG_LPUSHPIN",51);DEFINE("MARK_IMG_DIAMOND",52);DEFINE("MARK_IMG_SQUARE",53);DEFINE("MARK_IMG_STAR",54);DEFINE("MARK_IMG_BALL",55);DEFINE("MARK_IMG_SBALL",55);DEFINE("MARK_IMG_MBALL",56);DEFINE("MARK_IMG_LBALL",57);DEFINE("MARK_IMG_BEVEL",58);// Styles for gradient color fillDEFINE("GRAD_VER",1);DEFINE("GRAD_VERT",1);DEFINE("GRAD_HOR",2);DEFINE("GRAD_MIDHOR",3);DEFINE("GRAD_MIDVER",4);DEFINE("GRAD_CENTER",5);DEFINE("GRAD_WIDE_MIDVER",6);DEFINE("GRAD_WIDE_MIDHOR",7);DEFINE("GRAD_LEFT_REFLECTION",8);DEFINE("GRAD_RIGHT_REFLECTION",9);// Inline definesDEFINE("INLINE_YES",1);DEFINE("INLINE_NO",0);// Format for background imagesDEFINE("BGIMG_FILLPLOT",1);DEFINE("BGIMG_FILLFRAME",2);DEFINE("BGIMG_COPY",3);DEFINE("BGIMG_CENTER",4);// Depth of objectsDEFINE("DEPTH_BACK",0);DEFINE("DEPTH_FRONT",1);// DirectionDEFINE("VERTICAL",1);DEFINE("HORIZONTAL",0);// Constants for types of static bands in plot areaDEFINE("BAND_RDIAG",1);	// Right diagonal linesDEFINE("BAND_LDIAG",2); // Left diagonal linesDEFINE("BAND_SOLID",3); // Solid one colorDEFINE("BAND_VLINE",4); // Vertical linesDEFINE("BAND_HLINE",5);  // Horizontal linesDEFINE("BAND_3DPLANE",6);  // "3D" PlaneDEFINE("BAND_HVCROSS",7);  // Vertical/Hor crossesDEFINE("BAND_DIAGCROSS",8); // Diagonal crosses// Axis styles for scientific style axisDEFINE('AXSTYLE_SIMPLE',1);DEFINE('AXSTYLE_BOXIN',2);DEFINE('AXSTYLE_BOXOUT',3);DEFINE('AXSTYLE_YBOXIN',4);DEFINE('AXSTYLE_YBOXOUT',5);// Style for title backgroundsDEFINE('TITLEBKG_STYLE1',1);DEFINE('TITLEBKG_STYLE2',2);DEFINE('TITLEBKG_STYLE3',3);DEFINE('TITLEBKG_FRAME_NONE',0);DEFINE('TITLEBKG_FRAME_FULL',1);DEFINE('TITLEBKG_FRAME_BOTTOM',2);DEFINE('TITLEBKG_FRAME_BEVEL',3);DEFINE('TITLEBKG_FILLSTYLE_HSTRIPED',1);DEFINE('TITLEBKG_FILLSTYLE_VSTRIPED',2);DEFINE('TITLEBKG_FILLSTYLE_SOLID',3);// Width of tab titlesDEFINE('TABTITLE_WIDTHFIT',0);DEFINE('TABTITLE_WIDTHFULL',-1);//// Get hold of gradient class (In Version 2.x)// A client of the library has to manually include this//include INCLUDE_PATH . "graph/jpgraph_gradient.php";//// First of all set up a default error handler////=============================================================// The default trivial text error handler.//=============================================================class JpGraphErrObject {    function JpGraphErrObject() {	// Empty. Reserved for future use    }    // If aHalt is true then execution can't continue. Typical used for    // fatal errors    function Raise($aMsg,$aHalt=true) {	$aMsg = "<b>JpGraph Error:</b> ".$aMsg;	if( $aHalt )	    die($aMsg);	else 	    echo $aMsg."<p>";    }}//==============================================================// An image based error handler//==============================================================class JpGraphErrObjectImg {

⌨️ 快捷键说明

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