function pDraw::computeScale
Search API
5.x pDraw.class.php | pDraw::computeScale($XMin, $XMax, $MaxDivs, $Factors, $AxisID = 0) |
1 call to pDraw::computeScale()
- pDraw::drawScale in inc/
pchart/ pchart/ class/ pDraw.class.php
File
- inc/
pchart/ pchart/ class/ pDraw.class.php, line 2498
Class
Code
function computeScale($XMin, $XMax, $MaxDivs, $Factors, $AxisID = 0)
{
/* Compute each factors */
$Results = "";
foreach ($Factors as $Key => $Factor) {
$Results [$Factor] = $this->processScale($XMin, $XMax, $MaxDivs, array($Factor), $AxisID);
};
/* Remove scales that are creating to much decimals */
$GoodScaleFactors = "";
foreach ($Results as $Key => $Result)
{
$Decimals = preg_split("/\./", $Result ["RowHeight"]);
if ((!isset($Decimals [1])) || (strlen($Decimals [1]) < 6)) {
$GoodScaleFactors [] = $Key;
}
}
/* Found no correct scale, shame,... returns the 1st one as default */
if ($GoodScaleFactors == "") {
return ($Results [$Factors [0]]);
}
/* Find the factor that cause the maximum number of Rows */
$MaxRows = 0;
$BestFactor = 0;
foreach ($GoodScaleFactors as $Key => $Factor)
{
if ($Results [$Factor]["Rows"] > $MaxRows) {
$MaxRows = $Results [$Factor]["Rows"];
$BestFactor = $Factor;
}
}
/* Return the best visual scale */
return ($Results [$BestFactor]);
}