$type, 'attributes' => $value); } else { $values[] = array('key' => $type, 'attributes' => array($attr => $value)); } } // Create the XML array if (empty($options['no_wrap'])) { return array( 'key' => $global_type, 'value' => $values, 'attributes' => $options ); } else { return $values; } } /** * Convert all Chart-level data. * * @param &$chart * Array. The array that will be converted into a string for FusionCharts * @param &$data * Array. The raw data. * @return * String. The string presentation of series data */ function _fusioncharts_chart(&$chart, &$data) { $chart['attributes']['bgColor'] = $data['#color']; $chart['attributes']['caption'] = $data['#title']; } /** * Convert all Series-level data. * * @param &$chart * Array. The array that will be converted into a string for FusionCharts * @param &$data * Array. The raw data. * @return * String. The string presentation of series data */ function _fusioncharts_series(&$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) { foreach (element_children($data[$series]) as $values) { if (is_array($data[$series][$values])) { $series_data[] = array( 'value' => $data[$series][$values]['#value'], 'label' => $data[$series][$values]['#label'], ); } else { $series_data[] = array( 'value' => $data[$series][$values], ); } } $options['color'] = trim($data['#color_palette'][$series]); $chart['value'][] = _fusioncharts_values('set', $series_data, $options); foreach (element_children($data[$series]) as $values) { $value_labels_temp[] = empty($data[$series][$value]['#label']) ? NULL : $data[$series][$value]['#label']; } // 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); } } } /** * Convert all Series-level data. * * @param &$chart * Array. The array that will be converted into a string for FusionCharts * @param &$data * Array. The raw data. * @return * String. The string presentation of series data */ 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_palette'][$series]) ); } 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); } } }