1, 'labels' => [], 'datasets' => [ [ 'label' => 'Diff', 'data' => [], ], ], ]; $sum = '0'; foreach ($set as $entry) { $date = new Carbon($entry->date); $sum = bcadd($sum, $entry->sum); $data['labels'][] = $date->formatLocalized($format); $data['datasets'][0]['data'][] = round($sum, 2); } return $data; } }