You are here

function theme_charts_settings_fields in Charts 7.2

Output the table of field settings within the charts settings form.

File

includes/charts.pages.inc, line 416
Menu callbacks for Charts module.

Code

function theme_charts_settings_fields($variables) {
  $element = $variables['element'];
  $table = array(
    'sticky' => FALSE,
  );
  $table['header'] = array(
    array(
      'data' => t('Field name'),
    ),
    array(
      'data' => t('Provides labels'),
      'class' => array(
        'chart-label-field',
        'checkbox',
      ),
    ),
    array(
      'data' => t('Provides data'),
      'class' => array(
        'chart-data-field',
        'checkbox',
      ),
    ),
    array(
      'data' => t('Color'),
      'class' => array(
        'chart-field-color',
        'checkbox',
      ),
    ),
  );
  foreach ($element['label_field']['#options'] as $field_name => $field_label) {
    $element['label_field'][$field_name]['#title_display'] = 'attribute';
    $element['data_fields'][$field_name]['#title_display'] = 'attribute';
    $element['field_colors'][$field_name]['#title_display'] = 'attribute';
    $row = array();
    $row[] = array(
      'data' => $field_label,
    );
    $row[] = array(
      'data' => drupal_render($element['label_field'][$field_name]),
      'class' => array(
        'chart-label-field',
        'checkbox',
      ),
    );
    $row[] = array(
      'data' => $field_name ? drupal_render($element['data_fields'][$field_name]) : '',
      'class' => array(
        'chart-data-field',
        'checkbox',
      ),
    );
    $row[] = array(
      'data' => $field_name ? drupal_render($element['field_colors'][$field_name]) : '',
      'class' => array(
        'chart-field-color',
        'checkbox',
      ),
    );
    $table['rows'][] = $row;
  }
  $wrapper = array(
    '#title' => t('Chart fields'),
    '#id' => 'chart-fields',
    '#theme_wrappers' => array(
      'form_element',
    ),
    '#markup' => theme('table', $table),
    '#description' => t('Any field may be used to provide labels. Usually this is the first field configured in the view. e.g. Month names, types of content, etc. Subsequent fields typically provide numeric data which can be charted. In some chart types, no label field may be used at all to utilize a continuous axis.'),
  );
  return drupal_render($wrapper);
}