Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Aug 13, 2022
1 parent 5797de7 commit 1466d7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 54 deletions.
32 changes: 6 additions & 26 deletions app/Widgets/CashFlow.php
Expand Up @@ -34,41 +34,21 @@ public function show()
{
$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);
Expand Down
35 changes: 7 additions & 28 deletions app/Widgets/ProfitLoss.php
Expand Up @@ -31,39 +31,18 @@ public function show()
{
$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,
Expand Down

0 comments on commit 1466d7b

Please sign in to comment.