Maybe someone can help me, I have a real strange problem.
When I run the code below I get the following error:
Fatal error: Maximum execution time of 30 seconds exceeded in ..../pChart/pChart.class on line 467
If I replace the first amount in $DataSet "Serie1" from 19381.45 to 15381.45 or 45381.45 it will work but if
the value is 19381.45 it gives me the max ecexution time error. Hopefully anyone can help me.
Code:
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array("19381.45","12465.25","10061.15"),"Serie1");
$DataSet->AddPoint(array("461.46","311.63","479.10"),"Serie2");
$DataSet->AddPoint(array("1","2","3"),"Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("Monthly Income","Serie1");
$DataSet->SetSerieName("Average per Order","Serie2");
// Initialise the graph
$Test = new pChart(320,190);
$Test->drawGraphAreaGradient(90,90,90,90,TARGET_BACKGROUND);
// Prepare the graph area
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->setGraphArea(270,40,60,150);
// Initialise graph area
$Test->setFontProperties("Fonts/tahoma.ttf",8);
// Draw the 2nd graph
$DataSet->RemoveSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetYAxisName("Average per Order");
$Test->drawRightScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0);
$Test->drawGrid(4,TRUE,230,230,230,10);
$Test->setShadowProperties(3,3,0,0,0,30,4);
$Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30);
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,254,254,254);
// Write the legend (box less)
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->drawLegend(180,3,$DataSet->GetDataDescription(),0,0,0,0,0,0,254,254,254,FALSE);
$Test->drawTitle(30,410,"Months",254,254,254,300,30,TRUE);
// Write the title
$Test->setFontProperties("Fonts/FreeSansBold.ttf",12);
$Test->setShadowProperties(1,1,0,0,0);
$Test->drawTitle(-195,0,"Sales ".$year,254,254,254,300,30,TRUE);
$Test->clearShadow();
// Render the picture
$Test->Render("chart3.png");
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having this same problem, however it seems to be inconsistent and somewhat related to the values that are entered. If I have several series with several high values I don't get an error, but if I have one or two series with low values then it seems to timeout.
$Test->setGraphArea(20,15,285,120);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having a similar problem, charts with certain values cause it to hang during drawScale() method. Like array(0,0,0,0,0,57000); hangs but array(0,0,0,0,0,56000); executes instantly. When I increase the size of the graph area by increasing the vertical dimensions of setGraphArea() by a factor of 10, it runs fine. So it seems like it is some sort of division or scaling error? If the difference between the scale of the data and the pixels is too large it crashes. Pain it the butt, probably have to change libraries.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, the bug is in the drawScale method. Around line 480, it is trying to calculate an appropriate scale range inside of a while loop. If it doesn't get a good value, it increases the scale factor by 10x and tries again. …. unless the it is below 1, in which case it decreases by 10x… so for some values it gets stuck in an infinite loop oscillating between the same values.
since it isn't increasing and decreasing by the same value, it should eventually converge. Negative side effect: sometimes the scale values won't be nice round numbers, end up with 1033333 etc. Also, loop conditions may still be possible for some values, so I added a max loop param of 100 and an error message so at least it should break the loop.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Infinit loop when graph area heigh smaller than some value.
This works fine:
Add this before while on 473:
$i = 0;
And this in while body:
If ($i++ == 100)
{
$ScaleOk = TRUE;
$Divisions = 1;
$Scale = 2;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe someone can help me, I have a real strange problem.
When I run the code below I get the following error:
Fatal error: Maximum execution time of 30 seconds exceeded in ..../pChart/pChart.class on line 467
If I replace the first amount in $DataSet "Serie1" from 19381.45 to 15381.45 or 45381.45 it will work but if
the value is 19381.45 it gives me the max ecexution time error. Hopefully anyone can help me.
Code:
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array("19381.45","12465.25","10061.15"),"Serie1");
$DataSet->AddPoint(array("461.46","311.63","479.10"),"Serie2");
$DataSet->AddPoint(array("1","2","3"),"Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("Monthly Income","Serie1");
$DataSet->SetSerieName("Average per Order","Serie2");
// Initialise the graph
$Test = new pChart(320,190);
$Test->drawGraphAreaGradient(90,90,90,90,TARGET_BACKGROUND);
// Prepare the graph area
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->setGraphArea(270,40,60,150);
// Initialise graph area
$Test->setFontProperties("Fonts/tahoma.ttf",8);
// Draw the 1st graph
$DataSet->SetYAxisName("Monthly Income");
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0);
$Test->drawGraphAreaGradient(40,40,40,-50);
$Test->drawGrid(4,TRUE,230,230,230,10);
$Test->setShadowProperties(3,3,0,0,0,30,4);
$Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30);
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,254,254,254);
// Clear the scale
$Test->clearScale();
// Draw the 2nd graph
$DataSet->RemoveSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetYAxisName("Average per Order");
$Test->drawRightScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0);
$Test->drawGrid(4,TRUE,230,230,230,10);
$Test->setShadowProperties(3,3,0,0,0,30,4);
$Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30);
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,254,254,254);
// Write the legend (box less)
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->drawLegend(180,3,$DataSet->GetDataDescription(),0,0,0,0,0,0,254,254,254,FALSE);
$Test->drawTitle(30,410,"Months",254,254,254,300,30,TRUE);
// Write the title
$Test->setFontProperties("Fonts/FreeSansBold.ttf",12);
$Test->setShadowProperties(1,1,0,0,0);
$Test->drawTitle(-195,0,"Sales ".$year,254,254,254,300,30,TRUE);
$Test->clearShadow();
// Render the picture
$Test->Render("chart3.png");
Thanks.
I forgot to say I using the latest version pChart.1.27d.rar
I am having this same problem, however it seems to be inconsistent and somewhat related to the values that are entered. If I have several series with several high values I don't get an error, but if I have one or two series with low values then it seems to timeout.
$Test->setGraphArea(20,15,285,120);
As I found out, the height of the chart is to small. If I increase the height of the chart from 150 pixels to 160 pixels it will work.
I'm having a similar problem, charts with certain values cause it to hang during drawScale() method. Like array(0,0,0,0,0,57000); hangs but array(0,0,0,0,0,56000); executes instantly. When I increase the size of the graph area by increasing the vertical dimensions of setGraphArea() by a factor of 10, it runs fine. So it seems like it is some sort of division or scaling error? If the difference between the scale of the data and the pixels is too large it crashes. Pain it the butt, probably have to change libraries.
Ok, the bug is in the drawScale method. Around line 480, it is trying to calculate an appropriate scale range inside of a while loop. If it doesn't get a good value, it increases the scale factor by 10x and tries again. …. unless the it is below 1, in which case it decreases by 10x… so for some values it gets stuck in an infinite loop oscillating between the same values.
Hackish work around:
change from:
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }
if ( $Scale2 < 1 ) { $Factor = $Factor / 10; }
to:
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }
if ( $Scale2 < 1 ) { $Factor = $Factor / 15; }
since it isn't increasing and decreasing by the same value, it should eventually converge. Negative side effect: sometimes the scale values won't be nice round numbers, end up with 1033333 etc. Also, loop conditions may still be possible for some values, so I added a max loop param of 100 and an error message so at least it should break the loop.
this is my patch. around line 480. it works for me.
if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}
if ( $Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}
+ if ( $Scale1 == $this->VMax && $Factor == 1 && !$ScaleOk) { $ScaleOk = TRUE; $Scale = 1; };
I wish to confirm that this is indeed the solution to my problem.
Adding here: processor hangs in case anyone else searches for the term.
Thanks for your help.
Infinit loop when graph area heigh smaller than some value.
This works fine:
Add this before while on 473:
$i = 0;
And this in while body:
If ($i++ == 100)
{
$ScaleOk = TRUE;
$Divisions = 1;
$Scale = 2;
}