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 1466d7b commit c9dd7a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions app/Traits/Charts.php
Expand Up @@ -19,22 +19,22 @@ trait Charts
'values' => [],
];

public function addToDonut($color, $label, $value)
public function addToDonutChart($color, $label, $value)
{
$this->donut['colors'][] = $color;
$this->donut['labels'][] = $label;
$this->donut['values'][] = (int) $value;
}

public function addMoneyToDonut($color, $amount, $description = '')
public function addMoneyToDonutChart($color, $amount, $description = '')
{
$label = money($amount, setting('default.currency'), true)->formatForHumans();

if (!empty($description)) {
$label .= ' - ' . $description;
}

$this->addToDonut($color, $label, $amount);
$this->addToDonutChart($color, $label, $amount);
}

public function getDonutChart($name, $width = '100%', $height = 300, $limit = 10)
Expand Down Expand Up @@ -69,7 +69,7 @@ public function getDonutChart($name, $width = '100%', $height = 300, $limit = 10
return $chart;
}

public function addToBar($color, $label, $value)
public function addToBarChart($color, $label, $value)
{
$this->bar['colors'][] = $color;
$this->bar['labels'][] = $label;
Expand Down Expand Up @@ -209,4 +209,22 @@ public function getLocaleTranslationOfChart(?string $locale = null): array

return $translations;
}

// @deprecated version 3.0.0
public function addToDonut($color, $label, $value)
{
$this->addToDonutChart($color, $label, $value);
}

// @deprecated version 3.0.0
public function addMoneyToDonut($color, $amount, $description = '')
{
$this->addMoneyToDonutChart($color, $amount, $description);
}

// @deprecated version 3.0.0
public function addToBar($color, $label, $value)
{
$this->addToBarChart($color, $label, $value);
}
}
2 changes: 1 addition & 1 deletion app/Widgets/ExpensesByCategory.php
Expand Up @@ -22,7 +22,7 @@ public function show()
$amount += $transaction->getAmountConvertedToDefault();
});

$this->addMoneyToDonut($category->colorHexCode, $amount, $category->name);
$this->addMoneyToDonutChart($category->colorHexCode, $amount, $category->name);
});

$chart = $this->getDonutChart(trans_choice('general.expenses', 2), '100%', 300, 6);
Expand Down

0 comments on commit c9dd7a9

Please sign in to comment.