public static function _getReportChart($report, $start_date, $end_date, $frequency, $decorator = null) { $line_chart = new LineChart(); $line_chart->setTitle($report->getTitle()); $series = new Series(); $temp = ReportPeer::getQueryResults($report->getId(), $start_date, $end_date, $frequency); if (self::isEmpty($temp)) { return null; } $titles = $report->getQueryTitles(); $arrays = ReportPeer::fillWithEmptyValues($temp, $start_date, $end_date, $frequency); for ($i = 0; $i < sizeof($arrays); $i++) { $series->addSerie(new Serie(array_values($arrays[$i]), $titles[$i])); } $factors = Utils::find_factors(sizeof($arrays[0]) - 1, 7); $factor = $factors[sizeof($factors) - 1]; $labels = array(); for ($j = 0; $j < $factor + 1; $j++) { $labels[] = $j + 1; } $temp = array_keys($arrays[0]); for ($j = 0; $j < sizeof($labels); $j++) { if ($frequency == QueryResultPeer::FREQUENCY_MONTH) { $labels[$j] = date('M y', strtotime($temp[$j * (sizeof($arrays[0]) - 1) / $factor])); } else { $labels[$j] = $temp[$j * (sizeof($arrays[0]) - 1) / $factor]; } } $series->setXLabels($labels); $series->autoSetYLabels(5); $series->normalize(); $line_chart->setSeries($series); if ($decorator) { $decorator->decorate($line_chart); } return array('values' => $arrays, 'chart' => $line_chart); }