private static function BaseSettings::processBasicForm in Charts 8.4
Same name and namespace in other branches
- 5.0.x src/Element/BaseSettings.php \Drupal\charts\Element\BaseSettings::processBasicForm()
Process form.
Parameters
array $element: The current element.
array $options: Options.
Return value
array The element.
1 call to BaseSettings::processBasicForm()
- BaseSettings::processSettings in src/
Element/ BaseSettings.php - Processes the settings element.
File
- src/
Element/ BaseSettings.php, line 689
Class
- BaseSettings
- Provides a form element for setting a chart.
Namespace
Drupal\charts\ElementCode
private static function processBasicForm(array $element, array $options) {
$element_name = $element['#name'];
$element['yaxis']['inherit'] = [
'#title' => new TranslatableMarkup('Add a secondary y-axis'),
'#type' => 'checkbox',
'#default_value' => $options['yaxis']['inherit'] ?? FALSE,
'#description' => new TranslatableMarkup('Only one additional (secondary) y-axis can be created.'),
];
$element['yaxis']['secondary'] = [
'#title' => new TranslatableMarkup('Secondary vertical axis'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => [
'class' => [
'chart-yaxis',
],
],
'#states' => [
'visible' => [
':input[name="' . $element_name . '[yaxis][inherit]"]' => [
'checked' => TRUE,
],
],
],
];
$element['yaxis']['secondary']['title'] = [
'#title' => new TranslatableMarkup('Custom title'),
'#type' => 'textfield',
'#default_value' => $options['yaxis']['secondary']['title'] ?? '',
];
$element['yaxis']['secondary']['min_max_label'] = [
'#type' => 'html_tag',
'#tag' => 'label',
'#value' => new TranslatableMarkup('Value range'),
];
$element['yaxis']['secondary']['min'] = [
'#type' => 'number',
'#title' => new TranslatableMarkup('Value range minimum'),
'#title_display' => 'invisible',
'#attributes' => [
'placeholder' => new TranslatableMarkup('Minimum'),
],
'#max' => 999999999,
'#size' => 12,
'#suffix' => ' ',
'#default_value' => $options['yaxis']['secondary']['min'] ?? '',
];
$element['yaxis']['secondary']['max'] = [
'#type' => 'number',
'#title' => new TranslatableMarkup('Value range maximum'),
'#title_display' => 'invisible',
'#attributes' => [
'placeholder' => new TranslatableMarkup('Maximum'),
],
'#max' => 999999999,
'#size' => 12,
'#default_value' => $options['yaxis']['secondary']['max'] ?? '',
];
$element['yaxis']['secondary']['prefix'] = [
'#title' => new TranslatableMarkup('Value prefix'),
'#type' => 'textfield',
'#size' => 12,
'#default_value' => $options['yaxis']['secondary']['prefix'] ?? '',
];
$element['yaxis']['secondary']['suffix'] = [
'#title' => new TranslatableMarkup('Value suffix'),
'#type' => 'textfield',
'#size' => 12,
'#default_value' => $options['yaxis']['secondary']['suffix'] ?? '',
];
$element['yaxis']['secondary']['decimal_count'] = [
'#title' => new TranslatableMarkup('Decimal count'),
'#type' => 'number',
'#attributes' => [
'placeholder' => new TranslatableMarkup('auto'),
],
'#max' => 20,
'#min' => 0,
'#size' => 5,
'#description' => new TranslatableMarkup('Enforce a certain number of decimal-place digits in displayed values.'),
'#default_value' => $options['yaxis']['secondary']['decimal_count'] ?? '',
];
$element['yaxis']['secondary']['labels_rotation'] = [
'#title' => new TranslatableMarkup('Labels rotation'),
'#type' => 'select',
'#options' => [
0 => new TranslatableMarkup('0°'),
30 => new TranslatableMarkup('30°'),
45 => new TranslatableMarkup('45°'),
60 => new TranslatableMarkup('60°'),
90 => new TranslatableMarkup('90°'),
],
// This is only shown on inverted charts.
'#attributes' => [
'class' => [
'axis-inverted-show',
],
],
'#default_value' => $options['yaxis']['secondary']['labels_rotation'] ?? '',
];
return $element;
}