You are here

function charts_plugin_style_chart::options_form in Charts 6

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

Generate a form for setting options.

File

views/charts_plugin_style_chart.inc, line 32
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']);

  // 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.'),
  );
}