private function formatDataForChart(array $data, \DateTime $minDate = null, \DateTime $maxDate = null)
    {
        $prevDate = $minDate;
        $chartData = [];
        $idx = 0;
        foreach ($data as $value) {
            // Fill in with zeros from previous date till this date
            while ($prevDate !== null && $prevDate < $value['date']) {
                $chartData["c${idx}"] = ['xData' => $prevDate->format('Y-m-d\TH:i:s'), 'yData' => 0];
                $prevDate->add(new \DateInterval('P1D'));
                ++$idx;
            }
            $chartData["c${idx}"] = ['xData' => $value['date']->format('Y-m-d\TH:i:s'), 'yData' => floatval($value['total'])];
            $prevDate = $value['date']->add(new \DateInterval('P1D'));
            ++$idx;
        }
        // Fill in with zeros till maxDate
        while ($prevDate !== null && $maxDate !== null && $maxDate >= $prevDate) {
            $chartData["c${idx}"] = ['xData' => $prevDate->format('Y-m-d\TH:i:s'), 'yData' => 0];
            $prevDate->add(new \DateInterval('P1D'));
            ++$idx;
        }

        return $chartData;
    }
private function formatDataForChart(array $data, \DateTime $minDate = null, \DateTime $maxDate = null)
    {
        $prevDate = $minDate;
        $chartData = [];
        $idx = 0;
        foreach ($data as $value) {
            // Fill in with zeros from previous date till this date
            while ($prevDate !== null && $prevDate < $value['date']) {
                $chartData["c${idx}"] = ['xData' => $prevDate->format('Y-m-d\TH:i:s'), 'yData' => 0];
                $prevDate->add(new \DateInterval('P1D'));
                ++$idx;
            }
            $chartData["c${idx}"] = ['xData' => $value['date']->format('Y-m-d\TH:i:s'), 'yData' => floatval($value['total'])];
            $prevDate = $value['date']->add(new \DateInterval('P1D'));
            ++$idx;
        }
        // Fill in with zeros till maxDate
        while ($prevDate !== null && $maxDate !== null && $maxDate >= $prevDate) {
            $chartData["c${idx}"] = ['xData' => $prevDate->format('Y-m-d\TH:i:s'), 'yData' => 0];
            $prevDate->add(new \DateInterval('P1D'));
            ++$idx;
        }

        return $chartData;
    }
private function formatDataForChart ( array $ data , \ DateTime $ minDate = null , \ DateTime $ maxDate = null ) { $ prevDate = $ minDate ; $ chartData = [ ] ; $ idx = 0 ; foreach ( $ data as $ value ) { // Fill in with zeros from previous date till this date while ( $ prevDate !== null && $ prevDate < $ value [ 'date' ] ) { $ chartData [ "c${idx}" ] = [ 'xData' => $ prevDate -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => 0 ] ; $ prevDate -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } $ chartData [ "c${idx}" ] = [ 'xData' => $ value [ 'date' ] -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => floatval ( $ value [ 'total' ] ) ] ; $ prevDate = $ value [ 'date' ] -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } // Fill in with zeros till maxDate while ( $ prevDate !== null && $ maxDate !== null && $ maxDate >= $ prevDate ) { $ chartData [ "c${idx}" ] = [ 'xData' => $ prevDate -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => 0 ] ; $ prevDate -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } return $ chartData ; }
Formats raw data to the appropriate charts format.

@param array          $data
@param \DateTime|null $minDate
@param \DateTime|null $maxDate

@return array
Formats raw data to the appropriate charts format .