You are here

function _ad_report_select_x in Advertisement 5.2

Figure out how many x columns to display. TODO: Find a better algorithm than this slop.

1 call to _ad_report_select_x()
ad_report_generate_bargraph in report/ad_report.module
Page that utilizes gd to generate a bargraph.

File

report/ad_report.module, line 807
Provides comprehensive charts and reports about advertising statistics.

Code

function _ad_report_select_x($number, $divisor, $diff) {
  if ($divisor < 2) {
    return $number;
  }
  $divisor = $divisor + $diff;
  if ($divisor == 0) {
    $divisor = $divisor + $diff;
  }
  $result = (int) ($number / $divisor);
  if ($result < 8) {
    $diff -= 1;
    if ($diff) {
      return _ad_report_select_x($number, $divisor, $diff);
    }
  }
  else {
    if ($result > 12) {
      $diff += 1;
      if ($diff) {
        return _ad_report_select_x($number, $divisor, $diff);
      }
    }
  }
  return $result;
}