You are here

function charts_plugin_style_chart::render in Charts 6

Same name and namespace in other branches
  1. 7.2 views/charts_plugin_style_chart.inc \charts_plugin_style_chart::render()
  2. 7 views/charts_plugin_style_chart.inc \charts_plugin_style_chart::render()

Define and display a chart from the grouped values.

File

views/charts_plugin_style_chart.inc, line 127
Contains the chart style plugin. @author Bruno Massa http://drupal.org/user/67164 @author Karen Stevenson http://drupal.org/user/45874

Class

charts_plugin_style_chart
Style plugin to render view as a chart.

Code

function render() {

  // Get chart settings from options form.
  $chart = $this->options['charts'];

  // Get values from rows.
  foreach ($this
    ->calc_fields() as $calc) {
    foreach ($this->view->result as $row) {
      foreach ($this->view->field as $key => $field) {
        if ($key == $this->options['aggregation_field']) {
          $legend_field = array_key_exists($calc, $this->view->field) ? $this->view->field[$calc] : NULL;
          $legend = !empty($legend_field->options['label']) ? $legend_field->options['label'] : NULL;
          $value['#label'] = strip_tags(theme_views_view_field($this->view, $this->view->field[$key], $row));

          // .': '. $row->$calc;
          $value['#value'] = $row->{$calc};
          $chart[$calc][] = $value;
        }
      }
    }
  }

  // Print the chart.
  return charts_chart($chart);
}