You are here

function flot_views_plugin_style::options_form in Flot 6

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

File

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'),
    ),
    '#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++) {
    $xaxis_granularity[$i] = t('Granularity: !count ticks', array(
      '!count' => $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'],
  );

  // Views
  $layers = $this
    ->get_views_by_style();
  unset($layers["{$this->view->name}:{$this->view->current_display}"]);
  $form['layers'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Additional data layers'),
    '#description' => t('Display the selected views displays as additional layers.'),
    '#options' => $layers,
    '#default_value' => $this->options['layers'],
  );
}