Detailed explanation of PHP data statistics chart example code_PHP tutorial
Release: 2016-07-13 17:40:52
Original
1395 people have browsed it
- /***
- * Time 2010-8-9
- * www .ite5e.com
- * Note: If you have any questions, please reply.
- * There is a calling test code at the bottom of the program.
- ***/
- define("DEFAULT_FONT_PATH", "c:/windows/fonts/simhei.ttf");
- class barbarism
- {
- private $_x;
- private $_y;
- private $_h;
- public $_l = 50;
- private $_w = null;
- private $_srcPoints = array();
- private $_points = array();
-
- public function __construct($x, $y, $h, $l = 50, $w = null)
- {
- $this->_x = $x;
- $this->_y = $y;
- $this->_h = $h;
- $this->_l = $l;
- $this->_w = $w;
- $this->_srcPoints = $this->getSrcPoints();
- $this->_points = $this->getPoints();
- }
-
- public function getSrcPoints()
- {
- return array(
- array($this->_x , $this->_y),
- array($this->_x $this->_l , $this->_y),
- array($this->_x (1.35*$this->_l), $this->_y-(0.35*$this->_l)),
- array($this->_x (0.35*$this->_l), $this->_y-(0.35*$this->_l)),
- array($this->_x , $this->_y $this->_h),
- array($this->_x $this->_l , $this->_y $this->_h),
- array($this->_x (1.35*$this->_l), $this->_y $this->_h-(0.35*$this->_l))
- );
- }
-
- public function getPoints()
- {
- $points = array();
- foreach($this->_srcPoints as $key => $val)
- {
- $points[] = $val[0];
- $points[] = $val[1];
- }
- return $points;
- }
-
- public function getTopPoints()
- {
- return array_slice($this->_points, 0, 8); //顶坐标
- }
-
- public function getBelowPoints()
- {
- return array_merge(array_slice($this->_points, 0, 2), array_slice($this->_points, 8, 4), array_slice($this->_points, 2, 2)); //下坐标
- }
-
- public function getRightSidePoints()
- {
- return array_merge(array_slice($this->_points, 2, 2), array_slice($this->_points, 10, 4), array_slice($this->_points, 4, 2)); //右侧坐标
- }
-
- public function draw($image, $topColor, $belowColor, $sideColor, $borderColor = null, $type = LEFT)
- {
- if (is_null($borderColor))
- {
- $borderColor = 0xcccccc;
- }
-
- $top_rgb = $this->getRGB($topColor);
- $below_rgb = $this->getRGB($belowColor);
- $side_rgb = $this->getRGB($sideColor);
- $top_color = imagecolorallocate($image, $top_rgb[R], $top_rgb[G], $top_rgb[B]);
- $below_color = imagecolorallocate($image, $below_rgb[R], $below_rgb[G], $below_rgb[B]);
- $side_color = imagecolorallocate($image, $side_rgb[R], $side_rgb[G], $side_rgb[B]);
-
- imagefilledpolygon($image, $this->getTopPoints(), 4, $top_color); //画顶面
- imagepolygon($image, $this->getTopPoints(), 4, $borderColor); //画顶面边线
-
- imagefilledpolygon($image, $this->getBelowPoints(), 4, $below_color); //画下面
- imagepolygon($image, $this->getBelowPoints(), 4, $borderColor); //画下面边线
-
- if ($type == LEFT)
- {
- imagefilledpolygon($image, $this->getRightSidePoints(), 4, $side_color); //画右侧面
- imagepolygon($image, $this->getRightSidePoints(), 4, $borderColor); //画侧面边线
- }
- }
-
- public function getRGB($color)
- {
- $ar = array();
- $color = hexdec($color);
- $ar[R] = ($color>>16) & 0xff;
- $ar[G] = ($color>>8) & 0xff;
- $ar[B] = ($color) & 0xff;
- return $ar;
- }
- }
-
- class Bardate
- {
- private $_W;
- private $_H;
- private $_bgColor = "ffffff";
- private $_barHeights = array();
- private $_barTexts = array();
- private $_barColors = array();
- public $_title;
- public $_paddingTop = 30;
- public $_paddingBottom = 100;
- public $_paddingLeft = 45;
- public $_paddingRight = 2;
- public $_barL = 50;
- public $image;
http://www.bkjia.com/PHPjc/486183.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486183.htmlTechArticle?php /*** * Time 2010-8-9 * www.ite5e.com * Note: If you have any questions, please reply. * There is a calling test code at the bottom of the program. ***/ define("DEFAULT_FONT_PATH", "c:/windows/fonts/...
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31