You are here

function charts_plugin_style_chart::options_form in Charts 7

Same name and namespace in other branches
  1. 6 views/charts_plugin_style_chart.inc \charts_plugin_style_chart::options_form()
  2. 7.2 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 36
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 options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // Add the Chart Settings form
  module_load_include('admin.inc', 'charts');

  // Get chart settings from options form.
  _charts_settings_form($form['charts'], $this->options['charts']);
  $form['show_legend'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show legend'),
    '#default_value' => $this->options['show_legend'],
    '#description' => t('Display legend next to the chart.'),
  );
  $form['show_sums'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show individual sums'),
    '#default_value' => TRUE,
    '#description' => t('Display the sum for each column in the chart legends'),
  );

  // Views Calc related fields
  $form['aggregation_field'] = array(
    '#type' => 'select',
    '#title' => t('Legend field'),
    '#options' => $this
      ->aggregated_field_options(),
    '#default_value' => $this->options['aggregation_field'],
    '#description' => t('Select a field to aggreagate the results on.'),
  );

  // TODO Charts module cannot currently handle more than one series,
  // update Multiple to TRUE if that changes.
  $form['calc_fields'] = array(
    '#type' => 'select',
    '#title' => t('Operation field'),
    '#options' => $this
      ->aggregated_field_options(),
    '#default_value' => $this
      ->calc_fields(),
    '#multiple' => FALSE,
    '#description' => t('Select field to perform computations on.'),
  );
  $form['calc'] = array(
    '#type' => 'select',
    '#title' => t('Operation'),
    '#options' => $this
      ->calc_options(),
    '#default_value' => $this->options['calc'],
  );
  $form['precision'] = array(
    '#type' => 'select',
    '#title' => t('Precision'),
    '#options' => range(0, 4),
    '#default_value' => $this->options['precision'],
    '#description' => t('Decimal points to use in computed values.'),
  );
}