public function FlotTime::buildOptionsForm in Flot 8
Provide a form to edit options for this plugin.
Overrides StylePluginBase::buildOptionsForm
File
- flot_views_time/
src/ Plugin/ views/ style/ FlotTime.php, line 73
Class
- FlotTime
- Style plugin to render dates and values as a bar, scatter, or line chart.
Namespace
Drupal\flot_views_time\Plugin\views\styleCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$handlers = $this->displayHandler
->getHandlers('field');
if (empty($handlers)) {
$form['error_markup'] = array(
'#markup' => '<div class="messages messages--error">' . $this
->t('You need at least one field before you can configure your table settings') . '</div>',
);
return;
}
// Create an array of allowed columns from the data we know:
$field_names = $this->displayHandler
->getFieldLabels();
$number_fields = count($field_names);
$form['#theme'] = 'views_ui_style_plugin_flot_views_table';
$columns['x'] = $this
->sanitizeColumns($this->options['columns']);
$columns['y'] = $columns['x'];
$i = 0;
for ($i = 0; $i < $number_fields - 1; $i++) {
$field = array_slice($field_names, $i, 1);
$field_name = key($field);
$column = $field_names[$field_name];
$form['columns']['x'][$i] = array(
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $field_names,
'#default_value' => $this->options['columns']['x'][$i],
);
$form['columns']['y'][$i] = array(
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $field_names,
'#default_value' => $this->options['columns']['y'][$i],
);
$form['info'][$i]['points'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display Points'),
'#title_display' => 'invisible',
'#default_value' => $this->options['info'][$i]['points'],
];
$form['info'][$i]['lines'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display Lines'),
'#title_display' => 'invisible',
'#default_value' => $this->options['info'][$i]['lines'],
];
$form['info'][$i]['second_axis'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Second Axis'),
'#title_display' => 'invisible',
'#default_value' => isset($this->options['info'][$i]['second_axis']) ? $this->options['info'][$i]['second_axis'] : FALSE,
];
}
}