You are here

function _yandex_metrics_chart_adjust_resolution 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_chart_adjust_resolution()

Replace for _chart_adjust_resolution(). Use '#fluid_grid_adjust' => array('#max' => $max_grid) inslead of #adjust => TRUE for custom grids.

1 call to _yandex_metrics_chart_adjust_resolution()
yandex_metrics_reports_chart_alter in yandex_metrics_reports/yandex_metrics_reports.module
Implements hook_chart_alter().

File

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

Code

function _yandex_metrics_chart_adjust_resolution(&$data, $max_grid) {
  if (count($data)) {

    // Encoding resolution
    $resoluton = 100;
    $divider = $max_grid / $resoluton;
    foreach ($data as $k => $v) {
      if (is_array($v)) {
        _yandex_metrics_chart_adjust_resolution($data[$k], $max_grid);
      }
      else {
        if (is_numeric($v)) {

          // Multiply or divide data values to adjust them to the resolution
          $data[$k] = floor($v / $divider);
        }
      }
    }
  }
}