You are here

function flot_views_plugin_style::options_form in Flot 7

Same name and namespace in other branches
  1. 6 views/flot_views_plugin_style.inc \flot_views_plugin_style::options_form()

Provide a form to edit options for this plugin.

Overrides views_plugin_style::options_form

File

flot_views/views/flot_views_plugin_style.inc, line 14

Class

flot_views_plugin_style

Code

function options_form(&$form, &$form_state) {
  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Graph type'),
    '#options' => array(
      'line' => t('Line'),
      'bar' => t('Bar'),
      'point' => t('Point'),
      'pie' => t('Pie chart'),
    ),
    '#description' => t("Choose the type of chart you would like to display."),
    '#default_value' => $this->options['type'],
  );
  $form['size'] = array(
    '#type' => 'textfield',
    '#title' => t('Size'),
    '#description' => t("Enter the dimensions for the chart. Format: WIDTHxHEIGHT (e.g. 200x100)"),
    '#default_value' => $this->options['size'],
  );

  // Generate label fields
  $label_options = array(
    '' => '< ' . t('No labels') . ' >',
    'default' => t('Default (from data points)'),
  );

  // Generate granularity options
  $yaxis_granularity = $xaxis_granularity = array(
    'auto' => t('Auto generate'),
    'endpoints' => t('Endpoints only'),
  );
  for ($i = 3; $i < 10; $i++) {
    $yaxis_granularity[$i] = t('Granularity: !count ticks', array(
      '!count' => $i,
    ));
  }
  $form['x'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('X Axis'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['x']['label'] = array(
    '#type' => 'select',
    '#options' => $label_options,
    '#title' => t('Labels'),
    '#default_value' => $this->options['x']['label'],
  );
  $form['x']['granularity'] = array(
    '#type' => 'select',
    '#options' => $xaxis_granularity,
    '#title' => t('Granularity'),
    '#default_value' => $this->options['x']['granularity'],
  );
  $form['y'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('Y Axis'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['y']['label'] = array(
    '#type' => 'select',
    '#options' => $label_options,
    '#title' => t('Labels'),
    '#default_value' => $this->options['y']['label'],
  );
  $form['y']['granularity'] = array(
    '#type' => 'select',
    '#options' => $yaxis_granularity,
    '#title' => t('Granularity'),
    '#default_value' => $this->options['y']['granularity'],
  );
  $form['y']['pad'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add headroom above points'),
    '#default_value' => $this->options['y']['pad'],
  );
}