function flot_handler_field_datapoint::options_form in Flot 6
Same name and namespace in other branches
- 7 flot_views/views/flot_handler_field_datapoint.inc \flot_handler_field_datapoint::options_form()
Options form.
File
- views/
flot_handler_field_datapoint.inc, line 24
Class
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['series'] = array(
'#tree' => TRUE,
'#collapsible' => TRUE,
'#type' => 'fieldset',
'#title' => t('Series (X axis)'),
);
$form['series']['field'] = array(
'#title' => t('Field'),
'#type' => 'select',
'#options' => array(),
'#default_value' => $this->options['series']['field'],
);
$form['value'] = array(
'#tree' => TRUE,
'#collapsible' => TRUE,
'#type' => 'fieldset',
'#title' => t('Series (Y axis)'),
);
$form['value']['field'] = array(
'#title' => t('Field'),
'#type' => 'select',
'#options' => array(),
'#default_value' => $this->options['value']['field'],
);
// Get field options and generate subsequent options based on class
foreach (views_fetch_fields($this->view->base_table, 'field') as $field_id => $field_info) {
$form['series']['field']['#options'][$field_id] = !empty($field_info['title']) ? $field_info['title'] : $field_id;
$form['value']['field']['#options'][$field_id] = !empty($field_info['title']) ? $field_info['title'] : $field_id;
list($table, $field) = explode('.', $field_id);
$handler = get_class(views_get_handler($table, $field, 'field'));
if (strpos($handler, '_date') !== FALSE) {
// If the series field is empty, use a date by default
$form['series']['field']['#default_value'] = empty($form['series']['field']['#default_value']) ? $field_id : $form['series']['field']['#default_value'];
if (!isset($form['series']['grouping'])) {
$form['series']['grouping'] = array(
'#title' => t('Group dates by'),
'#type' => 'select',
'#options' => array(
'Y-m-d-H' => t('Hour'),
'Y-m-d-3' => t('3 hours'),
'Y-m-d-6' => t('6 hours'),
'Y-m-d-A' => t('12 hours'),
'Y-m-d' => t('Day'),
'Y-m' => t('Month'),
'Y' => t('Year'),
),
'#process' => array(
'views_process_dependency',
),
'#dependency' => array(),
'#default_value' => $this->options['series']['grouping'],
);
$form['series']['date_format'] = array(
'#title' => t('Date format'),
'#type' => 'select',
'#options' => array(
'small' => format_date(time(), 'small'),
'medium' => format_date(time(), 'medium'),
'large' => format_date(time(), 'large'),
),
'#process' => array(
'views_process_dependency',
),
'#dependency' => array(),
'#default_value' => $this->options['series']['date_format'],
);
}
// Add this field to the list of timestamp options which trigger the grouping field display.
$form['series']['grouping']['#dependency']['edit-options-series-field'][] = $field_id;
$form['series']['date_format']['#dependency']['edit-options-series-field'][] = $field_id;
}
}
$form['value']['format'] = array(
'#title' => t('Format'),
'#type' => 'select',
'#options' => array(
'raw' => t('Raw value'),
'count' => t('Count'),
),
'#default_value' => $this->options['value']['format'],
);
}