有关PHP生成图形报表

        在开发统计系统中要用到很多图像报表的功能,我选择了JpGraph。JpGraph是一个专门提供图表的类库,用了这个类比起以前自己写起来简单多了;并且这个可以按自己的需要进行二次开发。

        JpGraph没有对数据按色分组的功能, 下面是我对这个图表是加上按自定义颜色分隔的功能的效果,比以前统一的背景看起来美观一点。

代码如下:

function FillPlotArea() {
  if(is_array($this->plotarea_color)){//当传过来的是数组时就会按色分组,
   $colorNum=count($this->plotarea_color);
   $distance=($this->img->width-$this->img->left_margin-$this->img->right_margin)/$colorNum;
   foreach($this->plotarea_color as $num=>$color){
    $this->img->PushColor($color);
    $startX=$this->img->left_margin+$distance*$num;
    $endX=$this->img->left_margin+$distance*($num+1);
    $this->img->FilledRectangle($startX,
           $this->img->top_margin,
           $endX,
           $this->img->height-$this->img->bottom_margin); 
    $this->img->PopColor();
   }
  }else{//原函数不变,可以接收
   $this->img->PushColor($this->plotarea_color);
   $this->img->FilledRectangle($this->img->left_margin,
       $this->img->top_margin,
       $this->img->width-$this->img->right_margin,
       $this->img->height-$this->img->bottom_margin); 
   $this->img->PopColor();
  }
    }

最后有个问题还没有解决的,看哪个朋友可以帮一下,简体中文正常显示,繁体中文什么都显示不了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值