search
HomeBackend DevelopmentPHP TutorialDetailed 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
phppersonalpictureitITutorialyesgenerateusekindDetailed 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
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
How can you check if a PHP session has already started?How can you check if a PHP session has already started?Apr 30, 2025 am 12:20 AM

In PHP, you can use session_status() or session_id() to check whether the session has started. 1) Use the session_status() function. If PHP_SESSION_ACTIVE is returned, the session has been started. 2) Use the session_id() function, if a non-empty string is returned, the session has been started. Both methods can effectively check the session state, and choosing which method to use depends on the PHP version and personal preferences.

Describe a scenario where using sessions is essential in a web application.Describe a scenario where using sessions is essential in a web application.Apr 30, 2025 am 12:16 AM

Sessionsarevitalinwebapplications,especiallyfore-commerceplatforms.Theymaintainuserdataacrossrequests,crucialforshoppingcarts,authentication,andpersonalization.InFlask,sessionscanbeimplementedusingsimplecodetomanageuserloginsanddatapersistence.

How can you manage concurrent session access in PHP?How can you manage concurrent session access in PHP?Apr 30, 2025 am 12:11 AM

Managing concurrent session access in PHP can be done by the following methods: 1. Use the database to store session data, 2. Use Redis or Memcached, 3. Implement a session locking strategy. These methods help ensure data consistency and improve concurrency performance.

What are the limitations of using PHP sessions?What are the limitations of using PHP sessions?Apr 30, 2025 am 12:04 AM

PHPsessionshaveseverallimitations:1)Storageconstraintscanleadtoperformanceissues;2)Securityvulnerabilitieslikesessionfixationattacksexist;3)Scalabilityischallengingduetoserver-specificstorage;4)Sessionexpirationmanagementcanbeproblematic;5)Datapersis

Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.