You are here

public function FrxSVGGraph::configForm in Forena Reports 7.4

Returns the section Enter description here ...

Overrides FrxRenderer::configForm

File

renderers/FrxSVGGraph.inc, line 497

Class

FrxSVGGraph

Code

public function configForm($config) {
  $graph_options = FrxSVGGraph::graphOptions();
  $graph_types = FrxSVGGraph::graphTypes();
  $gt = array_change_key_case($graph_types);
  $type = @$config['style'];
  if (!isset($config['base_type'])) {
    $base_type = $type ? $gt[strtolower($type)]['type'] : 'Bar Graph';
  }
  else {
    $base_type = $config['base_type'];
  }
  $styles = $graph_options['styles'][$base_type];
  $form = parent::configForm($config);
  $form['base_type'] = array(
    '#type' => 'select',
    '#title' => t('Graph Type'),
    '#options' => $graph_options['types'],
    '#default_value' => $base_type,
    '#ajax' => $this
      ->configAjax(),
  );
  $form['style'] = array(
    '#type' => 'select',
    '#title' => t('Style'),
    '#options' => $styles,
    '#default_value' => $type,
    '#ajax' => $this
      ->configAjax(),
  );
  $form['gen_table'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include data table with graph'),
    '#default_value' => @$config['gen_table'],
    '#ajax' => $this
      ->configAjax(),
  );
  $this
    ->weight_sort($config['crosstab_columns']);
  $types = array(
    'heading' => t('Label'),
    'crosstab' => t('Crosstab'),
    'value' => 'Value',
    'ignore' => t('Ignore'),
  );
  $form['crosstab_columns'] = array(
    '#theme' => 'forena_element_draggable',
    '#draggable_id' => 'FrxCrosstab-columns',
  );
  foreach ($config['crosstab_columns'] as $key => $col) {
    $ctl = array();
    $ctl['label'] = array(
      '#type' => 'textfield',
      '#size' => 30,
      '#title' => t('Label'),
      '#default_value' => $col['label'],
    );
    $ctl['contents'] = array(
      '#type' => 'textfield',
      '#size' => '30',
      '#title' => t('Data'),
      '#default_value' => $col['contents'],
    );
    $ctl['type'] = array(
      '#type' => 'radios',
      '#title' => t('Type'),
      '#default_value' => $col['type'],
      '#options' => $types,
      '#ajax' => $this
        ->configAjax(),
    );
    $ctl['weight'] = array(
      "#type" => 'weight',
      '#title' => t('Weight'),
      '#delta' => 50,
      '#default_value' => $col['weight'],
    );
    $form['crosstab_columns'][$key] = $ctl;
  }
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Graph Label'),
    '#default_value' => @$config['label'],
  );
  $form['link'] = array(
    '#type' => 'textfield',
    '#title' => t('Link Url'),
    '#default_value' => @$config['link'],
  );
  $form['legend_entries'] = array(
    '#type' => 'textfield',
    '#title' => t('Legend'),
    '#default_value' => @$config['legend_entries'],
  );
  $form['tooltip'] = array(
    '#type' => 'textfield',
    '#title' => t('Tool Tip'),
    '#default_value' => @$config['tooltip'],
  );
  return $form;
}