|
@@ -75,6 +75,7 @@ foreach($charts_b64 as $index => $b64) {
|
|
|
|
|
|
|
|
if($chart->print) {
|
|
if($chart->print) {
|
|
|
// Table
|
|
// Table
|
|
|
|
|
+ if($chart->printTotalColumn) ++$column_count;
|
|
|
|
|
|
|
|
$shape = $slide->createTableShape($column_count)
|
|
$shape = $slide->createTableShape($column_count)
|
|
|
->setWidth(900)
|
|
->setWidth(900)
|
|
@@ -87,6 +88,8 @@ foreach($charts_b64 as $index => $b64) {
|
|
|
|
|
|
|
|
$labels = $chart->getPrintLabels() ?? $chart->getLabels();
|
|
$labels = $chart->getPrintLabels() ?? $chart->getLabels();
|
|
|
|
|
|
|
|
|
|
+ if($chart->printTotalColumn) $labels[] = "Total";
|
|
|
|
|
+
|
|
|
foreach($labels as $label) {
|
|
foreach($labels as $label) {
|
|
|
$cell = $row->nextCell();
|
|
$cell = $row->nextCell();
|
|
|
$cell->getActiveParagraph()->getAlignment()
|
|
$cell->getActiveParagraph()->getAlignment()
|
|
@@ -104,9 +107,15 @@ foreach($charts_b64 as $index => $b64) {
|
|
|
foreach($datasets as $index => $dataset) {
|
|
foreach($datasets as $index => $dataset) {
|
|
|
$label = $dataset->label;
|
|
$label = $dataset->label;
|
|
|
$data = $dataset->data;
|
|
$data = $dataset->data;
|
|
|
|
|
+ $print_data = array_slice($data, 0);
|
|
|
|
|
|
|
|
|
|
+ $total = array_sum($data);
|
|
|
$suffix = $suffixes[$index] ?? "";
|
|
$suffix = $suffixes[$index] ?? "";
|
|
|
|
|
|
|
|
|
|
+ if($chart->printTotalColumn) {
|
|
|
|
|
+ $print_data[] = ($suffix == "%") ? "" : number_format(array_sum($data)) . $suffix;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$row = $shape->createRow();
|
|
$row = $shape->createRow();
|
|
|
$row->setHeight(20);
|
|
$row->setHeight(20);
|
|
|
$cell = $row->nextCell();
|
|
$cell = $row->nextCell();
|
|
@@ -117,7 +126,9 @@ foreach($charts_b64 as $index => $b64) {
|
|
|
->setMarginTop(4);
|
|
->setMarginTop(4);
|
|
|
$cell->createTextRun($label)
|
|
$cell->createTextRun($label)
|
|
|
->getFont()->setBold(true);
|
|
->getFont()->setBold(true);
|
|
|
- foreach($data as $value) {
|
|
|
|
|
|
|
+ foreach($print_data as $value) {
|
|
|
|
|
+ $string = strlen($value) == 0 ? "" : $value . $suffix;
|
|
|
|
|
+
|
|
|
$cell = $row->nextCell();
|
|
$cell = $row->nextCell();
|
|
|
$cell->getActiveParagraph()->getAlignment()
|
|
$cell->getActiveParagraph()->getAlignment()
|
|
|
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
|
|
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
|
|
@@ -125,11 +136,10 @@ foreach($charts_b64 as $index => $b64) {
|
|
|
->setMarginLeft(4)
|
|
->setMarginLeft(4)
|
|
|
->setMarginRight(4)
|
|
->setMarginRight(4)
|
|
|
->setMarginTop(4);
|
|
->setMarginTop(4);
|
|
|
- $cell->createTextRun($value . $suffix);
|
|
|
|
|
|
|
+ $cell->createTextRun($string);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if($chart->printPercentages) {
|
|
if($chart->printPercentages) {
|
|
|
- $total = array_sum($data);
|
|
|
|
|
|
|
|
|
|
$percentages = [];
|
|
$percentages = [];
|
|
|
foreach($data as $value) {
|
|
foreach($data as $value) {
|