|
|
@@ -64,6 +64,11 @@ class Chart {
|
|
|
public $printPercentages = false;
|
|
|
public $printTotalColumn = false;
|
|
|
|
|
|
+ public $numeratorColumnIndex = null;
|
|
|
+ public $denominatorColumnIndex = null;
|
|
|
+
|
|
|
+ public $tableSorter = null;
|
|
|
+
|
|
|
// Static methods
|
|
|
public static function getColourByIndex(int $index): string {
|
|
|
$count = count(self::COLOURS);
|
|
|
@@ -346,6 +351,10 @@ class Chart {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if($this->tableSorter) {
|
|
|
+ usort($data, $this->tableSorter);
|
|
|
+ }
|
|
|
+
|
|
|
foreach($data as $row_index => $columns) {
|
|
|
?>
|
|
|
<tr>
|
|
|
@@ -397,9 +406,22 @@ class Chart {
|
|
|
<th><?=htmlspecialchars(__("Total"))?></th>
|
|
|
<?php
|
|
|
foreach($datasets as $dataset) {
|
|
|
+ $label = $dataset->label;
|
|
|
+
|
|
|
+ $is_percentage = strpos($label, "%");
|
|
|
+ if($is_percentage && $this->numeratorColumnIndex !== null && $this->denominatorColumnIndex !== null) {
|
|
|
+ $numerator_sum = array_sum($datasets[$this->numeratorColumnIndex]->data);
|
|
|
+ $denominator_sum = array_sum($datasets[$this->denominatorColumnIndex]->data);
|
|
|
+
|
|
|
+ $text = number_format(($numerator_sum * 100) / $denominator_sum, 2) . "%";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $text = number_format(array_sum($dataset->data));
|
|
|
+ }
|
|
|
+
|
|
|
?>
|
|
|
<td class="text-right">
|
|
|
- <?=number_format(array_sum($dataset->data))?>
|
|
|
+ <?=$text?>
|
|
|
</td>
|
|
|
<?php
|
|
|
}
|