php 数据统计图类实例代码详解_PHP教程
Lepaskan: 2016-07-13 17:40:52
asal
1395 orang telah melayarinya
- /***
- * 时间 2010-8-9
- * www.ite5e.com
- * 注意:如有什么问题可以回帖。
- * 程序最底下有调用测试代码。
- ***/
- 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 /*** * 时间 2010-8-9 * www.ite5e.com * 注意:如有什么问题可以回帖。 * 程序最底下有调用测试代码。 ***/ define("DEFAULT_FONT_PATH", "c:/windows/fonts/...
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel terbaru oleh pengarang
-
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
Topik-topik yang berkaitan
Lagi>