From 6d3883d48f05c125cb076cdfcda3af3ce18a4d9f Mon Sep 17 00:00:00 2001 From: Bruno Massa <brmassa@67164.no-reply.drupal.org> Date: Fri, 2 Jul 2010 01:02:43 +0000 Subject: [PATCH] Improvements: * Both FusionCharts and OpenFlashCharts removed. Because they never worked correctly, its far better to add them later, with better implementations --- fusioncharts/fusioncharts.inc | 261 --------------------------- fusioncharts/fusioncharts.info | 6 - fusioncharts/fusioncharts.install | 22 --- fusioncharts/fusioncharts.module | 37 ---- openflashchart/openflashchart.inc | 144 --------------- openflashchart/openflashchart.info | 7 - openflashchart/openflashchart.module | 27 --- 7 files changed, 504 deletions(-) delete mode 100644 fusioncharts/fusioncharts.inc delete mode 100644 fusioncharts/fusioncharts.info delete mode 100644 fusioncharts/fusioncharts.install delete mode 100644 fusioncharts/fusioncharts.module delete mode 100644 openflashchart/openflashchart.inc delete mode 100644 openflashchart/openflashchart.info delete mode 100644 openflashchart/openflashchart.module diff --git a/fusioncharts/fusioncharts.inc b/fusioncharts/fusioncharts.inc deleted file mode 100644 index 2a66aa2..0000000 --- a/fusioncharts/fusioncharts.inc +++ /dev/null @@ -1,261 +0,0 @@ -<?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use FusionCharts on your site. - */ - -/** - * Create the values object using FusionCharts - * - * @param $type - * String. The data type. It can be 'category', 'set' or 'trendline' - * @param $data - * Array. The data to be converted to XML - * @param $options - * Array (optional). Data options - * @return - * Array, the XML array - */ -function _fusioncharts_values($type, $data, $options = array()) { - switch ($type) { - case 'category': - $attr = 'label'; - $global_type = 'categories'; - break; - case 'set': - $attr = 'value'; - $global_type = 'dataSet'; - break; - case 'trendline': - $attr = 'value'; - $global_type = 'trendlines'; - break; - } - - // Create each value. - $values = array(); - while (list(, $value) = each($data)) { - if (is_array($value)) { - $values[] = array('key' => $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']['background']; - if (isset($data['#title'])) { - $chart['attributes']['caption'] = $data['#title']; - } - $chart['attributes']['animation'] = '0'; -} - -/** - * Implementation of hook_charts_render(). - * - * Its a Charts module hook. It transform the data into a HTML chart. - * - * @param &$data - * Array. The - */ -function _fusioncharts_charts_render(&$data) { - // Convert the chat TYPE into the FusionCharts way. - // Since its a requirement to build the chart on Google, if the value - // was not found, return nothing and stop the execution. - $options = array( - 'line2D' => 'MSLine.swf', - 'hbar2D' => 'MSBar2D.swf', - 'hbar3D' => 'MSBar3D.swf', - 'vbar2D' => 'MSColumn2D.swf', - 'vbar3D' => 'MSColumn3D.swf', - 'pie2D' => 'Pie2D.swf', - 'pie3D' => 'Pie3D.swf', - ); - if (empty($options[$data['#type']])) { - return t('This type is not possible using %chartplugin', - array('%chartplugin' => 'FusionCharts')); - } - $file = file_create_url('fusioncharts') .'/'. $options[$data['#type']]; - - // Convert the chat SIZE into the FusionCharts way. - // Since its a requirement to build the chart on Google, if the value - // was not found, return nothing and stop the execution. - if (empty($data['#width']) or empty($data['#height'])) { - return ''; - } - $width = $data['#width']; - $height = $data['#height']; - - $chart = array( - 'key' => 'chart', - 'value' => array() - ); - - if ($message = _fusioncharts_chart($chart, $data)) { - return $message; - } - - $series = '_fusioncharts_series'; - if ($data['#type'] == 'pie2D' or $data['#type'] == 'pie3D') { - $series = '_fusioncharts_series_single'; - } - if ($message = $series($chart, $data)) { - return $message; - } - - $chart = '&dataXML='. str_replace('"', "'", format_xml_elements(array($chart))); - - // Its the HTML tag to include the chart - return <<<FUSIONCHARTS -<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="$width" height="$height"> - <param name="allowScriptAccess" value="always" /> - <param name="movie" value="$file" /> - <param name="FlashVars" value="&chartWidth=$width&chartHeight=$height$chart" /> - <param name="quality" value="high" /> - <embed src="$file" flashVars="&chartWidth=$width&chartHeight=$height$chart" width="$width" height="$height" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> -</object> -FUSIONCHARTS; -} - -/** - * 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) { - $series_data = array(); - foreach (element_children($data[$series]) as $values) { - $serie_data = array( - 'value' => $data[$series][$values]['#value'] - ); - if (isset($data[$series][$values]['#label'])) { - $serie_data['label'] = $data[$series][$values]['#label']; - } - $series_data[] = $serie_data; - } - - if (isset($data['#color'][$series])) { - $options['color'] = substr($data['#color'][$series], 1); - } - - $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[] = ''; - $toogle = TRUE; - } - else { - $value_labels[] = $data[$series][$value]['#label']; - $toogle = TRUE; - } - } - if (!empty($toogle) and empty($chart['categories'])) { - $chart['value'][] = _fusioncharts_values('category', $value_labels); - $chart['categories'] = TRUE; - } - } -} - -/** - * 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'][$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); - } - } -} diff --git a/fusioncharts/fusioncharts.info b/fusioncharts/fusioncharts.info deleted file mode 100644 index f74acb5..0000000 --- a/fusioncharts/fusioncharts.info +++ /dev/null @@ -1,6 +0,0 @@ -; $Id$ -core = "6.x" -dependencies[] = charts -description = "Use FusionCharts on your site." -name = "FusionCharts" -package = "Charts" diff --git a/fusioncharts/fusioncharts.install b/fusioncharts/fusioncharts.install deleted file mode 100644 index f59f1e7..0000000 --- a/fusioncharts/fusioncharts.install +++ /dev/null @@ -1,22 +0,0 @@ -<?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Install and unistall functions for this module - */ - -/** - * Implementation of hook_requirements(). - */ -function fusioncharts_requirements($phase) { - $path = file_create_path() .'/fusioncharts'; - if (!file_exists($path .'/MSLine.swf')) { - $requirements['charts']['title'] = t('FusionCharts'); - $requirements['charts']['value'] = t('FusionCharts flash files not installed'); - $requirements['charts']['severity'] = REQUIREMENT_ERROR; - $requirements['charts']['description'] = t('Put all flash files inside %dir.', array('%dir' => $path)); - - return $requirements; - } -} diff --git a/fusioncharts/fusioncharts.module b/fusioncharts/fusioncharts.module deleted file mode 100644 index 03df4ee..0000000 --- a/fusioncharts/fusioncharts.module +++ /dev/null @@ -1,37 +0,0 @@ -<?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use FusionCharts on your site. - * - * @note only hooks are here. - */ - -/** - * Immplementation of hook_charts_info(). - * - * Its a Charts module hook. It defines almost all aspects - * of a chart provider, like its name, what types of charts - * it can perform and what are the restrictions. - */ -function fusioncharts_charts_info() { - return array( - 'fusioncharts' => array( - 'file' => drupal_get_path('module', 'fusioncharts') .'/fusioncharts.inc', - 'name' => t('FusionCharts'), - 'render' => '_fusioncharts_charts_render', - 'types' => array('line2D', 'hbar2D', 'hbar3D', 'vbar2D', 'vbar3D', 'pie2D', 'pie3D'), - ), - ); -} - -/** - * Immplementation of hook_chart_types(). - */ -function fusioncharts_chart_types() { - return array( - 'hbar3D' => t('Horizontal Bar 3D'), - 'vbar3D' => t('Vertical Bar 3D'), - ); -} diff --git a/openflashchart/openflashchart.inc b/openflashchart/openflashchart.inc deleted file mode 100644 index 8788976..0000000 --- a/openflashchart/openflashchart.inc +++ /dev/null @@ -1,144 +0,0 @@ -<?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use Open Flash Chart on your site. - */ - -/** - * Convert all Chart-level data. - * - * @param &$chart - * Object. The Open Flash Chart object - * @param &$data - * Array. The raw data. - */ -function _openflashchart_chart(&$chart, &$data) { - $chart->set_title($data['#title']); - $chart->set_width($data['#width']); - $chart->set_height($data['#height']); - $chart->set_bg_colour($data['#color']['#background']); -} - -/** - * Implementation of hook_charts_render(). - * - * Its a Charts module hook. It transform the data into a HTML chart. - * - * @param &$data - * Array. The - */ -function _openflashchart_charts_render(&$data) { - $chart = new open_flash_chart_api(); - - if ($error = _openflashchart_chart($chart, $data)) { - return $error; - } - - if ($error = _openflashchart_series($chart, $data)) { - return $error; - } - - return $chart->render(); -} - -/** - * Convert all Series-level data. - * - * @param &$chart - * Object. The Open Flash Chart object - * @param &$data - * Array. The raw data. - */ -function _openflashchart_series(&$chart, &$data) { - foreach (element_children($data) as $series) { - // Get the color - $color = empty($data[$series]['#color']) ? '' : $data[$series]['#color']; - - switch ($data['#type']) { - case 'line2D': - $chart->line(1, $color); - break; - - case 'vbar2D': - $chart->bar(75, $color); - break; - - case 'vbar3D': - $chart->bar_3D(75, $color); - break; - - case 'pie2D': - $chart->pie(75, '#000000', 'font-size: 12px;'); - break; - - default: - return t('This type is not possible using %chartplugin', - array('%chartplugin' => 'Open Flash Chart')); - } - - // Insert a new series of values - if ($data['#type'] != 'pie2D') { - _openflashchart_series_generic($chart, $data, $series); - } - elseif (empty($series)) { - _openflashchart_series_pie($chart, $data, $series); - } - } -} - -function _openflashchart_series_generic(&$chart, &$data, $series) { - static $max; - - // Get only the numeric values from the series - $series_data = _charts_series_values($data[$series]); - - $chart->set_data($series_data); - - // Get the highest value on the series, to be a reference point - $max = $max < max($series_data) ? max($series_data) : $max; - - // Y labels - $chart->set_y_max($max); - - // 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->set_x_labels($value_labels); - } -} - -function _openflashchart_series_pie(&$chart, &$data, $series) { - // Get only the numeric values from the series - $series_data = _charts_series_values($data[$series]); - - if (empty($series)) { - // Pieces labels - $value_labels = array(); - foreach (array_keys($series_data) as $value) { - if (empty($data[$series][$value]['#label'])) { - $value_labels[] = ''; - } - else { - $value_labels[] = $data[$series][$value]['#label']; - } - - $color[] = $data[$series][$value]['#color']; - } - - $chart->pie_values($series_data, $value_labels, array()); - - $chart->pie_slice_colours($color); - } -} diff --git a/openflashchart/openflashchart.info b/openflashchart/openflashchart.info deleted file mode 100644 index 244a1a1..0000000 --- a/openflashchart/openflashchart.info +++ /dev/null @@ -1,7 +0,0 @@ -; $Id$ -core = "6.x" -dependencies[] = charts -dependencies[] = open_flash_chart_api -description = "Use Open Flash Charts on your site." -name = "Open Flash Chart" -package = "Charts" diff --git a/openflashchart/openflashchart.module b/openflashchart/openflashchart.module deleted file mode 100644 index c17cc81..0000000 --- a/openflashchart/openflashchart.module +++ /dev/null @@ -1,27 +0,0 @@ -<?php -// $Id$ -/** - * @author Bruno Massa http://drupal.org/user/67164 - * @file - * Use Open Flash Chart on your site. - * - * @note only hooks are here. - */ - -/** - * Immplementation of hook_charts_info(). - * - * Its a Charts module hook. It defines almost all aspects - * of a chart provider, like its name, what types of charts - * it can perform and what are the restrictions. - */ -function openflashchart_charts_info() { - return array( - 'openflashchart' => array( - 'file' => drupal_get_path('module', 'openflashchart') .'/openflashchart.inc', - 'name' => t('Open Flash Chart'), - 'render' => '_openflashchart_charts_render', - 'types' => array('line2D', 'vbar2D', 'vbar3D', 'pie2D'), - ), - ); -} -- GitLab