You are here

public function MonthlyHistory::display in Visitors 8.2

Returns a monthly history page.

Return value

array A render array representing the monthly history page content.

1 string reference to 'MonthlyHistory::display'
visitors.routing.yml in ./visitors.routing.yml
visitors.routing.yml

File

src/Controller/Report/MonthlyHistory.php, line 61
Contains Drupal\visitors\Controller\Report\MonthlyHistory.

Class

MonthlyHistory

Namespace

Drupal\visitors\Controller\Report

Code

public function display() {
  $config = \Drupal::config('visitors.config');
  $form = $this->formBuilder
    ->getForm('Drupal\\visitors\\Form\\DateFilter');
  $header = $this
    ->_getHeader();
  $results = $this
    ->_getData(NULL);
  $x = array();
  $y = array();
  foreach ($results as $data) {
    $x[] = "\"{$data[1]}\"";
    $y[$data[1]] = $data[2];
  }
  return array(
    'visitors_date_filter_form' => $form,
    'visitors_jqplot' => array(
      '#theme' => 'visitors_jqplot',
      '#path' => drupal_get_path('module', 'visitors'),
      '#x' => implode(', ', $x),
      '#y' => implode(', ', $y),
      '#width' => $config
        ->get('chart_width'),
      '#height' => $config
        ->get('chart_height'),
    ),
    'visitors_table' => array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $this
        ->_getData($header),
    ),
  );
}