<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Utils_OpenFlashChart {
/**
- * colours.
+ * Colours.
* @var array
- * @static
*/
private static $_colours = array(
- "#C3CC38", "#C8B935", "#CEA632", "#D3932F",
- "#D9802C", "#FA6900", "#DC9B57", "#F78F01",
- "#5AB56E", "#6F8069", "#C92200", "#EB6C5C",
+ "#C3CC38",
+ "#C8B935",
+ "#CEA632",
+ "#D3932F",
+ "#D9802C",
+ "#FA6900",
+ "#DC9B57",
+ "#F78F01",
+ "#5AB56E",
+ "#6F8069",
+ "#C92200",
+ "#EB6C5C",
);
/**
* Build The Bar Gharph.
*
- * @param array $params assoc array of name/value pairs
+ * @param array $params
+ * Assoc array of name/value pairs.
*
- * @return object $chart object of open flash chart.
- * @static
+ * @return object
+ * $chart object of open flash chart.
*/
- static function &barChart(&$params) {
+ public static function &barChart(&$params) {
$chart = NULL;
if (empty($params)) {
return $chart;
$bars[$barCount]->set_values($yValues);
if ($barCount > 0) {
// FIXME: for bars > 2, we'll need to come out with other colors
- $bars[$barCount]->colour( '#BF3B69');
+ $bars[$barCount]->colour('#BF3B69');
}
if ($barKey = CRM_Utils_Array::value($barCount, CRM_Utils_Array::value('barKeys', $params))) {
- $bars[$barCount]->key($barKey,12);
+ $bars[$barCount]->key($barKey, 12);
}
// call user define function to handle on click event.
$xLabels = new x_axis_labels();
// set_labels function requires xValues array of string or x_axis_label
// so type casting array values to string values
- array_walk($xValues, function(&$value, $index) {
- $value = (string)$value;
- });
+ array_walk($xValues, function (&$value, $index) {
+ $value = (string) $value;
+ });
$xLabels->set_labels($xValues);
// set angle for labels.
/**
* Build The Pie Gharph.
*
- * @param array $params assoc array of name/value pairs
+ * @param array $params
+ * Assoc array of name/value pairs.
*
- * @return object $chart object of open flash chart.
- * @static
+ * @return object
+ * $chart object of open flash chart.
*/
- static function &pieChart(&$params) {
+ public static function &pieChart(&$params) {
$chart = NULL;
if (empty($params)) {
return $chart;
// get the required data.
$values = array();
foreach ($allValues as $label => $value) {
- $values[] = new pie_value((double)$value, $label);
+ $values[] = new pie_value((double) $value, $label);
}
$graphTitle = !empty($params['legend']) ? $params['legend'] : ts('Pie Chart');
/**
* Build The 3-D Bar Gharph.
*
- * @param array $params assoc array of name/value pairs
+ * @param array $params
+ * Assoc array of name/value pairs.
*
- * @return object $chart object of open flash chart.
- * @static
+ * @return object
+ * $chart object of open flash chart.
*/
- static function &bar_3dChart(&$params) {
+ public static function &bar_3dChart(&$params) {
$chart = NULL;
if (empty($params)) {
return $chart;
continue;
}
- $xValueLabels[] = (string)$xVal;
+ $xValueLabels[] = (string) $xVal;
foreach ($criterias as $criteria) {
- $xReferences[$criteria][$xVal] = (double)CRM_Utils_Array::value($criteria, $yVal, 0);
- $yValues[] = (double)CRM_Utils_Array::value($criteria, $yVal, 0);
+ $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
+ $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
}
}
// set colour pattel
$xValues[$count]->set_colour(self::$_colours[$count]);
// define colur pattel with bar criterias
- $xValues[$count]->key((string)$criteria, 12);
+ $xValues[$count]->key((string) $criteria, 12);
// define bar chart values
$xValues[$count]->set_values(array_values($values));
*
* @return array
*/
- static function chart($rows, $chart, $interval) {
+ public static function chart($rows, $chart, $interval) {
$chartData = $dateKeys = array();
switch ($interval) {
foreach ($rows['multiValue'] as $key => $val) {
$graph[$key] = array_combine($dateKeys, $rows['multiValue'][$key]);
}
- $chartData =
- array(
- 'legend' => "$legend " . CRM_Utils_Array::value('legend', $rows, ts('Contribution')) . ' ' . ts('Summary'),
- 'values' => $graph[0],
- 'multiValues' => $graph,
- 'barKeys' => CRM_Utils_Array::value('barKeys', $rows, array()),
- );
+ $chartData = array(
+ 'legend' => "$legend " . CRM_Utils_Array::value('legend', $rows, ts('Contribution')) . ' ' . ts('Summary'),
+ 'values' => $graph[0],
+ 'multiValues' => $graph,
+ 'barKeys' => CRM_Utils_Array::value('barKeys', $rows, array()),
+ );
}
// rotate the x labels.
// carry some chart params if pass.
foreach (array(
- 'xSize', 'ySize', 'divName') as $f) {
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ) as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
*
* @return array
*/
- static function reportChart($rows, $chart, $interval, &$chartInfo) {
+ public static function reportChart($rows, $chart, $interval, &$chartInfo) {
foreach ($interval as $key => $val) {
$graph[$val] = $rows['value'][$key];
}
// carry some chart params if pass.
foreach (array(
- 'xSize', 'ySize', 'divName') as $f) {
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ) as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
}
/**
- * @param $params
+ * @param array $params
* @param $chart
*
* @return array
*/
- static function buildChart(&$params, $chart) {
+ public static function buildChart(&$params, $chart) {
$openFlashChart = array();
if ($chart && is_array($params) && !empty($params)) {
// build the chart objects.
return $openFlashChart;
}
-}
+}