1
<?php
/* CAT:Bar Chart */ 

 /* pChart library inclusions */ 
    include("pData.class.php"); 
    include("pDraw.class.php"); 
    include("pImage.class.php"); 
    require "ludigidb.php";

            $db = new luDigi_db ();
            $r=$db->do_some_magic($db->run_q("SELECT emc_city , COUNT(  `emc_city` ) AS count FROM emc_leadgen  GROUP BY emc_city "));
            if ($r > 0)  {
/* Create and populate the pData object */ 
    $MyData = new pData();   
            foreach($r as $l)
            foreach($l as $g=>$b)
            $colnams[]=$b;
            for ($i=0; $i<count($colnams); $i++)  {
            $MyData->addPoints($colnams[$i],"emc_city");// (1) this portion is showing the x axis values//
} 
            for ($ii=0; $ii<count($colnams); $ii++)  {
            $MyData->addPoints($colnams[$ii],"count");// (2) I am facing problem in this line //
}
            $MyData->setAxisName(0,"count"); 
            $MyData->setSerieDescription("emc_city","count"); 
            $MyData->setAbscissa("emc_city"); 
            }
/* Create the pChart object */ 
 $myPicture = new pImage(700,230,$MyData); 

 /* Turn of Antialiasing */ 
 $myPicture->Antialias = FALSE; 

 /* Add a border to the 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 the default font */ 
 $myPicture->setFontProperties(array("FontName"=>"pf_arma_five.ttf","FontSize"=>6)); 

 /* Define the chart area */ 
 $myPicture->setGraphArea(60,40,650,200); 

 /* Draw the scale */ 
 $scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE); 
 $myPicture->drawScale($scaleSettings); 

 /* Write the 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 the 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 the picture (choose the best way) */ 
 $myPicture->autoOutput("pictures/example.drawBarChart.spacing.png"); 

 ?>

[1]: https://i.stack.imgur.com/hkJY0.png = this image is my output which helps you to understand my problem ** I am working in a php language . I am using 3 classes of pchart only . In the pic , I have send you the output result . the problem is that I am getting cities name and count values in the x axis , see point (1) and in (2) point I need the count values . I am not able to figure out which variable i have to pass to get the count values .**

PHP_USER1
  • 21
  • 5

0 Answers0