php自定义类生成lib,php生成图形(Libchart)的代码分享

/*

LIbchart图形生成类的例子

编辑:www.jbxue.com

*/

require "./libchart/classes/libchart.php";

class drawPic{

var $chart;

var $style;

function drawPic($style="1",$width="500",$height="250"){

$this->style=$style;

if($style==1){

//cylinder

$this->chart = new VerticalBarChart($width,$height);

}else if($style==2){

//line

$this->chart = new LineChart($width,$height);

}else if($style==3){

//Lump

$this->chart = new PieChart($width,$height);

}else{

//cross

$this->chart=new HorizontalBarChart($width,$height);

}

}

function draw($obj){

if($this->style==1||$this->style=="1"){

//cylinder

$dataSet = new XYDataSet() ;

$this->chart->setTitle($obj->title);//title

$arr=array();

$arr=$obj->dataArray;

foreach($arr as $key => $val){

$dataSet->addPoint ( new Point($key,$val)) ;

}

$this->chart->setDataSet ( $dataSet ) ;

$this->chart->render();

}else if($this->style==2||$this->style=="2"){

//line

$this->chart->setTitle($obj->title);//title

$arr=array();

$arr=$obj->dataArray;

$i=0;

$dataSet = new XYSeriesDataSet();

foreach($arr as $key => $val){

$serie{$i}= new XYDataSet();

foreach($val as $k => $v){

$serie{$i}->addPoint(new Point($k,$v));

}

$dataSet->addSerie($key,$serie{$i});

$i=$i+1;

}

$this->chart->setDataSet($dataSet);

$this->chart->render();

}else if($style==3){

//Lump

$dataSet = new XYDataSet() ;

$this->chart->setTitle($obj->title);//title

$arr=array();

$arr=$obj->dataArray;

foreach($arr as $key => $val){

$dataSet->addPoint ( new Point($key."($val)",$val)) ;

}

$this->chart->setDataSet ( $dataSet ) ;

$this->chart->render();

}else{

//cross

$dataSet = new XYDataSet();

$this->chart->setTitle($obj->title);//title

$arr=array();

$arr=$obj->dataArray;

foreach($arr as $key => $val){

$dataSet->addPoint ( new Point($key,$val)) ;

}

$this->chart->setDataSet($dataSet);

$this->chart->render();

}

}

}

//调用示例

class kkk{};

$n=new drawPic("4");//it will set 1 or 2 or 3 or 4

$k=new kkk();

$k->dataArray=array("2000"=>"30","2001"=>"40","2002"=>"50","2003"=>"60","2004"=>"70","2005"=>"80","20020"=>"90");//style==1 or style=2 or style=4

//$k->dataArray=array("2000"=>"30","2001"=>"40","2002"=>"50","2003"=>"60","2004"=>"70","2005"=>"80","20020"=>"90");//style==3

//$k->dataArray=array("yi"=>array("2000"=>"30","2001"=>"40","2002"=>"50","2004"=>"60"),"er"=>array("2003"=>"60","2004"=>"70","2005"=>"80","20020"=>"90"),"san"=>array("33"=>"12","45"=>"56","89"=>"45","86"=>"49"));//style==2 and the years will show first array to block.(it will be show 2000 2001 2002 2004)

$k->title="The Sheet title";

$n->draw($k);

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是在Ubuntu系统中安装Bugzilla的步骤: 1. 安装必要的软件包: ``` sudo apt-get install apache2 mysql-server libappconfig-perl libdate-calc-perl libtemplate-perl libmime-perl build-essential libdatetime-timezone-perl libdatetime-perl libemail-sender-perl libemail-mime-perl libemail-mime-modifier-perl libdbi-perl libdbd-mysql-perl libcgi-pm-perl libmath-random-isaac-perl libmath-random-isaac-xs-perl apache2-mpm-prefork libapache2-mod-perl2 libapache2-mod-perl2-dev libchart-perl libxml-perl libxml-twig-perl perlmagick libgd-graph-perl libtemplate-plugin-gd-perl libsoap-lite-perl libhtml-scrubber-perl libjson-rpc-perl libdaemon-generic-perl libtheschwartz-perl libtest-taint-perl libfile-slurp-perl libencode-detect-perl libmodule-build-perl libauthen-radius-perl libfile-which-perl libxml-dom-perl libxml-parser-perl ``` 2. 下载并解压缩Bugzilla: ``` wget https://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-5.0.6.tar.gz tar zxvf bugzilla-5.0.6.tar.gz ``` 3. 移动Bugzilla到Apache的文档根目录: ``` sudo mv bugzilla-5.0.6 /var/www/html/bugzilla ``` 4. 创建一个MySQL数据库: ``` mysql -u root -p create database bugs; grant all privileges on bugs.* to bugs@localhost identified by 'password'; exit ``` 注意:将“password”替换为您选择的数据库密码。 5. 配置Bugzilla: ``` cd /var/www/html/bugzilla sudo cp localconfig{.example,} sudo nano localconfig ``` 在文件中,找到以下行: ``` $db_user = ''; $db_pass = ''; $db_name = 'bugs'; ``` 修改为: ``` $db_user = 'bugs'; $db_pass = 'password'; $db_name = 'bugs'; ``` 注意:将“password”替换为您选择的数据库密码。 6. 创建一个管理员帐户: ``` sudo ./checksetup.pl sudo ./checksetup.pl --check-modules sudo ./checksetup.pl --run sudo ./checksetup.pl --check-modules sudo ./checksetup.pl --setup-admin ``` 按照提示输入管理员帐户的用户名和密码。 7. 配置Apache: ``` sudo nano /etc/apache2/conf-available/bugzilla.conf ``` 添加以下内容: ``` <Directory /var/www/html/bugzilla> AddHandler cgi-script .cgi Options +Indexes +ExecCGI DirectoryIndex index.cgi AllowOverride All Require all granted </Directory> ``` 保存并关闭文件。 8. 激活配置文件并重新启动Apache: ``` sudo a2enconf bugzilla sudo systemctl restart apache2 ``` 9. 访问Bugzilla: 在Web浏览器中输入服务器的IP地址或域名,后面加上/bugzilla即可访问Bugzilla。例如:http://192.168.1.100/bugzilla。 现在,您已经成功在Ubuntu系统中安装了Bugzilla。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值