function views_plugin_style_chart::_render in Views Charts 7
Same name and namespace in other branches
- 6 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 215 - Holds views_plugin_style_chart class which implements the chart plugin.
Class
Code
function _render($rows, $title) {
if (!isset($this->options['engine'])) {
drupal_set_message("No engine specified for display '" . $this->view->current_display . "' on view '" . $this->view->name . "'");
return FALSE;
}
if ($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);
$canvas->x_type = $cgp_data->x_type;
$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 (!empty($this->options['series_colours'])) {
$series_colours = explode(',', $this->options['series_colours']);
if (count($series_colours)) {
$canvas->series_colours = $series_colours;
}
}
else {
$canvas->series_colours = $canvas
->series_colours();
}
// make the user input a bit more resilient;
$width = str_replace("px", "", $this->options['width']);
// just for people who are confused and still added this
$width = is_numeric($width) || is_numeric(str_replace("%", "", $width)) ? $width : "600";
$height = str_replace("px", "", $this->options['height']);
$height = is_numeric($height) ? $height : "500";
$canvas->width = $width;
$canvas->height = $height;
$canvas->showlegend = $this->options['showlegend'];
$canvas->zoom = $this->options['zoom'];
// Flot only
//'admin/structure/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,
));
$element = $canvas
->get_chart();
return render($element);
}
else {
drupal_set_message("Graph with engine " . $this->options['engine'] . " not available");
}
}