<?php include("views/class/pdata.class.php"); include("views/class/pdraw.class.php"); include("views/class/pimage.class.php"); $mydata = new pdata(); $res=ludigi::get('col'); $ser=ludigi::get('n'); if ($res > 0) { /* create , populate pdata object */ $t1e=array(); $t1=array(); while($row = mysql_fetch_array($res)) { //$sample_number = $row["sample_number"]; //not using data //$mydata->addpoints($sample_number,"sample_number"); $t1e[] = $row[0]; $t1[] = $row[1]; } } $mydata->addpoints($t1,"countoff"); $mydata->setaxisname(0,"countoff"); $mydata->setseriedescription("countoff","count"); $mydata->addpoints($t1e,"name"); $mydata->setabscissa("name"); /* create pchart object */ $mypicture = new pimage(700,230,$mydata); /* turn of antialiasing */ $mypicture->antialias = false; /* add border picture */ $mypicture->drawgradientarea(0,0,700,230,direction_vertical,array("startr"=>240,"startg"=>240,"startb"=>240,"endr"=>180,"endg"=>180,"endb"=>180,"alpha"=>100)); $mypicture->drawgradientarea(0,0,700,230,direction_horizontal,array("startr"=>240,"startg"=>240,"startb"=>240,"endr"=>180,"endg"=>180,"endb"=>180,"alpha"=>20)); $mypicture->drawrectangle(0,0,699,229,array("r"=>0,"g"=>0,"b"=>0)); /* set default font */ $mypicture->setfontproperties(array("fontname"=>"views/fonts/pf_arma_five.ttf","fontsize"=>6)); /* define chart area */ $mypicture->setgrapharea(60,40,650,200); /* draw scale */ $scalesettings = array("gridr"=>200,"gridg"=>200,"gridb"=>200,"drawsubticks"=>true,"cyclebackground"=>true); $mypicture->drawscale($scalesettings); /* write chart legend */ $mypicture->drawlegend(580,12,array("style"=>legend_noborder,"mode"=>legend_horizontal)); /* turn on shadow computing */ $mypicture->setshadow(true,array("x"=>1,"y"=>1,"r"=>0,"g"=>0,"b"=>0,"alpha"=>10)); /* draw chart */ $mypicture->setshadow(true,array("x"=>1,"y"=>1,"r"=>0,"g"=>0,"b"=>0,"alpha"=>10)); $settings = array("surrounding"=>-30,"innersurrounding"=>30,"interleave"=>0); $mypicture->drawbarchart($settings); /* render picture (choose best way) */ //header ("content-type: image/png" ); $mypicture->render("pictures/spacing.png"); ?> <img src="../pictures/spacing.png" />
thats working program , in fetching data using function database , and converting bar-spacing chart . simple program . after fetching data using pchart function creat bar-sapcing chart
Comments
Post a Comment