Index: chart.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/chart.module,v
retrieving revision 1.14
diff -u -r1.14 chart.module
--- chart.module 14 Jul 2009 02:25:29 -0000 1.14
+++ chart.module 14 Jul 2009 02:44:40 -0000
@@ -1,20 +1,22 @@
-* @package Chart
-*/
-
+// $Id$
/**
-* Misc
-*/
+ * @file
+ * Provides Google chart API integration.
+ *
+ * @author Tj Holowaychuk
+ * @author Jimmy Berry ("boombatower", http://drupal.org/user/214218)
+ * @package Chart
+ */
+
+/*
+ * Misc
+ */
define('CHART_URI', 'http://chart.apis.google.com/chart');
-/**
-* Chart types
-*/
+/*
+ * Chart types.
+ */
define('CHART_TYPE_LINE', 'lc');
define('CHART_TYPE_LINE_XY', 'lxy');
define('CHART_TYPE_BAR_H', 'bhs');
@@ -28,9 +30,9 @@
define('CHART_TYPE_MAP', 't');
define('CHART_TYPE_GMETER', 'gom');
-/**
-* Marker types
-*/
+/*
+ * Marker types.
+ */
define('CHART_MARKER_ARROW', 'a');
define('CHART_MARKER_CROSS', 'c');
define('CHART_MARKER_DIAMOND', 'd');
@@ -41,44 +43,42 @@
define('CHART_MARKER_HORIZONTAL_LINE', 'h');
define('CHART_MARKER_X', 'x');
-/**
-* Axis
-*/
+/*
+ * Axis.
+ */
define('CHART_AXIS_X_BOTTOM', 'x');
define('CHART_AXIS_X_TOP', 't');
define('CHART_AXIS_Y_LEFT', 'y');
define('CHART_AXIS_Y_RIGHT', 'r');
/**
-* Alignment
-*/
+ * Alignment.
+ */
define('CHART_ALIGN_LEFT', -1);
define('CHART_ALIGN_CENTER', 0);
define('CHART_ALIGN_RIGHT', 1);
-/* -----------------------------------------------------------------
-
- Hook Implementations
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Hook Implementations
+ *------------------------------------------------------------------*/
/**
-* Implementation of hook_perm();
-*/
+ * Implementation of hook_perm();
+ */
function chart_perm() {
return array('administer chart');
}
/**
-* Implementation of hook_init().
-*/
+ * Implementation of hook_init().
+ */
function chart_init() {
_chart_color_schemes(TRUE);
}
/**
-* Implementation of hook_menu().
-*/
+ * Implementation of hook_menu().
+ */
function chart_menu() {
$items = array();
@@ -92,24 +92,22 @@
return $items;
}
-/* -----------------------------------------------------------------
-
- Public API
-
------------------------------------------------------------------- */
-
-/**
-* Renders a chart structure.
-*
-* @param array $chart
-*
-* @param array $attributes
-* (optional) Assoc array of attributes parsed by drupal_attributes();
-*
-* @return mixed
-* - Success: Chart image markup
-* - Failure: FALSE
-*/
+/*-----------------------------------------------------------------
+ * Public API
+ *------------------------------------------------------------------*/
+
+/**
+ * Renders a chart structure.
+ *
+ * @param array $chart
+ *
+ * @param array $attributes
+ * (optional) Assoc array of attributes parsed by drupal_attributes();
+ *
+ * @return mixed
+ * - Success: Chart image markup
+ * - Failure: FALSE
+ */
function chart_render($chart, $attributes = array()) {
if ($chart_query_string = chart_build($chart)){
$attributes['id'] = 'chart-' . $chart['#chart_id'];
@@ -127,14 +125,14 @@
}
/**
-* Returns the chart URL.
-*
-* @param array $chart
-*
-* @return mixed
-* - Success: Chart image markup
-* - Failure: FALSE
-*/
+ * Returns the chart URL.
+ *
+ * @param array $chart
+ *
+ * @return mixed
+ * - Success: Chart image markup
+ * - Failure: FALSE
+ */
function chart_url($chart) {
if ($chart_query_string = chart_build($chart)){
return CHART_URI . '?' . $chart_query_string;
@@ -146,27 +144,27 @@
/**
-* Copies rendered chart image.
-*
-* @param array $chart
-* Chart API structure
-*
-* @param string $name
-* (optional) Filename WITHOUT extension.
-* when NULL #chart_id is used.
-*
-* @param string $dest
-* (optional) A string containing the path to verify. If this value is
-* omitted, Drupal's 'files/charts' directory will be used.
-*
-* @param string $replace
-* (optional) Replace behavior when the destination file already exists.
-* - FILE_EXISTS_REPLACE: Replace the existing file
-* - FILE_EXISTS_RENAME: Appends _{incrementing number} until the filename is unique
-* - FILE_EXISTS_ERROR: Do nothing and return FALSE.
-*
-* @return bool
-*/
+ * Copies rendered chart image.
+ *
+ * @param array $chart
+ * Chart API structure
+ *
+ * @param string $name
+ * (optional) Filename WITHOUT extension.
+ * when NULL #chart_id is used.
+ *
+ * @param string $dest
+ * (optional) A string containing the path to verify. If this value is
+ * omitted, Drupal's 'files/charts' directory will be used.
+ *
+ * @param string $replace
+ * (optional) Replace behavior when the destination file already exists.
+ * - FILE_EXISTS_REPLACE: Replace the existing file
+ * - FILE_EXISTS_RENAME: Appends _{incrementing number} until the filename is unique
+ * - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *
+ * @return bool
+ */
function chart_copy($chart, $name = NULL, $dest = 'charts', $replace = FILE_EXISTS_REPLACE) {
if (!$chart_query_string = chart_build($chart)){
return FALSE;
@@ -199,35 +197,35 @@
}
/**
-* Build chart query string.
-*
-* @param array $chart
-*
-* REQUIRED
-* #chart_id
-* #type
-* #data
-*
-* OPTIONAL
-* #title
-* #size
-* #legends
-* #labels
-* #adjust_resolution
-* #line_styles
-* #grid_lines
-* #shape_markers
-* #data_colors
-* #chart_fill
-* #mixed_axis_labels
-* #mixed_axis_label_styles
-* #bar_size
-* #countries
-* #georange
-*
-* @return mixed
-* Query string or FALSE on failure.
-*/
+ * Build chart query string.
+ *
+ * @param array $chart
+ *
+ * REQUIRED
+ * #chart_id
+ * #type
+ * #data
+ *
+ * OPTIONAL
+ * #title
+ * #size
+ * #legends
+ * #labels
+ * #adjust_resolution
+ * #line_styles
+ * #grid_lines
+ * #shape_markers
+ * #data_colors
+ * #chart_fill
+ * #mixed_axis_labels
+ * #mixed_axis_label_styles
+ * #bar_size
+ * #countries
+ * #georange
+ *
+ * @return mixed
+ * Query string or FALSE on failure.
+ */
function chart_build($chart) {
static $charts;
@@ -307,15 +305,13 @@
return $charts[$chart['#chart_id']];
}
-/* -----------------------------------------------------------------
-
- Page Callbacks
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Page Callbacks
+ *------------------------------------------------------------------*/
/**
-* Settings form page callback handler.
-*/
+ * Settings form page callback handler.
+ */
function chart_settings() {
$form = array();
@@ -350,8 +346,8 @@
/**
-* Implementation of hook_validate();
-*/
+ * Implementation of hook_validate();
+ */
function chart_settings_validate($form, &$form_state) {
if (!empty($form_state['values']['chart_global_bg']) && !preg_match('/[a-fA-F0-9]{6}/is', $form_state['values']['chart_global_bg'])){
form_set_error('chart_global_bg', t('Invalid color. Formatted as RRGGBB with no pound sign.'));
@@ -364,20 +360,18 @@
}
}
-/* -----------------------------------------------------------------
-
- Helpers
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Helpers
+ *------------------------------------------------------------------*/
/**
-* Encode an array of data.
-*
-* Missing data placeholder 'NULL' is replaced
-* the appropriate placeholder.
-*
-* @return string
-*/
+ * Encode an array of data.
+ *
+ * Missing data placeholder 'NULL' is replaced
+ * the appropriate placeholder.
+ *
+ * @return string
+ */
function _chart_encode_data($data) {
$output = '';
if (count($data)){
@@ -401,10 +395,10 @@
}
/**
-* Adjusts chart data transforming values so that they may
-* be represented properly within the given resolution
-* for the selected encoding type.
-*/
+ * Adjusts chart data transforming values so that they may
+ * be represented properly within the given resolution
+ * for the selected encoding type.
+ */
function _chart_adjust_resolution($chart_id, &$data, $max_value = NULL) {
static $max;
@@ -455,9 +449,9 @@
}
/**
-* When the value passed is valid append a chart API
-* attribute and parsed values to $data.
-*/
+ * When the value passed is valid append a chart API
+ * attribute and parsed values to $data.
+ */
function _chart_append($attr, $value, &$data) {
// Size and fill contain defaults, all other attributes must be set
if (!$value && $attr != 'chs' && $attr != 'chf'){
@@ -684,8 +678,8 @@
}
/**
-* Return the max value of a single level array.
-*/
+ * Return the max value of a single level array.
+ */
function _chart_get_max($array) {
rsort($array, SORT_NUMERIC);
$max = is_array($array[0]) ? 1 : $array[0];
@@ -705,8 +699,8 @@
}
/**
-* Override the default chart aspect ratio.
-*/
+ * Override the default chart aspect ratio.
+ */
function _chart_override_aspect(&$width, &$height) {
$decrement = 20;
$max_width = variable_get('chart_max_width', FALSE);
@@ -733,8 +727,8 @@
}
/**
-* Admin error.
-*/
+ * Admin error.
+ */
function _chart_error($message, $admin = TRUE) {
if ($admin){
if (user_access('administer chart')){
@@ -747,8 +741,8 @@
}
/**
-* Check if chart data is below size limit.
-*/
+ * Check if chart data is below size limit.
+ */
function _chart_is_valid_size($size) {
if (!is_numeric($size['#width']) && !is_numeric($size['#height'])){
return FALSE;
@@ -762,9 +756,9 @@
}
/**
-* Invoke chart_color_schemes(); hook to gather available schemes.
-* When $init is FALSE the color schemes gathered are returned.
-*/
+ * Invoke chart_color_schemes(); hook to gather available schemes.
+ * When $init is FALSE the color schemes gathered are returned.
+ */
function _chart_color_schemes($init = FALSE) {
static $colors;
@@ -807,23 +801,21 @@
}
}
-/* -----------------------------------------------------------------
-
- Label Utils
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Label Utils
+ *------------------------------------------------------------------*/
/**
-* Title
-*
-* @param string $title
-*
-* @param string $color
-*
-* @param int $size
-*
-* @return array
-*/
+ * Title
+ *
+ * @param string $title
+ *
+ * @param string $color
+ *
+ * @param int $size
+ *
+ * @return array
+ */
function chart_title($title, $color = '000000', $size = 14) {
return array(
'#title' => $title,
@@ -833,29 +825,29 @@
}
/**
-* Create a mixed axis label.
-*
-* Labels must be nested by axis and index:
-* @code
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Monday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Tuesday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Wednesday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_range_label(0, 50);
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Min'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Max'));
-* @endcode
-*
-* @param mixed $label
-* - string: A single label
-* - array: An array of label strings, or an assoc array containing #label and #position
-*
-* @param int $position
-* (optional) An integer between 0 - 100 representing where the label should appear along the axis.
-* 0 representing bottom and left, 100 representing top and right. When one label within a given set
-* is given a position, the remaining labels in the set must have a position.
-*
-* @return array
-*/
+ * Create a mixed axis label.
+ *
+ * Labels must be nested by axis and index:
+ * @code
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Monday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Tuesday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Wednesday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_range_label(0, 50);
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Min'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Max'));
+ * @endcode
+ *
+ * @param mixed $label
+ * - string: A single label
+ * - array: An array of label strings, or an assoc array containing #label and #position
+ *
+ * @param int $position
+ * (optional) An integer between 0 - 100 representing where the label should appear along the axis.
+ * 0 representing bottom and left, 100 representing top and right. When one label within a given set
+ * is given a position, the remaining labels in the set must have a position.
+ *
+ * @return array
+ */
function chart_mixed_axis_label($label, $position = NULL) {
return array(
'#label' => $label,
@@ -864,24 +856,24 @@
}
/**
-* Create a mixed axis range label.
-*
-* Labels must be nested by axis and index:
-* @code
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Monday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Tuesday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Wednesday'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_range_label(0, 50);
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Min'));
-* $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Max'));
-* @endcode
-*
-* @param string $start
-*
-* @param string $end
-*
-* @return array
-*/
+ * Create a mixed axis range label.
+ *
+ * Labels must be nested by axis and index:
+ * @code
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Monday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Tuesday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('Wednesday'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_range_label(0, 50);
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Min'));
+ * $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][2][] = chart_mixed_axis_label(t('Max'));
+ * @endcode
+ *
+ * @param string $start
+ *
+ * @param string $end
+ *
+ * @return array
+ */
function chart_mixed_axis_range_label($start, $end) {
return array(
'#start' => $start,
@@ -890,21 +882,21 @@
}
/**
-* Create a mixed axis for a corresponding label set index.
-*
-* @param int $index
-*
-* @param string $color
-*
-* @param int $font_size
-*
-* @param int $alignment
-* - CHART_ALIGN_LEFT
-* - CHART_ALIGN_CENTER
-* - CHART_ALIGN_RIGHT
-*
-* @return array
-*/
+ * Create a mixed axis for a corresponding label set index.
+ *
+ * @param int $index
+ *
+ * @param string $color
+ *
+ * @param int $font_size
+ *
+ * @param int $alignment
+ * - CHART_ALIGN_LEFT
+ * - CHART_ALIGN_CENTER
+ * - CHART_ALIGN_RIGHT
+ *
+ * @return array
+ */
function chart_mixed_axis_label_style($index, $color, $font_size = 12, $alignment = CHART_ALIGN_CENTER) {
return array(
'#index' => $index,
@@ -914,17 +906,15 @@
);
}
-/* -----------------------------------------------------------------
-
- Style Utils
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Style Utils
+ *------------------------------------------------------------------*/
/**
-* Chart size
-*
-* @return array
-*/
+ * Chart size
+ *
+ * @return array
+ */
function chart_size($width, $height) {
return array(
'#width' => $width,
@@ -933,27 +923,27 @@
}
/**
-* Data Colors
-*
-* @param array $colors
-*
-* @return array
-*/
+ * Data Colors
+ *
+ * @param array $colors
+ *
+ * @return array
+ */
function chart_data_colors($colors) {
return $colors;
}
/**
-* Line Style
-*
-* @param int $line_thickness
-*
-* @param int $segment_length
-*
-* @param int $blank_segment_length
-*
-* @return array
-*/
+ * Line Style
+ *
+ * @param int $line_thickness
+ *
+ * @param int $segment_length
+ *
+ * @param int $blank_segment_length
+ *
+ * @return array
+ */
function chart_line_style($line_thickness = 1, $segment_length = 1, $blank_segment_length = 0) {
return array(
'#line_thickness' => $line_thickness,
@@ -963,22 +953,22 @@
}
/**
-* Grid Lines
-*
-* @param int $x_step
-* Space in pixels in which to step the horizontal lines.
-*
-* @param int $y_step
-* Space in pixels in which to step the virtical lines.
-*
-* @param int $segment_length
-* (optional) Visibile segment length in pixels.
-*
-* @param int $blank_segment_length
-* (optional) Blank segment length in pixels.
-*
-* @return array
-*/
+ * Grid Lines
+ *
+ * @param int $x_step
+ * Space in pixels in which to step the horizontal lines.
+ *
+ * @param int $y_step
+ * Space in pixels in which to step the virtical lines.
+ *
+ * @param int $segment_length
+ * (optional) Visibile segment length in pixels.
+ *
+ * @param int $blank_segment_length
+ * (optional) Blank segment length in pixels.
+ *
+ * @return array
+ */
function chart_grid_lines($x_step, $y_step, $segment_length = 1, $blank_segment_length = 3) {
return array(
'#x_step' => $x_step,
@@ -989,33 +979,33 @@
}
/**
-* Shape Marker
-*
-* @param int $index
-* (optional) The index of the line on which to draw the marker.
-*
-* @param float $point
-* (optional) Floating point value that specifies on which data point
-* the marker will be drawn.
-*
-* @param string $type
-* - CHART_MARKER_ARROW
-* - CHART_MARKER_CROSS
-* - CHART_MARKER_DIAMOND
-* - CHART_MARKER_CIRCLE
-* - CHART_MARKER_SQUARE
-* - CHART_MARKER_VIRTICAL_LINE_X
-* - CHART_MARKER_VIRTICAL_LINE_TOP
-* - CHART_MARKER_HORIZONTAL_LINE
-* - CHART_MARKER_X
-*
-* @param int $size
-* (optional) Marker size in pixels.
-*
-* @param string $color
-*
-* @return array
-*/
+ * Shape Marker
+ *
+ * @param int $index
+ * (optional) The index of the line on which to draw the marker.
+ *
+ * @param float $point
+ * (optional) Floating point value that specifies on which data point
+ * the marker will be drawn.
+ *
+ * @param string $type
+ * - CHART_MARKER_ARROW
+ * - CHART_MARKER_CROSS
+ * - CHART_MARKER_DIAMOND
+ * - CHART_MARKER_CIRCLE
+ * - CHART_MARKER_SQUARE
+ * - CHART_MARKER_VIRTICAL_LINE_X
+ * - CHART_MARKER_VIRTICAL_LINE_TOP
+ * - CHART_MARKER_HORIZONTAL_LINE
+ * - CHART_MARKER_X
+ *
+ * @param int $size
+ * (optional) Marker size in pixels.
+ *
+ * @param string $color
+ *
+ * @return array
+ */
function chart_shape_marker($index = 0, $point = 0, $type = 'o', $size = 20, $color = '000000') {
return array(
'#type' => $type,
@@ -1027,18 +1017,18 @@
}
/**
-* Range Marker
-*
+ * Range Marker
+ *
* @param int $start
-*
-* @param int $end
-*
-* @param bool $virtical
-*
-* @param string $color
-*
-* @return array
-*/
+ *
+ * @param int $end
+ *
+ * @param bool $virtical
+ *
+ * @param string $color
+ *
+ * @return array
+ */
function chart_range_marker($start, $end, $virtical = TRUE, $color = '000000') {
return array(
'#start' => $start,
@@ -1049,16 +1039,16 @@
}
/**
-* Bar chart bar sizing.
-*
-* @param int $size
-* (optional) Height or width of the bar.
-*
-* @param int $spacing
-* (optional) Pixel spacing between bars.
-*
-* @return array
-*/
+ * Bar chart bar sizing.
+ *
+ * @param int $size
+ * (optional) Height or width of the bar.
+ *
+ * @param int $spacing
+ * (optional) Pixel spacing between bars.
+ *
+ * @return array
+ */
function chart_bar_size($size = 40, $spacing = 20) {
return array(
'#size' => $size,
@@ -1067,15 +1057,15 @@
}
/**
-* Solid Fill
-*
-* @param int $type
-* (optional) 'bg' or 'c'
-*
-* @param string $color
-*
-* @return array
-*/
+ * Solid Fill
+ *
+ * @param int $type
+ * (optional) 'bg' or 'c'
+ *
+ * @param string $color
+ *
+ * @return array
+ */
function chart_fill($type = 'c', $color = '000000') {
return array(
'#type' => $type,
@@ -1085,19 +1075,19 @@
}
/**
-* Linear Gradient
-*
-* @param int $type
-* (optional) 'bg' or 'c'
-*
-* @param int $color
-*
-* @param int $offset
-* (optional) Cpecify at what point the color is pure where: 0 specifies the right-most
-* chart position and 1 the left-most.
-*
-* @return array
-*/
+ * Linear Gradient
+ *
+ * @param int $type
+ * (optional) 'bg' or 'c'
+ *
+ * @param int $color
+ *
+ * @param int $offset
+ * (optional) Cpecify at what point the color is pure where: 0 specifies the right-most
+ * chart position and 1 the left-most.
+ *
+ * @return array
+ */
function chart_linear_gradient($type = 'c', $color = '000000', $offset = 0) {
return array(
'#type' => $type,
@@ -1107,22 +1097,22 @@
}
/**
-* Linear Stripes
-*
-* @param int $type
-* (optional) 'bg' or 'c'
-*
-* @param int $color
-*
-* @param int $angle
-* (optional) Specifies the angle of the gradient between 0 (horizontal) and 90 (vertical).
-*
-* @param float $width
-* (optional) Must be between 0 and 1 where 1 is the full width of the chart. Stripes are
-* repeated until the chart is filled.
-*
-* @return array
-*/
+ * Linear Stripes
+ *
+ * @param int $type
+ * (optional) 'bg' or 'c'
+ *
+ * @param int $color
+ *
+ * @param int $angle
+ * (optional) Specifies the angle of the gradient between 0 (horizontal) and 90 (vertical).
+ *
+ * @param float $width
+ * (optional) Must be between 0 and 1 where 1 is the full width of the chart. Stripes are
+ * repeated until the chart is filled.
+ *
+ * @return array
+ */
function chart_linear_stripes($type = 'c', $color = '000000', $angle = 0, $width = 0.25) {
return array(
'#type' => $type,
@@ -1133,28 +1123,26 @@
);
}
-/* -----------------------------------------------------------------
-
- Color Schemes
-
------------------------------------------------------------------- */
-
-/**
-* Supplies a unique color.
-*
-* When an assoc array color scheme is provided
-* $content_id can be used to sync the color to
-* the data rendered. Otherwise the next available
-* color in the stack is assigned to $content_id
-*
-* @param string $content_id
-*
-* @param string $scheme
-* (optional) Color scheme.
-*
-* @return string
-* hex RGB value
-*/
+/*-----------------------------------------------------------------
+ * Color Schemes
+ *------------------------------------------------------------------*/
+
+/**
+ * Supplies a unique color.
+ *
+ * When an assoc array color scheme is provided
+ * $content_id can be used to sync the color to
+ * the data rendered. Otherwise the next available
+ * color in the stack is assigned to $content_id
+ *
+ * @param string $content_id
+ *
+ * @param string $scheme
+ * (optional) Color scheme.
+ *
+ * @return string
+ * hex RGB value
+ */
function chart_unique_color($content_id, $scheme = 'default') {
static $colors_used;
$colors = _chart_color_schemes();
Index: contrib/system_charts/system_charts.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/contrib/system_charts/system_charts.module,v
retrieving revision 1.10
diff -u -r1.10 system_charts.module
--- contrib/system_charts/system_charts.module 14 Jul 2009 02:28:58 -0000 1.10
+++ contrib/system_charts/system_charts.module 14 Jul 2009 02:44:40 -0000
@@ -1,28 +1,27 @@
* @package Chart
*/
-/* -----------------------------------------------------------------
-
- Hook Implementations
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Hook Implementations
+ *------------------------------------------------------------------*/
/**
-* Implementation of hook_perm();
-*/
+ * Implementation of hook_perm();
+ */
function system_charts_perm(){
return array('administer system charts', 'access system charts');
}
/**
-* Implementation of hook_menu().
-*/
+ * Implementation of hook_menu().
+ */
function system_charts_menu() {
$items = array();
@@ -58,8 +57,8 @@
}
/**
-* Implementation of hook_chart_color_schemes();
-*/
+ * Implementation of hook_chart_color_schemes();
+ */
function system_charts_chart_color_schemes(&$colors) {
$colors['watchdog_severity'] = array(
'Error' => 'a00000',
@@ -75,18 +74,18 @@
------------------------------------------------------------------ */
/**
-* Page callback.
-*/
+ * Page callback.
+ */
function system_charts($page = 'nodes') {
return '
' . system_charts_display($page) . '
';
}
/**
-* Display charts and content in context to the current page.
-*
-* @return string
-* markup, chart images.
-*/
+ * Display charts and content in context to the current page.
+ *
+ * @return string
+ * markup, chart images.
+ */
function system_charts_display($page = 'nodes') {
$output = '';
@@ -113,11 +112,11 @@
}
/**
-* Gather data and build a chart API structure.
-*
-* @return array
-* chart API structure.
-*/
+ * Gather data and build a chart API structure.
+ *
+ * @return array
+ * chart API structure.
+ */
function system_charts_build($type) {
$chart = array();
$now = (isset($_GET['year']) && isset($_GET['month'])) ? mktime(0, 0, 0, $_GET['month'], 30, $_GET['year']) : time();
@@ -307,11 +306,11 @@
}
/**
-* Get available report page information.
-*
-* @return array
-* report information.
-*/
+ * Get available report page information.
+ *
+ * @return array
+ * report information.
+ */
function system_charts_get_page_info() {
return array(
'nodes' => array(
@@ -332,15 +331,13 @@
);
}
-/* -----------------------------------------------------------------
-
- Helpers
-
------------------------------------------------------------------- */
+/*-----------------------------------------------------------------
+ * Helpers
+ *------------------------------------------------------------------*/
/**
-* Return the watchdog severity label
-*/
+ * Return the watchdog severity label
+ */
function _system_charts_watchdog_severity_label($severity) {
switch($severity){
case WATCHDOG_NOTICE:
@@ -358,8 +355,8 @@
}
/**
-* Return user status label
-*/
+ * Return user status label
+ */
function _system_charts_user_status_label($status) {
return $status ? t('Active') : t('Blocked') ;
}