Software: Apache/2.2.3 (CentOS). PHP/5.1.6 uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /var/www/html/manage_22222/jpgraph/docs/ref/ drwxr-xr-x |
Viewing file: Select action/file-type: CLASS Graph
(Defined in: jpgraph.php : 744)Class usage and Overview The Graph class is the main container class for all x,y-axis based plots which controls the creation of the entire graph. You must always instantiate one instance to create a graph. Through this class one controls many overall settings of the image displayed.
Please note that to create Pie, Gantt, Canvas and Spider charts you have to use their respective creation classes. Public properties:
See also related classes: Axis, Grid, Text and Image
Class Methods
Description Each plot that should be displayed within the graph has to be added to the graph. This is the main method to add object. You can use this method to add
Note that since the plot is added as a reference any changes you make to the original plot will also happen to the plot you have added to the graph.
Add() will always add plots to the first Y-scale. If you are using two Y-axis then you must use AddY2() to add plots to the second Y-scale.
See also Graph::AddY2 and Graph::SetScale
Example $graph->img->SetMargin(40,30,20,40); $graph->SetScale("textlin"); $graph->SetShadow(); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor("orange"); $graph->Add($bplot); // Display the graph $graph->Stroke();
Description A plot may have one or several filled horizontal or vertical "bands" to emphasise certain scale areas.
Each band is an instance of the PlotBand class. For types of plot band see the documentation of class PlotBand
Note: You can alos use the standard method Add() to add bands. See also PlotBand::PlotBand and Graph::Add
Example
Description Add a vertical or horizontal line to the graph. The line will extend over the entire length of the plot. The plot object is an instance of the PlotLine class
Note: You can alos use the standard method Add() to add lines. See also PlotLine::PlotLine and Graph::Add
Example $graph->AddLine(new PlotLine(HORIZONTAL,0,"black",2)); $graph->AddLine(new PlotLine(VERTICAL,3,"black",2));
Description Adds an instance of the Text class to the graph, allowing arbitrary text to be placed anywhere in the graph.
Note: You can alos use the standard method Add() to add bands.
See also Text::Text and Graph::Add
Example // image width and height $caption=new Text(“Figure 1. Temperature over time”,0.1,0.8); $caption->SetFont(FONT1_BOLD); $graph->AddText($caption);
Description No description available.
Description Works the same way as Add() but the plot is added for use with the Y2 scale (the right Y scale) instead. See also Graph::Add and Graph::SetY2Scale
Example $graph->SetScale(“linlin”); $graph->SetY2Scale(“linlog”); $lineplot = New LinePlot($datay); $graph->AddY2($lineplot);
Description When using background images it is often desirable to make it a "shadow" image so it doesn't disturb the main messagfe of the plot. This can often be accomplished by, for example, increasing the brightness level of the image.
With method you can adjust both the brighness, contrast as well as color saturation in the loaded background image before it is displayed on the graph. This makes it unnecessary to first adjust the image in an image processing program.
All values are gives as fraction between 0 and 1 where lower values indicates a "lower" value. The special value 0 leaves the parameter as is.
See also Graph::LoadBkgImage
Example
Description With this method you can adjust both the brightness, contrast as well as color saturation in the image before it is sent to the browser or filedisplayed on the graph.
All values are gives as fraction between 0 and 1 where lower values indicates a "lower" value. The special value 0 leaves the parameter as is.
See also Graph::AdjBackgroundImage
Example
Description This method is used to enable caching for graphs that use image maps (CSIM). It should be called as the first method after the creation of the Graph(). If the cached image and image map exists this will be directly sent back to the browser and script execution will stop.
This specifically means that no lines of code after this method will be executed in case the image/map is found in the cache.
See also Graph::StrokeCSIM
Example $graph->CheckCSIMCache('myimage01',10); // .. Lopt of code to create the image $graph->StrokeCSIM();
Description When you are using image maps for a plot then this routine is called in your script to get the resulting image map as a string for the graph. The image map is given the name specified as the first argument to the method.
Please note that due to the way client side image maps work you need to have both the image map and the image available in the script that is sent back to the browser. Since you can't do this at the same time you will have to create an image to disk and read the image map. The you have to stream the HTML page with an Example $graph->Stroke($myfile); // Then read the image map $imagemap = $graph->GetHTMLImageMap('MainMap'); echo $imagemap; echo "<img src=$myfile>";
Description Creates a new graph. This is often the first call made to set-up a new graph.
If the cache name is specified (via the $aCachedname) argument then this method will first try to locate the named file in the cache directory (as specified by the DEFINE in jpgraph.php) rather then generating the graph on the fly. If the file is not there or if it is older then the specified timeout value ($aTimeOut) the graph will be generated and saved as the specified file. If the cache name is specifed as 'auto' then the cache name will be based on the basename of the script with an extension indicating the image format used, i.e. JPG, GIF or PNG. If the specified file is found in the cache directory then it will be streamed back to the browser directly. If no cache name is specified then the graph will always be generated and the cache bypassed. The same is true if the DEFINE 'USE_CACHE' or 'READ_CACHE' is set to false.
Before any other operation is performed on the graph a call to SetScale() should be made to finish the initialisation of the graph.
See also Graph::Stroke
Example $graph = new Graph(400,200,"auto"); $graph->img->SetMargin(60,20,30,50); $graph->SetScale("textlin"); $graph->SetMarginColor("silver"); $graph->SetShadow(); // Example 2 . Don't use the cache $graph = new Graph(400,200); $graph->SetScale("textint");
Description Enable final image perspective transformation before sending the image back to the browser. This makes a "skewing" tansformation of the image to emulate a 3D depth.
Allowed argument for $aDir are
aSkewDist How far to the right on the horizon is the "skewing point", a large value gives a very strong for-shortening. aQuality Use high quality (takes longer time) TRUE or FALSE aFIllColor Fill background color in the image on places where the original image no longer cover the entire canvas. aBorder Border around or not aMinSize Just make the image as large as it has to be. TRUE or FALSE. If this argument is set to false then the original image size will be preserved.
aHorizonPosHow far, in fraction, should the point of focus be from the left edge of the image. Example
Description Rotates the graph 90 degrees and sets the margin as specified.
Remember that when rotating the graph it might be a good idea to adjust the axis so that the alignment of the labels for x and Y axis. For example by setting them as:
$graph->xaxis->SetLabelAlign('right','center','right');
Note: This is slightly different from using SetAngle() and SetMargin() in that this method automatically adjusts the margin so that width becomes height and vice versa due to the rotation.
See also Graph::SetAngle and Graph::SetMargin
Example $graph->SetScale("linlin"); $graph->Set90AndMargin(40,40,40,40); $graph->SetShadow(); $graph->title->Set("A 90 degrees rotated scatter plot"); $graph->title->SetFont(FF_FONT1,FS_BOLD); // Adjust the label align for X-axis so they look good rotated $graph->xaxis->SetLabelAlign('right','center','right'); // Adjust the label align for Y-axis so they look good rotated $graph->yaxis->SetLabelAlign('center','bottom'); $sp1 = new ScatterPlot($datay,$datax); $sp1->mark->SetType(MARK_FILLEDCIRCLE); $sp1->mark->SetFillColor("red"); $sp1->mark->SetWidth(5); $graph->Add($sp1); $graph->Stroke();
Description Enable disable alpha blending. The transparency factor is specified in the color as transparency fraction. For example, to specify a red color which is 50% transparent you specify this as:
"red@0.5" (or "#FF0000@0.5") can then use this color specification in all places where the color may be specified. If the alpha blending is not active then the alpha parameter will have no effect.
Note that the use of alpha blending requires GD 2.01 or higher. By default alpha blending is enabled.
Example
Description The graph can be rotated an arbitrary number of degrees. This will allow you to easily create, for example, horizontal bar graphs by rotating a normal bar graph 90 degrees.
See horizbarex1.php for a real life example.
Note: If you want a 90 degrees rotated graph consider using Graph::Set90AndMargin() which greatly simplifies this with just one call
See also Graph::Set90AndMargin
Example $graph->SetScale('textlin'); $graph->SetAngle(90);
Description The most common type of axis is two axis which crosses at a specified point. However for scientific plot it is often common to want to mirror the axis (and the scale) around the plot area.
This method controls which type to use
Example
Description [Synonym for SetBackgroundCountryFlag() )
Set a country flag in the background. All supported countries can be specified by either
The final arcgument "aMix" is a value between 0-100 and specifies the blend factor for the flag.
Description Set a country flag in the background. All supported countries can be specified by either
The final arcgument "aMix" is a value between 0-100 and specifies the blend factor for the flag.
Description This method allows you to specify a color gradient as the background of the graph. The color gradient can either fill the entire graph, just the plopt area or just the margin. This is specified by the $aStyle argument by specifyin one of the following values:
See also Graph::SetBackgroundImage and Graph::SetFrame
Example
Description A graph may have a background image. The image is loaded from a specified file and may be of type GIF, JPG or PNG. The image type may also be specified as "auto", in this case the image format is determined by the file ending.
The positioning and sizing of the background image can be controlled by the $aBgType parameter. Possible values are
See also Graph::SetBackgroundGradient
Example $graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME); // If you use a canvas graph, and only canvas graphs, // you must manually call the InitFrame() method. $graph->InitFrame();
Description Specifes what how much the background image should be blendid in with the background.
Description This is used to specify whether the plot-area should have a rectangle around it and the specifics of that rectangle. See also Graph::SetFrame
Example $graph->SetScale(“linlin”); $graph->Box();
Description Enable or disable clipping outside the plot area. If clipping is enabled then only the part of the graph exactly inside the plot area will be visible.
Clipping may come in handy when you for example set a manual scale and have data points outside the specified range. By default clipping is disabled. Note 1: Clipping is only supported for graphs at 0 or 90 degrees rotation and will generate an error message if enabled together with any other angle.
Note 2: The clipping is implemented with a O(1) algorithm in terns of data size.
Example
Description Specify color for the plotarea (not the margins) See also Graph::SetFrame and Graph::SetMarginColor
Example
Description Sets a frame (rectangle) of the chosen color around the edges of the image.
Note: For implementation reasons the frame must be enabled in order to for a specified gradient background to show up.
See also Graph::SetMarginColor
Example
Description Specify a a bevel frame around the entire graph. A Bevel frame will give the entire graph a "3D" uprised feel. Example
Description Specify if the grid in the plot should be drawn under or on top of the actual plots.
Valid values for grid depth are
The default is to draw the grid lines under the plots. Example
Description No description available.
Description Specify the margin around the actual plot area. This is actually just a shortcut for the Image::SetMargin()
Note: If you want to set the margin for a 90 degrees rotated graph please consider using Graph::Set90AndMargin() instead since this will automatically adjust for the rotated image and the swapped meaning of width and height.
See also Image::SetMargin
Example
Description Specifies the color of the area between the plot area and the edge of the image. See also Graph::SetColor and Graph::SetFrame
Example
Description Specifies what kind of scales should be used in the graph. The following combinations are allowed
To specify which combination of X and Y scales you want to use the $axtype parameter is specified. In this parameter you specify, by a text string, the type of scale you want to use for both X and Y scale.
Possible values for each axis are:
Example of possible combination:
Note: If you want to use a logarithmic scale you must make sure that the “jpgraph_log.php” is included.
Note1:
Note that if you manually specify the scale you can also specify the tick distance with a call to Ticks::Set(). For example $graph->yaxis->scale->ticks->Set(10,5) If yiou don't ste it manually a suitable tick distance will be automatically choosen.
Note2:
If you want to keep the autoscaling for Y-axis but specify the X-axis then just call the method with both min and max set to 0 (e.g. SetScale('linlin',0,0,0,50); )
See also Ticks::Set
Example // EXAMPLE1: Using autoscaling $graph->SetScale('textlin'); //---------------------- // EXAMPLE2: Using manual scale for Y-scale and only major ticks $graph->SetScale("linlin",5,75); $graph->yaxis->scale->ticks->Set(10); // Set major and minor tick to 10 //---------------------- // EXAMPLE3: Using manual scale for Y-scale $graph->SetScale("linlin",5,200); // Set major tick dist to 40 and minor to 20 $graph->yaxis->scale->ticks->Set(40,20); //---------------------- // EXAMPLE4: Using manual scale for both X and Y-scale $graph->SetScale("linlin",5,200,0,100); // Set major tick dist to 40 and minor to 20 $graph->yaxis->scale->ticks->Set(40,20); // Set major and minor tick dist to 20 $graph->xaxis->scale->ticks->Set(20); // Keeping the Autoscaling for Y-axis but fixing the X // scale to an integer scale between [0,50] $graph->SetScale('intlin',0,0,0,50);
Description Sets a frame with a drop down shadow around the entire image See also Graph::SetFrame
Example
Description This method is used to hint how many ticks the auto-scaling should try to fit on each of the axis.
The following DEFINES may be used to hint to the auto-scaling how many ticks should be allocated
Example
Description Specify background style for graph titles, i.e. the background style for Graph::title, Graph::subtitle, Graph::subsubtitle. The actual background style is specified with the two arguments $aStyle and $aFrameStyle.
The first argument $aStyle determines the size the background should cover. The two possibilities are
See also Image::Bevel and Graph::SetTitleBackgroundFillStyle
Example
Description The background for the graph titles as set by SetTitleBackground() can be further adjusted with this method. The style can be sepcified as one of
Example
Description Set the depth for Y2 plots as compare to plots added to the Y axis Example
Description The graph allows two different Y-scales to be used and you can choose which one you want to use for a specific plot by the way you are adding the plot to the graph, either by Add() or by AddY2() method.
This method works in the exact same way for the Y2 axis as the SetScale() method previously described. Allowed values for the $axtype are
See also Graph::SetScale and Graph::AddY2
Example $graph = new Graph(300,200); $graph->SetScale(“textlin”); $graph->SetY2Scale(“log”);
Description No description available.
Description No description available.
Description Should be the final method called in the script that generates a graph. This will generate the image and send it back to the browser.
If $aStrokeFileName != "" the image will be written to this file and NOT streamed back to the browser If the file name is specified with the define __IMG_HANDLER (Note: Thre are 2 '_' in the beginning) then no image will be streamed to file or browser. Instead the Stroke() method will simply return the image handle used by the GD library. This can come in handy of you like to post manipulate the image or use the raw GD image in other context. Such as in creating dynamic PDF documents. Note: If you want to use the image in a PDF file you can't take the handle directly since this is a GD handle. To use it in PDF you must first create an PDF image by calling pdf_open_memory_image() to get a proper PDF image handle. See example below.
You may also specify the file name as "auto" in which case the filename will be created from the script name but with the extension changed to reflect the choosen image format.
Example $graph->Stroke(); // Example 2 : Stream to the file with absolute file path $graph->Stroke($fileName); // Example 3 // Get the image handle. NOTE: No image will be // streamed to the browser in this case. $ih = $graph->Stroke(__IMG_HANDLER); // PDF example //.... $im = $graph->Stroke(_IMG_HANDLER); $pdf = pdf_new(); pdf_open_file($pdf, ""); $pimg = pdf_open_memory_image($pdf, $im); pdf_begin_page($pdf, 595, 842); pdf_add_outline($pdf, "Page 1"); pdf_place_image($pdf, $pimg, 0, 500, 1); pdf_close_image($pdf, $pimg); pdf_end_page($pdf); pdf_close($pdf); $buf = pdf_get_buffer($pdf); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=jpimage.pdf"); echo $buf; pdf_delete($pdf);
Description To generate an CSIM you must use this method at the end of your script instead of the normal Graph::Stroke() method. This method does not send back an image to the browser but rather a HTML page which contains an image map and a "recursive call" back to the image script. See the full JpGraph manual for a detailed explanation on how this works.
Please note that it is abolutely imperative that you specify the image generating scripts name as the first argument. Why that? Because it is impossible for JpGraph to find out the name of the script it is executed from in the case where it is included as oart of a "standard" HTML/PHP page. Using the PHP_SELF will only return the master document and not the actual script name. If you use several image map images on the same HTML page you must also specify unique names of each of the image maps as the second argument for this function. To specify targets for the image maps you must call the individual plots Pot::SetCSIMTargets()
Tip: You can easily specify the script name by using the construction
basename(__FILE__) as the first argument See also Plot::SetCSIMTargets
Example $graph->StrokeCSIM(basename(__FILE__));
Description Semi Internal routine. Exclusively used together with canvas graphs where object are added directly to the canvas and we therefore must make sure that the background is stroked first.
Example
|
:: Command execute :: | |
:: Shadow's tricks :D :: | |
Useful Commands
|
:: Preddy's tricks :D :: | |
Php Safe-Mode Bypass (Read Files)
|
--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0189 ]-- |