Exemplo n.º 1
0
 public function fill(Gpf_Chart_Labels $labels, array $data)
 {
     foreach ($labels->getLabels() as $label) {
         if (array_key_exists($label, $data)) {
             $this->addValue((int) $data[$label]);
             continue;
         }
         $this->addValue(0);
     }
 }
    private function buildChart() {
        $chart = new Gpf_Rpc_Chart();
        $chart->setChartType($this->chartType);
        $labels = new Gpf_Chart_Labels($this->statsParameters->getDateFrom(), $this->statsParameters->getDateTo(), $this->timeGroupBy);
        $chart->setLabels($labels->getLabels());

        $computer = $this->dataType1->getComputer($this->statsParameters, $this->timeGroupBy);
        $computer->computeStats();
        $chartData = $this->createChartData($this->dataType1, $chart->getLineColor(1));
        $chartData->fill($labels, $computer->getResult());
        $chart->addData1Recordset($chartData);

        if ($this->dataType2 !== null) {
            $computer = $this->dataType2->getComputer($this->statsParameters, $this->timeGroupBy);
            $computer->computeStats();
            $chartData = $this->createChartData($this->dataType2, $chart->getLineColor(2));
            $chartData->fill($labels, $computer->getResult());
            $chart->addData2Recordset($chartData);
        }
        return $chart;
    }