Donate Share

pChart

Subscribe

position of y-axis label & graph height

  1. 2009-11-04 06:02:09 UTC

    firstly, thanks guys for such nice tool. i need help for 2 problems when applying pchart in my website.

    1. how to control the position of y-axis label? i cannot find it in the manual. the default vertical alignment is not at the center.
    2. a weird problem of graph height. i refer to the codes below. the chart generation is fine when $height > 120. whenever i tried the values such as 100, 110, 120, etc and refreshed the page, the page was hung for minutes and nothing showed up, even no error msg. i cannot figure out what's going wrong. please give a hand

      include($lpath."pChart/pData.class");
      include($lpath."pChart/pChart.class");
      include($lpath."pChart/pCache.class");
      
      // Dataset definition
      $DataSet = new pData;
      $Requete = "SELECT schinitial as sch, count(*) as num from OTcount as c, OTlocation as p where c.trapID = p.serialno and datecollect >  '".date('Y-m-d', strtotime("-90 days"))."' group by schinitial;";
      $result  = mysql_query($Requete,$conn);
      while ($row = mysql_fetch_array($result))
      {
          $DataSet->AddPoint($row["num"],"Serie1");
          $DataSet->AddPoint($row["sch"],"Serie2");
      }
      $DataSet->AddAllSeries();
      $DataSet->SetAbsciseLabelSerie("Serie2");
      $DataSet->SetYAxisName("Entry");
      
      // Initialise the graph
      $width = 600;
      $height = 121;
      
      $Test = new pChart($width,$height);
      $Test->setFontProperties($lpath."Fonts/tahoma.ttf",8);
      $Test->setGraphArea(60,20,$width-20,$height-25);
      $Test->drawFilledRoundedRectangle(2,2,$width-7,$height-7,5,240,240,240);
      $Test->drawRoundedRectangle(0,0,$width-5,$height-5,5,230,230,230);
      $Test->drawGraphArea(255,255,255,TRUE);
      $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,0,TRUE);
      $Test->drawGrid(4,TRUE,230,230,230,50);
      
      // Draw the 0 line
      $Test->setFontProperties("$lpath.Fonts/tahoma.ttf",6);
      $Test->drawTreshold(0,143,55,72);
      
      // Draw the bar graph
      $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE);
      
      // Finish the graph
      $Test->setFontProperties($lpath."Fonts/tahoma.ttf",8);
      //$Test->drawLegend(65,25,$DataSet->GetDataDescription(),255,255,255);
      $Test->setFontProperties($lpath."Fonts/tahoma.ttf",9);
      $Test->drawTitle(0,14,"School Contribution in the Last 90 Days",50,50,50,$width);
      $Test->Render($target);
      
  2. 2009-11-04 06:10:42 UTC

    btw, a minor problem about the chart title. the font appearance of title is not as good as axis labels even if i set the same font and the same size. how could i improve the title font towards "axis label" kind of quality?

  3. 2009-11-06 05:04:47 UTC

    anyone could help to resolve the matter? many thanks!

< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.