* Colours.
* @var array
*/
- private static $_colours = array(
+ private static $_colours = [
"#C3CC38",
"#C8B935",
"#CEA632",
"#6F8069",
"#C92200",
"#EB6C5C",
- );
+ ];
/**
* Build The Bar Gharph.
return $chart;
}
if (empty($params['multiValues'])) {
- $params['multiValues'] = array($params['values']);
+ $params['multiValues'] = [$params['values']];
}
$values = CRM_Utils_Array::value('multiValues', $params);
// get the required data.
$chartTitle = !empty($params['legend']) ? $params['legend'] : ts('Bar Chart');
- $xValues = $yValues = array();
+ $xValues = $yValues = [];
$xValues = array_keys($values[0]);
$yValues = array_values($values[0]);
}
$ySteps = $yMax / 5;
- $bars = array();
+ $bars = [];
$config = CRM_Core_Config::singleton();
$symbol = $config->defaultCurrencySymbol;
foreach ($values as $barCount => $barVal) {
}
// get the required data.
- $values = array();
+ $values = [];
foreach ($allValues as $label => $value) {
$values[] = new pie_value((double) $value, $label);
}
}
// get the required data.
- $xReferences = $xValueLabels = $xValues = $yValues = array();
+ $xReferences = $xValueLabels = $xValues = $yValues = [];
foreach ($values as $xVal => $yVal) {
if (!is_array($yVal) || empty($yVal)) {
public static function chart($rows, $chart, $interval) {
$lcInterval = strtolower($interval);
$label = ucfirst($lcInterval);
- $chartData = $dateKeys = array();
- $intervalLabels = array(
+ $chartData = $dateKeys = [];
+ $intervalLabels = [
'year' => ts('Yearly'),
'fiscalyear' => ts('Yearly (Fiscal)'),
'month' => ts('Monthly'),
'quarter' => ts('Quarterly'),
'week' => ts('Weekly'),
'yearweek' => ts('Weekly'),
- );
+ ];
switch ($lcInterval) {
case 'month':
list($year, $month) = explode('-', $val);
$dateKeys[] = $year;
}
- $legend = ts("%1", array(1 => $label));
+ $legend = ts("%1", [1 => $label]);
if (!empty($intervalLabels[$lcInterval])) {
$legend = $intervalLabels[$lcInterval];
}
}
if (!empty($dateKeys)) {
- $graph = array();
+ $graph = [];
if (!array_key_exists('multiValue', $rows)) {
- $rows['multiValue'] = array($rows['value']);
+ $rows['multiValue'] = [$rows['value']];
}
foreach ($rows['multiValue'] as $key => $val) {
$graph[$key] = array_combine($dateKeys, $rows['multiValue'][$key]);
}
- $chartData = array(
+ $chartData = [
'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()),
- );
+ 'barKeys' => CRM_Utils_Array::value('barKeys', $rows, []),
+ ];
}
// rotate the x labels.
$chartData['yname'] = CRM_Utils_Array::value('yname', $rows);
// carry some chart params if pass.
- foreach (array(
- 'xSize',
- 'ySize',
- 'divName',
- ) as $f) {
+ foreach ([
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
$graph[$val] = $rows['value'][$key];
}
- $chartData = array(
+ $chartData = [
'values' => $graph,
'legend' => $chartInfo['legend'],
'xname' => $chartInfo['xname'],
'yname' => $chartInfo['yname'],
- );
+ ];
// rotate the x labels.
$chartData['xLabelAngle'] = CRM_Utils_Array::value('xLabelAngle', $chartInfo, 20);
}
// carry some chart params if pass.
- foreach (array(
- 'xSize',
- 'ySize',
- 'divName',
- ) as $f) {
+ foreach ([
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
* @return array
*/
public static function buildChart(&$params, $chart) {
- $openFlashChart = array();
+ $openFlashChart = [];
if ($chart && is_array($params) && !empty($params)) {
// build the chart objects.
$chartObj = CRM_Utils_OpenFlashChart::$chart($params);
- $openFlashChart = array();
+ $openFlashChart = [];
if ($chartObj) {
// calculate chart size.
$xSize = CRM_Utils_Array::value('xSize', $params, 400);
// generate unique id for this chart instance
$uniqueId = md5(uniqid(rand(), TRUE));
- $openFlashChart["chart_{$uniqueId}"]['size'] = array('xSize' => $xSize, 'ySize' => $ySize);
+ $openFlashChart["chart_{$uniqueId}"]['size'] = ['xSize' => $xSize, 'ySize' => $ySize];
$openFlashChart["chart_{$uniqueId}"]['object'] = $chartObj;
// assign chart data to template