Skip to content

Commit

Permalink
graphlib: NOBUG previous Moodle-specific hack had a bug when y_max wa…
Browse files Browse the repository at this point in the history
…s very small. This would round, e.g. 10^-5 to 0 which would break the axis.
  • Loading branch information
tjhunt committed Oct 6, 2009
1 parent bf088b3 commit 43fd59e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/graphlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,9 @@ function find_range($data, $min, $max, $resolution) {
if ($max < 0) $factor = - pow(10, (floor(log10(abs($max))) + $resolution) );
else $factor = pow(10, (floor(log10(abs($max))) - $resolution) );
}
$factor = round($factor * 1000.0) / 1000.0; // To avoid some wierd rounding errors (Moodle)
if ($factor > 0.1) { // To avoid some wierd rounding errors (Moodle)
$factor = round($factor * 1000.0) / 1000.0; // To avoid some wierd rounding errors (Moodle)
} // To avoid some wierd rounding errors (Moodle)

$max = $factor * @ceil($max / $factor);
$min = $factor * @floor($min / $factor);
Expand Down

0 comments on commit 43fd59e

Please sign in to comment.