Commit d0857798 authored by sluc23's avatar sluc23
Browse files

Merge branch 'dev-issue-11' into '2.x'

Fix color differentiation in Pie chart

See merge request !12
parents d5d19387 37039c21
...@@ -20,7 +20,14 @@ class CRM_Reportplus_Utils_ChartJS { ...@@ -20,7 +20,14 @@ class CRM_Reportplus_Utils_ChartJS {
'#166a8f', '#166a8f',
'#00a950', '#00a950',
'#58595b', '#58595b',
'#8549ba' '#8549ba',
'#F0E68C',
'#CD5C5C',
'#4169E1',
'#98FB98',
'#F4A460',
'#FFC0CB',
'#008080',
]; ];
/** /**
...@@ -123,17 +130,22 @@ class CRM_Reportplus_Utils_ChartJS { ...@@ -123,17 +130,22 @@ class CRM_Reportplus_Utils_ChartJS {
private static function pie($rows, $params = []) { private static function pie($rows, $params = []) {
$i = 0; $i = 0;
$colors = [];
$datasets = []; $datasets = [];
foreach ($rows as $yLabel => $row) { foreach ($rows as $yLabel => $row) {
//$color = self::$_colours[$i % (count(self::$_colours))]; foreach ($row as $value) {
$colors[] = self::$_colours[$i];
$i = ($i == count(self::$_colours) - 1) ? 0 : ($i + 1);
}
if ($colors[0] == $colors[count($colors) - 1]) {
$colors[count($colors) - 1] = self::$_colours[1];
}
$datasets[] = [ $datasets[] = [
'label' => $yLabel, 'label' => $yLabel,
//color(window.chartColors.red).alpha(0.5).rgbString(), 'backgroundColor' => $colors,
'backgroundColor' => array_slice(self::$_colours, count(array_values($row))),
'data' => array_values($row), 'data' => array_values($row),
]; ];
$i++;
} }
return $datasets; return $datasets;
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
<url desc="Main Extension Page">https://lab.civicrm.org/extensions/reportplus</url> <url desc="Main Extension Page">https://lab.civicrm.org/extensions/reportplus</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url> <url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls> </urls>
<releaseDate>2021-07-30</releaseDate> <releaseDate>2021-09-03</releaseDate>
<version>2.4.4</version> <version>2.4.5</version>
<develStage>stable</develStage> <develStage>stable</develStage>
<compatibility> <compatibility>
<ver>5.33</ver> <ver>5.33</ver>
</compatibility> </compatibility>
<comments>This is a new, undeveloped module</comments> <comments>ReportPlus extends the default CiviCRM Form's Framework adding new features</comments>
<classloader> <classloader>
<psr4 prefix="Civi\" path="Civi"/> <psr4 prefix="Civi\" path="Civi"/>
</classloader> </classloader>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment