function charts_plugin_style_chart::options_form in Charts 7.2
Same name and namespace in other branches
- 6 views/charts_plugin_style_chart.inc \charts_plugin_style_chart::options_form()
- 7 views/charts_plugin_style_chart.inc \charts_plugin_style_chart::options_form()
Generate a form for setting options.
Overrides views_plugin_style::options_form
File
- views/
charts_plugin_style_chart.inc, line 39 - Contains the Chart style (format) plugin (similar to Table, HTML List, etc.)
Class
- charts_plugin_style_chart
- Style plugin to render view as a chart.
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$handlers = $this->display->handler
->get_handlers('field');
if (empty($handlers)) {
$form['error_markup'] = array(
'#markup' => '<div class="error messages">' . t('You need at least one field before you can configure your table settings') . '</div>',
);
return;
}
// Limit grouping options (we only support one grouping field).
if (isset($form['grouping'][0])) {
$form['grouping'][0]['field']['#title'] = t('Grouping field');
$form['grouping'][0]['field']['#description'] = t('If grouping by a particular field, that field will be used to generate multiple data series on the same chart.');
$form['grouping'][0]['field']['#attributes']['class'][] = 'charts-grouping-field';
// Grouping by rendered version has no effect in charts. Hide the options.
$form['grouping'][0]['rendered']['#access'] = FALSE;
$form['grouping'][0]['rendered_strip']['#access'] = FALSE;
}
if (isset($form['grouping'][1])) {
$form['grouping'][1]['#access'] = FALSE;
}
// Merge in the global chart settings form.
module_load_include('inc', 'charts', 'includes/charts.pages');
$field_options = $this->display->handler
->get_field_labels();
$form = charts_settings_form($form, $this->options, $field_options, array(
'style_options',
));
// Reduce the options if this is a chart extension.
if ($parent_display = $this
->get_parent_chart_display()) {
$parent_chart_type = chart_get_type($parent_display->display_options['style_options']['type']);
if (empty($form['type']['#default_value'])) {
$form['type']['#default_value'] = $parent_display->display_options['style_options']['type'];
}
$form['type']['#description'] = empty($form['type']['#description']) ? '' : $form['type']['#description'] . ' ';
$form['type']['#description'] .= t('This chart will be combined with the parent display "@display_title", which is a "@type" chart. Not all chart types may be combined. Selecting a different chart type than the parent may cause errors.', array(
'@display_title' => $parent_display->display_title,
'@type' => $parent_chart_type['label'],
));
$form['fields']['label_field']['#disabled'] = TRUE;
$form['display']['#access'] = FALSE;
$form['xaxis']['#access'] = FALSE;
if ($this->display->handler
->get_option('inherit_yaxis')) {
$form['yaxis']['#access'] = FALSE;
}
else {
$form['yaxis']['#title'] = t('Secondary axis');
$form['yaxis']['#attributes']['class'] = array();
}
}
}