public function FrxGraphTemplate::config_form in Forena Reports 7.3
Same name and namespace in other branches
- 6.2 templates/FrxGraphTemplate.inc \FrxGraphTemplate::config_form()
- 7.2 templates/FrxGraphTemplate.inc \FrxGraphTemplate::config_form()
Returns the section Enter description here ...
Overrides FrxTemplate::config_form
File
- templates/
FrxGraphTemplate.inc, line 12
Class
Code
public function config_form($config, $xml = '') {
$form_ctl = array();
$graph_types = array(
'bargraph' => 'Bar Graph',
'linegraph' => 'Line Graph',
'multilinegraph' => 'Line Graph (Multi Series)',
'piechart' => 'Pie Chart',
'radargraph' => 'Radar Graph',
'multiradargraph' => 'Radar Graph (Multi Series)',
'scatterplot' => 'Scatter Plot',
);
$type = isset($config['type']) ? $config['type'] : 'Bar Graph';
$style = isset($config['style']) ? $config['style'] : 'BarGraph';
$graph_options = FrxSVGGraph::graphOptions();
$graph_types = FrxSVGGraph::graphTypes();
$styles = $graph_options['styles'][$type];
$xvalues = @$graph_types[$type]['xaxis'];
$num_series = isset($graph_types[$style]['series']) ? $graph_types[$style]['series'] : 1;
$types = $graph_options['types'];
$form_ctl['type'] = array(
'#type' => 'select',
'#title' => t('Graph Type'),
'#options' => $graph_options['types'],
'#default_value' => $type,
);
forena_template_ajax($form_ctl['type']);
$form_ctl['style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => $styles,
'#default_value' => $style,
);
forena_template_ajax($form_ctl['style']);
$form_ctl['gen_table'] = array(
'#type' => 'checkbox',
'#title' => t('Include data table with graph'),
'#default_value' => @$config['gen_table'],
);
$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'),
'#description' => t('Forena token expression to get the X value (.e.g. {years}'),
);
$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' => check_plain((string) ($i + 1)),
'#default_value' => $config['seriesx'][$i],
'#description' => t('Forena token expressioin for series %s x value. (e.g. {total} )', array(
'%s' => $i + 1,
)),
);
}
$form_ctl['series'][$i] = array(
'#type' => 'textfield',
'#title' => check_plain((string) ($i + 1)),
'#default_value' => @$config['series'][$i],
'#description' => t('Forena token expressioin for series %s. (e.g. {total} )', array(
'%s' => $i + 1,
)),
);
}
$form_ctl['link'] = array(
'#type' => 'textfield',
'#title' => 'link',
'#default_value' => @$config['link'],
);
return $form_ctl;
}