1, 'labels' => [], 'datasets' => [[ 'label' => trans('firefly.spent'), 'data' => []]]]; foreach ($accounts as $account) { if ($account->difference > 0) { $data['labels'][] = $account->name; $data['datasets'][0]['data'][] = $account->difference; } } return $data; } /** * @param Collection $accounts * @param Carbon $start * @param Carbon $end * * @return array */ public function frontpage(Collection $accounts, Carbon $start, Carbon $end): array { // language: $format = (string)trans('config.month_and_day'); $data = ['count' => 0, 'labels' => [], 'datasets' => [],]; $current = clone $start; while ($current <= $end) { $data['labels'][] = $current->formatLocalized($format); $current->addDay(); } foreach ($accounts as $account) { $data['datasets'][] = [ 'label' => $account->name, 'fillColor' => 'rgba(220,220,220,0.2)', 'strokeColor' => 'rgba(220,220,220,1)', 'pointColor' => 'rgba(220,220,220,1)', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => 'rgba(220,220,220,1)', 'data' => $account->balances, ]; } $data['count'] = count($data['datasets']); return $data; } /** * @param Account $account * @param array $labels * @param array $dataSet * * @return array */ public function single(Account $account, array $labels, array $dataSet): array { $data = [ 'count' => 1, 'labels' => $labels, 'datasets' => [ [ 'label' => $account->name, 'data' => $dataSet, ], ], ]; return $data; } }