function pDraw::computeScale in Visitors 7
Same name and namespace in other branches
- 7.2 pChart/class/pDraw.class.php \pDraw::computeScale()
1 call to pDraw::computeScale()
- pDraw::drawScale in pChart/
class/ pDraw.class.php
File
- 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];
}