php数据统计图类实例代码详解_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php数据统计图类实例代码详解_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3971字,纯文字阅读大概需要6分钟。
内容图文
![php数据统计图类实例代码详解_PHP教程](/upload/InfoBanner/zyjiaocheng/176/0f4e6157ce004189b887c0a863532dab.jpg)
- <?php
- /***
- * 时间 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/...
内容总结
以上是互联网集市为您收集整理的php数据统计图类实例代码详解_PHP教程全部内容,希望文章能够帮你解决php数据统计图类实例代码详解_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。