From 1466d7b29ed3daa83840a483cd2be1d4f03800a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Sat, 13 Aug 2022 15:13:25 +0300 Subject: [PATCH] formatting --- app/Widgets/CashFlow.php | 32 ++++++-------------------------- app/Widgets/ProfitLoss.php | 35 +++++++---------------------------- 2 files changed, 13 insertions(+), 54 deletions(-) diff --git a/app/Widgets/CashFlow.php b/app/Widgets/CashFlow.php index f0b3f7ee6..d9b1f9d2d 100644 --- a/app/Widgets/CashFlow.php +++ b/app/Widgets/CashFlow.php @@ -34,41 +34,21 @@ class CashFlow extends Widget { $this->setFilter(); - $labels = $this->getLabels(); - $income = array_values($this->calculateTotals('income')); $expense = array_values($this->calculateTotals('expense')); $profit = array_values($this->calculateProfit($income, $expense)); - $colors = $this->getColors(); - - $options = [ - 'chart' => [ - 'stacked' => true, - ], - 'plotOptions' => [ - 'bar' => [ - 'columnWidth' => '40%', - ], - ], - 'legend' => [ - 'position' => 'top', - ], - 'yaxis' => [ - 'labels' => [ - 'formatter' => $this->getChartLabelFormatter(), - ], - ], - ]; - $chart = new Chart(); $chart->setType('line') - ->setOptions($options) ->setDefaultLocale($this->getDefaultLocaleOfChart()) ->setLocales($this->getLocaleTranslationOfChart()) - ->setLabels(array_values($labels)) - ->setColors($colors) + ->setStacked(true) + ->setBar(['columnWidth' => '40%']) + ->setLegendPosition('top') + ->setYaxisLabels(['formatter' => $this->getChartLabelFormatter()]) + ->setLabels(array_values($this->getLabels())) + ->setColors($this->getColors()) ->setDataset(trans('general.incoming'), 'column', $income) ->setDataset(trans('general.outgoing'), 'column', $expense) ->setDataset(trans_choice('general.profits', 1), 'line', $profit); diff --git a/app/Widgets/ProfitLoss.php b/app/Widgets/ProfitLoss.php index d317df3cf..1e65a6f70 100644 --- a/app/Widgets/ProfitLoss.php +++ b/app/Widgets/ProfitLoss.php @@ -31,39 +31,18 @@ class ProfitLoss extends Widget { $this->setFilter(); - $labels = $this->getLabels(); - - $income = $this->getIncome(); - - $expense = $this->getExpense(); - - $colors = $this->getColors(); - $chart = new Chart(); - $options = [ - 'legend' => [ - 'position' => 'top', - 'markers' => [ - 'radius' => '12', - ], - ], - - 'yaxis' => [ - 'labels' => [ - 'formatter' => $this->getChartLabelFormatter(), - ], - ], - ]; - $chart->setType('bar') - ->setOptions($options) ->setDefaultLocale($this->getDefaultLocaleOfChart()) ->setLocales($this->getLocaleTranslationOfChart()) - ->setLabels(array_values($labels)) - ->setColors($colors) - ->setDataset(trans_choice('general.incomes', 1), 'column', array_values($income)) - ->setDataset(trans_choice('general.expenses', 1), 'column', array_values($expense)); + ->setLegendPosition('top') + ->setLegendMarkers(['radius' => '12']) + ->setYaxisLabels(['formatter' => $this->getChartLabelFormatter()]) + ->setLabels(array_values($this->getLabels())) + ->setColors($this->getColors()) + ->setDataset(trans_choice('general.incomes', 1), 'column', array_values($this->getIncome())) + ->setDataset(trans_choice('general.expenses', 1), 'column', array_values($this->getExpense())); return $this->view('widgets.bar_chart', [ 'chart' => $chart,