From 4ca4fdba7319752e51a77e24cd2170c5b988dc3d Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Fri, 24 Jun 2022 18:54:56 +0300 Subject: [PATCH] label formatter added for Report charts --- app/Abstracts/Report.php | 22 ++++++++++++++++++++-- app/Widgets/CashFlow.php | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/Abstracts/Report.php b/app/Abstracts/Report.php index 6821fe204..a934ff32f 100644 --- a/app/Abstracts/Report.php +++ b/app/Abstracts/Report.php @@ -14,6 +14,7 @@ use App\Exports\Common\Reports as Export; use App\Models\Common\Report as Model; use App\Models\Document\Document; use App\Models\Setting\Category; +use App\Traits\Charts; use App\Traits\DateTime; use App\Traits\SearchString; use App\Traits\Translations; @@ -23,7 +24,7 @@ use Illuminate\Support\Str; abstract class Report { - use DateTime, SearchString, Translations; + use Charts, DateTime, SearchString, Translations; public $model; @@ -60,9 +61,19 @@ abstract class Report 'colors' => [ '#6da252', ], + + 'yaxis' => [ + 'labels' => [ + 'formatter' => '', + ], + ], ], 'donut' => [ - // + 'yaxis' => [ + 'labels' => [ + 'formatter' => '', + ], + ], ], ]; @@ -100,6 +111,7 @@ abstract class Report $this->setRows(); $this->loadData(); $this->setColumnWidth(); + $this->setChartLabelFormatter(); $this->loaded = true; } @@ -284,6 +296,12 @@ abstract class Report $this->column_name_width = $this->column_value_width = $width; } + public function setChartLabelFormatter() + { + $this->chart['bar']['yaxis']['labels']['formatter'] = $this->getFormatLabel(); + $this->chart['donut']['yaxis']['labels']['formatter'] = $this->getFormatLabel('percent'); + } + public function setYear() { $this->year = $this->getSearchStringValue('year', Date::now()->year); diff --git a/app/Widgets/CashFlow.php b/app/Widgets/CashFlow.php index b9054ad1e..5825e7ff6 100644 --- a/app/Widgets/CashFlow.php +++ b/app/Widgets/CashFlow.php @@ -55,8 +55,8 @@ class CashFlow extends Widget 'position' => 'top', ], 'yaxis' => [ - 'labels' => [ - 'formatter' => $this->getFormatLabel(), + 'labels' => [ + 'formatter' => $this->getFormatLabel(), ], ], ];