You are here

function flot_fields_views_plugin_style::axisForm in Flot 7

1 call to flot_fields_views_plugin_style::axisForm()
flot_fields_views_plugin_style::options_form in flot_views/views/flot_fields_views_plugin_style.inc
Provide a form to edit options for this plugin.

File

flot_views/views/flot_fields_views_plugin_style.inc, line 98
Style plugin for views

Class

flot_fields_views_plugin_style
@file Style plugin for views

Code

function axisForm($axis) {
  $form = array();
  $axisname = $axis . 'axis';
  $form['show' . $axisname] = array(
    '#type' => 'checkbox',
    '#title' => t('Show ' . $axis . ' axis'),
    '#default_value' => $this->options['show' . $axisname],
  );
  $form[$axisname] = array(
    '#type' => 'fieldset',
    '#title' => t(drupal_strtoupper($axis) . ' axis settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[name="style_options[show' . $axisname . ']"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  if ($axis == 'y') {
    $label_options = array(
      '' => '< ' . t('No labels') . ' >',
      'default' => t('Default (from fields)'),
    );
    $form[$axisname]['label'] = array(
      '#type' => 'select',
      '#options' => $label_options,
      '#title' => t('Labels'),
      '#default_value' => $this->options[$axisname]['label'],
    );
  }
  $form[$axisname]['position'] = array(
    '#type' => 'select',
    '#title' => t('Position'),
    '#options' => $axis == 'x' ? array(
      'bottom' => t('Bottom'),
      'top' => t('Top'),
    ) : array(
      'left' => t('Left'),
      'right' => t('Right'),
    ),
    '#default_value' => $this->options[$axisname]['position'],
  );
  $form[$axisname]['color'] = array(
    '#type' => 'textfield',
    '#title' => t('Color'),
    '#description' => t('Determines the color of the labels and ticks for
        the axis (default is the grid color). For more fine-grained control
        you can also set the color of the ticks separately with "tickColor"
        (otherwise it\'s autogenerated as the base color with some
        transparency).'),
    '#default_value' => $this->options[$axisname]['color'],
  );
  $form[$axisname]['tickColor'] = array(
    '#type' => 'textfield',
    '#title' => t('Tick color'),
    '#description' => t('Determines the color of the ticks for
        the axis (default is the grid color. If left emtpy the color is
        autogenerated as the base color with some transparency).'),
    '#default_value' => $this->options[$axisname]['tickColor'],
  );
  $form[$axisname]['min'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum'),
    '#description' => t('The precise minimum value on the
        scale. If you don\'t specify this, a value will automatically
        be chosen based on the minimum data value. '),
    '#default_value' => $this->options[$axisname]['min'],
  );
  $form[$axisname]['max'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum'),
    '#description' => t('The precise maximum value on the
        scale. If you don\'t specify this, a value will automatically
        be chosen based on the maximum data value. '),
    '#default_value' => $this->options[$axisname]['max'],
  );
  $form[$axisname]['autoscaleMargin'] = array(
    '#type' => 'textfield',
    '#title' => t('Autoscale margin'),
    '#description' => t('The "autoscaleMargin" is a bit esoteric: it\'s the fraction of margin
        that the scaling algorithm will add to avoid that the outermost points
        ends up on the grid border. Note that this margin is only applied when
        a min or max value is not explicitly set. If a margin is specified,
        the plot will furthermore extend the axis end-point to the nearest
        whole tick. The default value is 0 for the x axes and 0.02 for y
        axes which seems appropriate for most cases.'),
    '#default_value' => $this->options[$axisname]['autoscaleMargin'],
  );

  //ticks
  $axis_granularity = array(
    'auto' => t('Auto generate'),
    'endpoints' => t('Endpoints only'),
  );
  if ($axis == 'y') {
    for ($i = 3; $i < 10; $i++) {
      $axis_granularity[$i] = t('Granularity: !count ticks', array(
        '!count' => $i,
      ));
    }
  }
  $form[$axisname]['granularity'] = array(
    '#type' => 'select',
    '#options' => $axis_granularity,
    '#title' => t('Granularity'),
    '#default_value' => $this->options[$axisname]['granularity'],
  );
  if ($axis == 'y') {
    $form[$axisname]['granularity'] += array(
      '#description' => t('The algorithm always tries to generate reasonably
          round tick values so even if you ask for three ticks, you might get
          five if that fits better with the rounding.'),
    );
  }
  $form[$axisname]['labelWidth'] = array(
    '#type' => 'textfield',
    '#title' => t('Label width'),
    '#description' => t('Specifies a fixed width of the tick labels in pixels.'),
    '#default_value' => $this->options[$axisname]['labelWidth'],
  );
  $form[$axisname]['labelHeight'] = array(
    '#type' => 'textfield',
    '#title' => t('Label height'),
    '#description' => t('Specifies a fixed height of the tick labels in pixels.'),
    '#default_value' => $this->options[$axisname]['labelHeight'],
  );
  return $form;
}