Added a better date for some budget charts [skip ci]

This commit is contained in:
James Cole 2015-07-01 11:04:08 +02:00
parent e0d863a46f
commit fdd9eaab4b

View File

@ -17,11 +17,16 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
/**
* @param Collection $entries
* @param string $dateFormat
*
* @return array
*/
public function budget(Collection $entries)
public function budget(Collection $entries, $dateFormat = 'month')
{
// language:
$language = Preferences::get('language', 'en')->data;
$format = Config::get('firefly.' . $dateFormat . '.' . $language);
$data = [
'count' => 1,
'labels' => [],
@ -35,7 +40,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
/** @var array $entry */
foreach ($entries as $entry) {
$data['labels'][] = trans('firefly.spent');
$data['labels'][] = $entry[0]->formatLocalized($format);
$data['datasets'][0]['data'][] = $entry[1];
}
@ -52,7 +57,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
*/
public function budgetLimit(Collection $entries)
{
return $this->budget($entries);
return $this->budget($entries, 'monthAndDay');
}
/**