You are here

function _yandex_metrics_reports_calculate_max_grid in Yandex.Metrics 8.2

Same name and namespace in other branches
  1. 7.2 yandex_metrics_reports/yandex_metrics_reports.reports.inc \_yandex_metrics_reports_calculate_max_grid()

Helper function to calculate rounded max grid value.

Parameters

int $min Min data value.:

int $max Max data value.:

Return value

number

2 calls to _yandex_metrics_reports_calculate_max_grid()
yandex_metrics_reports_traffic_hourly_chart in yandex_metrics_reports/yandex_metrics_reports.reports.inc
The function generates chart with information about hourly traffic.
yandex_metrics_reports_visits_chart in yandex_metrics_reports/yandex_metrics_reports.reports.inc
The function generates chart with information about page views, visitors and new visitors.

File

yandex_metrics_reports/yandex_metrics_reports.reports.inc, line 536
Report callbacks for Yandex.Metrics Reports module.

Code

function _yandex_metrics_reports_calculate_max_grid($min, $max) {
  $k = log10($max - $min);

  // Scale max value for smart rounding.
  $level = pow(10, floor($k));
  $max_grid = ceil(($max - $min) / $level) * $level;
  if ($max_grid == $max) {
    $max_grid += $max_grid * 0.05;

    // Add a margin.
  }
  return $max_grid;
}