Home Backend Development PHP Tutorial Detailed explanation of how phplot generates image classes_PHP tutorial

Detailed explanation of how phplot generates image classes_PHP tutorial

Jul 20, 2016 am 11:09 AM
php personal picture it I Tutorial yes generate use kind Detailed explanation

Detailed explanation of the picture class generated by lot in the php tutorial

I personally use phplot, which is an automatically generated class written using the image function of php. First of all, I only know about it. In the original Some versions of it seem to require various configurations and support, but now they all use the php5 series. Everyone only needs to understand some commonly used functions, just like when we learn a software, we only need to know how to use it. If you are interested, you can study it in depth, but for most of our friends, as long as you can use it, it is fine. After all, it is not commonly used. It is only used when you need to use PHP to draw pictures. So we just need to know how to use it, then
we must know the role of its function, just like when we learn discuz, we just need to know how to use it!
The download address of phplot is http://www.sourceforge.net/projects/phplot/The latest version seems to be phplot5.0
His commonly used functions are divided into several categories: configuration function, display function, color Function
1. Configuration function: configure what type phplot uses and how to display the image.
a.SetDataType($which_dt): Set the data type used. Multiple types can be used in this.
(1)text-date: The data is arranged at equal intervals along the x-column. Each array element represents a point at a certain position on the x-axis. It is also an array. The first element represents the x coordinate, and all subsequent elements of
represent the y coordinate.
(2) data-data: Similar to the above type, except that the second element of the numerical array represents the x coordinate, the following element represents the y coordinate, and the first element is just a label.
(3)data-data-error: Similar to data-data, except that there are two elements after its numerical array representing error_plus and error_minus, such as
(data_labl,x_position,y_position,error_plus,error_minus ).
b.SetDataValues($which_dv): Assign an array $which_dv to a variable $this->data_values ​​of the class. This function should be called before starting to draw.
c.SetPlotType($which_pt): Set the type of chart, which can be bars, lines, linepoints, area, points, pie, etc.
d.SetErrorBarLineWidth($wd): Set the width of the error bar.
e.SetFileFormat($which_file_format): Set the format of the output image file, which can be GIF, PNG, JPEG, etc. It also depends on whether your GD library supports it.
f.SetUseTTF($which_ttf): Set whether to use TTF. If the compiled php supports TTF, use SetUseTTF("1"); otherwise set to 0.

2. Display function: Display image sets the type, width and other parameters of the lines used in the output chart. You can also set the spacing of the coordinate axis scales, the size of the chart, etc.
a.SetErrorBarShape($which_ebs): Set the type of precision line, which can be line or tee. If it is tee, the half degree of the T-shaped line is set to SetErrorBarSize.
b.SetErrprBarSize($which_ebs ): Set the width of the precision line.
c.SetHorizTickIncreament($which_ti): Set the spacing of the x-axis display scale.
d.SetHorizTicks($whick_nt): Set the number of ticks displayed on the x-axis. (Cannot be used with SetHorizTickIncreament)
e.SetNumVertTicks($which_nt): Set the number of ticks displayed on the x-axis. (Cannot be used with SetVertTickIncreament)
f.SetPlotArearpixels($x1,$y1,$x2,$y2): Set the chart size.
g.SetPointShape($which_pt): Set the shape of the fixed point: rect, circle, diamond, triangle, dot, line, halfline.
h.SetPointSize ($whick_ps tutorial): Set the width of the point.
i.SetPrecisionX($whick_prec): Set the precision of the x-axis. $whick_prec represents the number of digits after the decimal point.
j.SetPrecisiony($whick_prec) sets the precision of the y-axis. $whick_prec represents the number of digits after the decimal point.
k.SetSjading($whick_s): Set the width of the shadow.
l.SetTickLength($which_tl): Set the length of the marker line on the coordinate axis, in pixels.
m.SetTile($title): Set the title of the chart.
n.SetVertTickIncreament($whick_ti): and SetHorizTicks($whick_nt) are two functions used to set the vertical and horizontal intervals of the mark lines on the coordinate axis.
o.SetXDataLabelMaxlength($which_xdlm): Set the maximum length of the label on the x-axis.
p.SetXGridLabelType($which_xtf): Set the label type of the x-axis, which can be time, title, data, none or default.
(1).time: Set by the function strftime().
(2).title: text type.
(3).data: Use the function number_format() to format numbers.
(4).none: No tags.
(5).default: Output according to the input form.
3. Color function: The color function is used to set the display color of each element in the chart, including the image background color and the color of the grid line. Title colors and more!
a.SetBackgroundColor($which_color): Set the background color of the entire image.
b.SetGridColor($which_color): Set the color of the grid line.
c.SetLegend($which_legend): The parameter is a text array, and its content is displayed in a chart box.
d.SetLegendPixels($which_x,$which_y,$which_type): Set the coordinates of the lower left corner point of the picture frame. The last parameter will be available later.
e.SetLightGridColor($which_color): The cutting line has two colors. This function sets one of them.
f.SetLineWidth($which_lt): Sets the line width used in the chart. It also affects the width of the precision line.
g.SetLineStyles($which_sls): Set the type of line, which can be solid or dashed.
h.SetPlotBgColor($which_color): Set the color of the area set using the SetPlotAreaPixels() function.
i.SetTextColor($which_color): Set the color of the text, the default is black.
j.SetTickColor($which_color): Set the color of the tick line on the coordinate axis.
k.SetTitleColor($which_color): Set the title color.

