In XY scatter plot, the grid can have only as many x divisors as y divisors (or the number can be different by one.). In other cases, the grid renders badly.
<?php
/**
* bad grid error
*/
// Standard inclusions
include("pChart/pData.class");
include("pChart/pChart.class");
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(1,2,3,4,5,8,4,8,15),"Serie1");
$DataSet->AddPoint(array(4,-5,5,2,-1,4,7,12,9),"Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January","Serie1");
$DataSet->SetSerieName("February","Serie2");
// Initialise the graph
$Test = new pChart(600,300);
// Prepare the graph area
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->setGraphArea(50,30,550,250);
$Test->setFixedScale(0,16,8,-5,12,17);
// $Test->setFixedScale(0,16,15,-5,12,17); // uncomment me to see whats wrong
$Test->drawXYScale($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2",0,0,0,TRUE,45);
$Test->drawGraphArea(213,217,221,FALSE);
$Test->drawGraphAreaGradient(30,30,30,-50);
$Test->drawGrid(4,TRUE,230,230,230,20);
// Draw the chart
$Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2",0);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf",10);
$Test->drawTitle(50,22,"Example of error 3 (scatter XY, missing grid)",50,50,50,585);
$Test->Stroke("error3.png");
?>
To fix this bug, please do the following:
(1) Open file 'pChart.class' and go to lines #831, 832. The lines in question are in 'function drawXYScale':
$this->XDivisionCount = $Divisions;
$this->DataCount = $Divisions + 2;
(2) Replace variable $Divisions with $XDivisions. After this correction, you should have:
$this->XDivisionCount = $XDivisions;
$this->DataCount = $XDivisions + 2;
I am delighted with this tool. Thank you Mr Jean-Damien Pogolotti!
Ahmet