You are here

function _fusioncharts_series_single in Charts 7

Convert all Series-level data.

Parameters

&$chart: Array. The array that will be converted into a string for FusionCharts

&$data: Array. The raw data.

Return value

String. The string presentation of series data

1 string reference to '_fusioncharts_series_single'
_fusioncharts_charts_render in fusioncharts/fusioncharts.inc
Implementation of hook_charts_render().

File

fusioncharts/fusioncharts.inc, line 211
@author Bruno Massa http://drupal.org/user/67164

Code

function _fusioncharts_series_single(&$chart, &$data) {

  // Convert the chat DATA into the FusionCharts way.
  // Since its a requirement to build the chart on FusionCharts, if the value
  // was not found, return nothing and stop the execution.
  foreach (element_children($data) as $series) {
    if (!empty($toogle)) {
      continue;
    }
    $toogle = TRUE;
    foreach (element_children($data[$series]) as $values) {
      $value_labels_temp[] = empty($data[$series][$value]['#label']) ? NULL : $data[$series][$value]['#label'];
      if (is_array($data[$series][$values])) {
        $series_data[] = array(
          'value' => $data[$series][$values]['#value'],
          'label' => $data[$series][$values]['#label'],
          'color' => trim($data['#color'][$values]),
        );
      }
      else {
        $series_data[] = array(
          'value' => $data[$series][$values],
        );
      }
    }
    $options['no_wrap'] = TRUE;
    $options['label'] = TRUE;
    foreach (_fusioncharts_values('set', $series_data, $options) as $set) {
      $chart['value'][] = $set;
    }

    // X labels
    $value_labels = array();
    $toogle = FALSE;
    foreach (array_keys($series_data) as $value) {
      if (empty($data[$series][$value]['#label'])) {
        $value_labels[] = '';
      }
      else {
        $value_labels[] = $data[$series][$value]['#label'];
        $toogle = TRUE;
      }
    }
    if (!empty($toogle)) {
      $chart['value'][] = _fusioncharts_values('category', $value_labels);
    }
  }
}