Look at an example

The code to generate the above graphic is as follows:

# PHPlot Demo

# 2008-01-09 ljb

# For more information see http://sourceforge.net/projects/phplot/

# Load the PHPlot class library:

require_once ' phplot.php';

# Define the data array: Label, the 3 data sets.

# Year, Features, Bugs, Happy Users:

$data = array(

array('2001', 60, 35, 20),

array('2002', 65, 30, 30),

array('2003', 70, 25, 40),

array('2004', 72, 20, 60),

array('2005', 75, 15, 70 ),

array('2006', 77, 10, 80),

array('2007', 80, 5, 90),

);

# Create a PHPlot object which will make a 600x400 pixel image:

$p = new PHPlot(600, 400);

# Use TrueType fonts:

$p->SetDefaultTTFont('./arial.ttf');

# Set the main plot title:

$p->SetTitle('PHPlot Customer Satisfaction (estimated)');  

 

# Select the data array representation and store the data:  

$p->SetDataType('text-data');  

$p->SetDataValues($data);  

 

# Select the plot type - bar chart:  

$p->SetPlotType('bars');  

 

# Define the data range. PHPlot can do this automatically, but not as well.  

$p->SetPlotAreaWorld(0, 0, 7, 100);  

 

# Select an overall image background color and another color under the plot:  

$p->SetBackgroundColor('#ffffcc');  

$p->SetDrawPlotAreaBackground(True);  

$p->SetPlotBgColor('#ffffff');  

 

# Draw lines on all 4 sides of the plot:  

$p->SetPlotBorderType('full');  

 

# Set a 3 line legend, and position it in the upper left corner:  

$p->SetLegend(array('Features', 'Bugs', 'Happy Users'));  

$p->SetLegendWorld(0.1, 95);  

 

# Turn data labels on, and all ticks and tick labels off:  

$p->SetXDataLabelPos('plotdown');  

$p->SetXTickPos('none');  

$p->SetXTickLabelPos('none');  

$p->SetYTickPos('none');  

$p->SetYTickLabelPos('none');  

 

# Generate and output the graph now:  

$p->DrawGraph();  

 

 


怎么样,不错吧。。 喜欢的朋友可以到 http://phplot.sourceforge.net/ 官方站下载


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444774.htmlTechArticlephp教程lot生成图片类详解 我个人使用的是phplot,它是一个利用php的图象函数编写的一个自动生成类,首先申明我对他也只是了解. 在原来的...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

See all articles