You are here

public function FrxGraphTemplate::config_form in Forena Reports 6.2

Same name and namespace in other branches
  1. 7.2 templates/FrxGraphTemplate.inc \FrxGraphTemplate::config_form()
  2. 7.3 templates/FrxGraphTemplate.inc \FrxGraphTemplate::config_form()

* Returns the section * Enter description here ...

Overrides FrxTemplate::config_form

File

templates/FrxGraphTemplate.inc, line 4

Class

FrxGraphTemplate

Code

public function config_form($config, $xml = '') {
  $form_ctl = array();
  $graph_types = array(
    'bargraph' => 'Bar Graph',
    'piechart' => 'Pie Chart',
    'linegraph' => 'Line Graph',
    'multilinegraph' => 'Multi Series Line Graph',
    'scatterplot' => 'Scatter Plot',
  );
  $styles = array(
    '' => 'Normal',
    '3D' => '3D',
  );
  if ($config['type'] == 'bargraph') {
    $styles = $styles + array(
      'grouped' => 'Grouped',
      'stacked' => 'Stacked',
      'horizontal' => 'Horizontal',
    );
  }
  switch (@$config['type']) {
    case 'piechart':
    case 'linegraph':
      $num_series = 1;
      $xvalues = FALSE;
      break;
    case 'scatterplot':
      $num_series = 4;
      $xvalues = TRUE;
      break;
    default:
      $xvalues = FALSE;
      $num_series = 4;
  }
  $form_ctl['type'] = array(
    '#type' => 'select',
    '#title' => t('Graph Type'),
    '#options' => $graph_types,
    '#default_value' => $config['type'],
    '#ahah' => array(
      'path' => 'forena/js/template',
      'event' => 'change',
      'method' => 'replace',
      'callback' => 'forena_template_info_callback',
      'wrapper' => 'template-wrapper',
    ),
  );
  $form_ctl['gen_table'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include data table with graph'),
    '#default_value' => $config['gen_table'],
  );
  $form_ctl['style'] = array(
    '#type' => 'select',
    '#title' => t('Style'),
    '#options' => $styles,
    '#disabled' => $config['type'] == 'scatterplot',
    '#default_value' => $config['style'],
  );
  $form_ctl['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => $config['label'],
  );
  $form_ctl['series'] = array(
    '#type' => 'fieldset',
    '#title' => t('Series'),
  );
  if ($xvalues) {
    $form_ctl['seriesx'] = array(
      '#type' => 'fieldset',
      '#title' => t('Series X'),
    );
    $form_ctl['series']['#title'] = t('Series Y');
  }
  for ($i = 0; $i <= $num_series - 1; $i++) {
    if ($xvalues) {
      $form_ctl['seriesx'][$i] = array(
        '#type' => 'textfield',
        '#title' => (string) ($i + 1),
        '#default_value' => $config['seriesx'][$i],
      );
    }
    $form_ctl['series'][$i] = array(
      '#type' => 'textfield',
      '#title' => (string) ($i + 1),
      '#default_value' => $config['series'][$i],
    );
  }
  $form_ctl['link'] = array(
    '#type' => 'textfield',
    '#title' => 'link',
    '#default_value' => $config['link'],
  );
  return $form_ctl;
}