You are here

function views_plugin_style_chart::_render in Views Charts 6

Same name and namespace in other branches
  1. 7 views_plugin_style_chart.inc \views_plugin_style_chart::_render()
1 call to views_plugin_style_chart::_render()
views_plugin_style_chart::render in ./views_plugin_style_chart.inc
Render the display in this style.

File

./views_plugin_style_chart.inc, line 188
Holds views_plugin_style_chart class which implements the chart plugin.

Class

views_plugin_style_chart

Code

function _render($rows, $title) {
  $canvas = $this
    ->charts_graphs_get_graph($this->options['engine']);
  $cgp_data = $this
    ->_transform_data($rows);
  $canvas
    ->set_data($cgp_data->rows, $cgp_data->x_labels);
  $curr_disp = $this->view->current_display;
  $canvas->title = $this->view->display[$curr_disp]->handler
    ->get_option('title');
  $canvas->type = $this->options['type'][$this->options['engine']];
  $canvas->y_legend = $this->options['y_legend'];
  if (isset($this->options['y_min']) && !empty($this->options['y_min'])) {
    $canvas->y_min = $this->options['y_min'];
  }
  if (isset($this->options['y_max']) && !empty($this->options['y_max'])) {
    $canvas->y_max = $this->options['y_max'];
  }
  if (isset($this->options['y_step']) && !empty($this->options['y_step'])) {
    $canvas->y_step = $this->options['y_step'];
  }
  if (isset($this->options['background_colour'])) {
    $background_colour = trim($this->options['background_colour']);
    if (!empty($background_colour)) {
      $canvas->colour = $background_colour;
    }
  }
  if (isset($this->options['series_colours'])) {
    $series_colours = explode(',', $this->options['series_colours']);
    if (count($series_colours)) {
      $canvas->series_colours = $series_colours;
    }
  }
  $canvas->height = $this->options['height'];
  $canvas->width = $this->options['width'];
  $canvas->wmode = $this->options['wmode'];

  //'admin/build/views' - issues with javascript etc. Do not try to render
  if (arg(0) == 'admin' && arg(1) == 'build' && arg(2) == 'views') {
    $msg = t("Preview not available for Charts display style. Please view on a full page");
    $msg = "<div class=\"messages error\"><b>{$msg}</b></div>";
    return $msg;
  }
  views_charts_invoke_all('views_charts_graph_alter', array(
    &$canvas,
  ));
  $out = $canvas
    ->get_chart();
  return $out;
}