You are here

protected function flot_views_plugin_style::get_layers in Flot 6

Build each layer and retrieve its result set.

1 call to flot_views_plugin_style::get_layers()
flot_views_plugin_style::preprocess in views/flot_views_plugin_style.inc
Theme template preprocessor.

File

views/flot_views_plugin_style.inc, line 162

Class

flot_views_plugin_style

Code

protected function get_layers() {
  $merged = array(
    'series' => array(),
    'titles' => array(),
    'ticks' => array(),
    'range' => array(
      'min' => NULL,
      'max' => NULL,
    ),
  );
  $layer_names["{$this->view->name}:{$this->view->current_display}"] = "{$this->view->name}:{$this->view->current_display}";
  $layer_names += array_filter($this->options['layers']);
  foreach ($layer_names as $layer_name) {
    list($view_name, $display_name) = explode(':', $layer_name);

    // Check that we're not going to build ourselves (and recurse to death).
    if ($layer_name === "{$this->view->name}:{$this->view->current_display}") {
      $layer = $this
        ->build_layer($this->view, $this->view->result, $this->view
        ->get_title());
    }
    else {
      if ($view = views_get_view($view_name)) {
        $view
          ->set_display($display_name);

        // If this display inherits arguments, pass the parent view's args.
        if ($view->display_handler
          ->get_option('inherit_arguments')) {
          $view
            ->set_arguments($this->view->args);
        }
        $view
          ->execute();
        $view
          ->init_style();
        $layer = $this
          ->build_layer($view, $view->result, $view
          ->get_title());
      }
    }
    if ($layer && !empty($layer['series']->data)) {

      // Merging series and titles is simple.
      $merged['series'][] = $layer['series'];
      $merged['titles'][] = $layer['title'];

      // Build an overlapping set of ticks between each series.
      foreach ($layer['ticks'] as $key => $val) {
        $merged['ticks'][$key] = $val;
      }

      // Choose the maximum of all series and minimum of all series for range.
      if (!isset($merged['range']['min']) || $layer['range']['min'] < $merged['range']['min']) {
        $merged['range']['min'] = $layer['range']['min'];
      }
      if (!isset($merged['range']['max']) || $layer['range']['max'] > $merged['range']['max']) {
        $merged['range']['max'] = $layer['range']['max'];
      }
    }
  }
  $merged['ticks'] = array_values($merged['ticks']);
  return $merged;
}