When you look at the data, you can see that the text is not as good as a number, and the numbers are not separated. in the design of the questionnaire form, the percentage of horizontal columns is displayed to the user. when the user shows the data to the user, the intuitive effect is as follows: the text is not as good as the number, and the number is not separated. in the design of the questionnaire form, the percentage of horizontal columns is displayed to the user. the user can intuitively see which survey or the popularity of a result. The following describes how to implement the technology:
1. PHP supports drawing, but the GD library must be enabled.
In the php. ini file, find extension = php_gd2.dll, remove the semicolon ";", and restart apache.
2. the following is a demo file, which is explained in more detail. if you do not understand it, you can only copy the content to the clipboard through ^_^ XML/HTML Code.
-
- // Create a canvas. do not have any output or spaces before the canvas is created. Otherwise, the image cannot be generated.
- $ Im = imagecreatetruecolor (100,10 );
- // $ Cc = imagecolorallocate ($ im, 245,245,245 );
- // Imagefill ($ im, 0, 0, $ cc );
- // Color, in RGB format
- $ Red = imagecolorallocate ($ im, 245 );
- $ Cc = imagecolorallocate ($ im, 245,245,245 );
- // Color
- $ Red1 = imagecolorallocate ($ im, 30,144,255 );
- $ Red2 = imagecolorallocate ($ im, 220,20, 60 );
- $ Red3 = imagecolorallocate ($ im, 0,206,209 );
- $ Red4 = imagecolorallocate ($ im, 255,255, 0 );
- // The color of the filled rectangle can be customized. The color defined above is just a test example here. the length ratio can be controlled based on the project's dynamic data.
- // Circle
- // Imageellipse ($ im, 20, 20, 20, $ red );
- // Straight line
- // Imageline ($ im, 0, 0, 400,300, $ red );
- // Rectangle
- // Imagerectangle ($ im, $ red );
- // Fill the rectangle
- Imagefilledrectangle ($ im, 0, 0, 30, 10, $ red );
- Imagefilledrectangle ($ im, 30,0, 100,10, $ cc );
- // Arc
- // Imagearc ($ im, 100,100, 50, 50, 180,270, $ red );
- // Slice
- // Imagefilledarc ($ im, 100,100, 180,270, $ red, IMG_ARC_PIE );
- // Copy the image to the canvas
- // 1. load the source image
- // $ SrcImage = imagecreatefromgif ("2.GIF ");
- // Here we can use a getimagesize ()
- // $ SrcImageInfo = getimagesize ("2.GIF ");
- // Copy the source image to the target canvas
- // Imagecopy ($ im, $ srcImage, 0, 0, 0, $ srcImageInfo [0], $ srcImageInfo [1]);
- Header ("content-type: image/png ");
- // Generate an image
- Imagepng ($ im );
- // Release the memory! If this sentence is not added, apache will crash if the traffic is high.
- Imagedestory ($ im );
- ?>