示例#1
0
 protected function draw()
 {
     $this->choosePalette('diem');
     $this->setColorPalette(1, 200, 40, 40);
     $this->setColorPalette(2, 140, 200, 140);
     $this->setColorPalette(0, 40, 60, 200);
     $this->setColorPalette(3, 250, 200, 40);
     $dataSet = new dmChartData();
     $dataSet->AddPoint($this->data['date'], 'date');
     $dataSet->AddPoint($this->data['time'], 'time');
     $dataSet->AddPoint($this->data['nbReq'], 'nbReq');
     $dataSet->AddPoint($this->data['nbErr'], 'nbErr');
     $dataSet->AddPoint($this->data['mem'], 'mem');
     $dataSet->SetSerieName($this->getI18n()->__('Requests per minute'), "nbReq");
     $dataSet->SetSerieName($this->getI18n()->__('Errors per minute'), "nbErr");
     $dataSet->SetSerieName($this->getI18n()->__('Latency in ms'), "time");
     $dataSet->SetSerieName($this->getI18n()->__('Memory used in %'), "mem");
     foreach ($this->eventsFilter as $eventType) {
         $dataSet->AddPoint($this->data['events'][$eventType], $eventType);
     }
     $dataSet->SetSerieName($this->getI18n()->__('Cache cleared'), 'clear cache');
     $dataSet->SetAbsciseLabelSerie('date');
     $dataSet->SetXAxisFormat('date');
     // Prepare the graph area
     $this->setGraphArea(40, 10, $this->getWidth() - 30, $this->getHeight() - 20);
     $this->drawGraphArea(255, 255, 255);
     $dataSet->AddSerie("date");
     $this->clearScale();
     $dataSet->removeAllSeries();
     $dataSet->AddSerie("nbReq");
     $dataSet->AddSerie("nbErr");
     $this->drawRightScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, self::$colors['grey2'][0], self::$colors['grey2'][1], self::$colors['grey2'][2], TRUE, 0, 0, false, 10);
     $this->drawGrid(4, TRUE, self::$colors['grey1'][0], self::$colors['grey1'][1], self::$colors['grey1'][2]);
     $this->drawFilledCubicCurve($dataSet->GetData(), $dataSet->GetDataDescription(), 0.2, 10);
     //    $this->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(), 0.2, 10);
     $this->clearScale();
     $dataSet->removeAllSeries();
     foreach ($this->eventsFilter as $eventType) {
         $dataSet->addSerie($eventType);
     }
     $this->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 0, 0, 0, false);
     $this->drawStackedBarGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 30, false);
     $this->writeValuesOptions($dataSet->GetData(), $dataSet->GetDataDescription(), 'clear cache', array('>' => 0));
     $this->clearScale();
     $dataSet->removeAllSeries();
     $dataSet->AddSerie("mem");
     $maxMem = 64;
     //(int) ini_get('memory_limit')
     $this->setFixedScale(0, $maxMem);
     $this->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 0, 0, 0, false, 0, 0, false, 10);
     $this->drawFilledCubicCurve($dataSet->GetData(), $dataSet->GetDataDescription(), 0.2, 20);
     //    $this->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(), 10);
     $this->clearScale();
     $dataSet->removeAllSeries();
     $dataSet->AddSerie("time");
     $dataSet->SetYAxisName($this->getI18n()->__('Latency in ms'));
     $this->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, self::$colors['grey2'][0], self::$colors['grey2'][1], self::$colors['grey2'][2], TRUE, 0, 0, false, 10);
     $this->drawFilledCubicCurve($dataSet->GetData(), $dataSet->GetDataDescription(), 0.2, 30);
     // Add labels
     //    foreach($this->data['events'] as $event)
     //    {
     //      $this->setLabel($dataSet->GetData(), $dataSet->GetDataDescription(), 'time', $event['time'], $event['msg'], 221,230,174);
     //    }
     // Finish the graph
     $this->drawLegend(45, 5, $dataSet->GetDataDescription(), 255, 255, 255);
 }