Charts are widely used in data and can be used to visualize complex data, this article describes how to add rows and columns to charts!
Add row and column labels to charts using the GD2 function (PHP graphic image typical application tutorial 5)
Charts are widely used in data and can be used to visualize complex data, this article describes how to add rows and columns to charts!
Let's continue to review the previous article "using GD2 functions to draw ry (PHP image typical application tutorial 4)". This article describes how to use GD2 functions to draw Ry, we also introduced several common functions for image processing. today we will introduce how to add row and column labels to charts!
Technical points of this article:
We still need to apply the GD2 function to add row and column labels to the chart. some of the functions are described in detail in the previous articles. now we will introduce several functions!
(1) imagecreatefrompng () function
This function is used to obtain image files in png format. the syntax format of this function is as follows:
resource imagecreatefrompng ( string $filename )
Imagecreatefrompng () returns an image identifier, representing the image obtained from the given file name.
(2) imageline () function
This function is used to draw a solid line. The syntax format of the function is as follows:
bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
This function uses color to draw a solid line from the coordinates (x1, y1) to (x2, y2) in the image. The Origin () is the upper left corner of the image.
(3) imagestring () function
This function is used to draw a line of string horizontally on the image. the syntax format is as follows:
bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
The font parameter is a font. if it is set to 1 to 5, the default font is used. the x and y parameters are the starting coordinates of the string. the content of the string is placed in parameter s, and the col parameter represents the color of the string!
Implementation process
The output result is as follows:
Note:
The imagepng () function sends the output content in png format to the browser. if you want to output the content in different formats, you should call the corresponding function. if you want to send the content in GIF format, you should call the imagegif () function.
It's easy to add rows and column labels to charts. next we will continue to introduce the chart analysis product data, for more information, see GD2 function-based chart analysis product data (PHP graphic image typical application tutorial 6).
The preceding section describes how to add row and column labels to charts using the GD2 function (PHP graphic image typical application tutorial 5). For more information, see other related articles in the first PHP community!