/** * @param string $date month to display */ private function userdownloads($date) { $usertraffic = $this->log->usertraffic($date); if (!$usertraffic) { $this->nograph($this->getLang('t_usertraffic') . ': no data'); } $tomb = create_function('$in', 'return $in / 1024 /1024;'); $usertraffic = array_map($tomb, $usertraffic); // get work day average if (count($usertraffic)) { $avg = $this->log->avg($usertraffic); // $avg = $avg / 7 *5; //work day average } else { $avg = 0; } arsort($usertraffic); // highest first // limit number of users shown $maxusers = 10; if (count($usertraffic) > $maxusers + 1) { $others = array_slice($usertraffic, $maxusers); $usertraffic = array_slice($usertraffic, 0, $maxusers); $other = 0; foreach ($others as $user => $traffic) { $other += $traffic; } $usertraffic[sprintf($this->getLang('others'), count($others))] = $other; } // prepare the graph datasets $DataSet = new pData(); $DataSet->addPoints(array_values($usertraffic), "traffic"); // setup axis $DataSet->AddPoints(array_keys($usertraffic), 'names'); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries('names'); $DataSet->removeSeries('names'); $DataSet->removeSeriesName('names'); // create the bar graph $Canvas = new GDCanvas(600, 300, false); $Chart = new pChart(600, 300, $Canvas); $Chart->setFontProperties(dirname(__FILE__) . '/../pchart/Fonts/DroidSans.ttf', 8); $Chart->setGraphArea(50, 40, 600, 200); $Chart->drawScale($DataSet, new ScaleStyle(SCALE_NORMAL, new Color(127)), 45, 1, true); $Chart->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription()); //$Chart->drawLegend(500, 40, $DataSet->GetDataDescription(), new Color(250)); $Chart->drawTreshold($avg, new Color(128, 0, 0)); $Chart->setFontProperties(dirname(__FILE__) . '/../pchart/Fonts/DroidSans.ttf', 12); $Chart->drawTitle(10, 10, $this->getLang('t_usertraffic') . ' (MB)', new Color(0), 590, 30); $Chart->Render(null); }
/** * @param string $date month to display */ private function userdownloads($date) { $usertraffic = $this->log->usertraffic($date); $this->listtable($usertraffic, $this->log->sum($usertraffic), $this->getLang('t_usertraffic'), true); }