formatting

This commit is contained in:
Denis Duliçi 2022-08-13 17:33:19 +03:00
parent 1466d7b29e
commit c9dd7a9384
2 changed files with 23 additions and 5 deletions

View File

@ -19,14 +19,14 @@ trait Charts
'values' => [], 'values' => [],
]; ];
public function addToDonut($color, $label, $value) public function addToDonutChart($color, $label, $value)
{ {
$this->donut['colors'][] = $color; $this->donut['colors'][] = $color;
$this->donut['labels'][] = $label; $this->donut['labels'][] = $label;
$this->donut['values'][] = (int) $value; $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(); $label = money($amount, setting('default.currency'), true)->formatForHumans();
@ -34,7 +34,7 @@ trait Charts
$label .= ' - ' . $description; $label .= ' - ' . $description;
} }
$this->addToDonut($color, $label, $amount); $this->addToDonutChart($color, $label, $amount);
} }
public function getDonutChart($name, $width = '100%', $height = 300, $limit = 10) public function getDonutChart($name, $width = '100%', $height = 300, $limit = 10)
@ -69,7 +69,7 @@ trait Charts
return $chart; return $chart;
} }
public function addToBar($color, $label, $value) public function addToBarChart($color, $label, $value)
{ {
$this->bar['colors'][] = $color; $this->bar['colors'][] = $color;
$this->bar['labels'][] = $label; $this->bar['labels'][] = $label;
@ -209,4 +209,22 @@ trait Charts
return $translations; 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);
}
} }

View File

@ -22,7 +22,7 @@ class ExpensesByCategory extends Widget
$amount += $transaction->getAmountConvertedToDefault(); $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); $chart = $this->getDonutChart(trans_choice('general.expenses', 2), '100%', 300, 6);