array( 'divider' => 3600, 'count' => 24, 'date_format' => 'H', 'skip_date_name' => 0, 'width' => 770 ), 1 => array( 'divider' => 86400, 'count' => 30, 'date_format' => 'd.m', 'skip_date_name' => 5, 'width' => 770 ) ); $graph_type = isset($_GET['type']) ? abs((int)$_GET['type']) : 0; if ($graph_type >= count($settings)) $graph_type = 0; $divider = $settings[$graph_type]['divider']; $count = $settings[$graph_type]['count']; $date_format = $settings[$graph_type]['date_format']; $graph_width = $settings[$graph_type]['width']; $skip_date_name = $settings[$graph_type]['skip_date_name']; $tine_end = time() - $divider; $time_start = $tine_end - $divider * $count; $sql = "SELECT SUM(`connections`) AS 'connections', SUM(`kills`) AS 'kills', SUM(`infects`) AS 'infects', SUM(`damage`) AS 'damage', (`time` - `time` % $divider) AS 'time' FROM `zp_graph` WHERE `time` >= $time_start AND `time` <= $tine_end GROUP BY (`time` - `time` % $divider)"; $r = mysql_query($sql); $connections = array(); $kills = array(); $infects = array(); $damage = array(); $time = array(); $i = 0; while($row = mysql_fetch_assoc($r)) { $connections[$i] = $row['connections']; $kills[$i] = $row['kills']; $infects[$i] = $row['infects']; $damage[$i] = $row['damage']; if (!$skip_date_name || $i % $skip_date_name == 0) $time[$i] = date($date_format, $row['time']); else $time[$i] = ''; $i++; } $DataSet = new pData; $DataSet->AddPoint($connections,"Connections"); $DataSet->AddPoint($kills,"Kills"); $DataSet->AddPoint($infects,"Infects"); $DataSet->AddPoint($damage,"Damage"); $DataSet->AddPoint($time,"Time"); $DataSet->AddSerie("Connections"); $DataSet->AddSerie("Kills"); $DataSet->AddSerie("Infects"); //$DataSet->AddSerie("Damage"); $DataSet->SetAbsciseLabelSerie("Time"); $DataSet->SetYAxisName("Value"); //$DataSet->SetXAxisName("Time"); //$DataSet->SetYAxisUnit("µs"); $DataSet->SetSerieName($lang->getElementsByTagName("graph_connections")->item(0)->nodeValue,"Connections"); $DataSet->SetSerieName($lang->getElementsByTagName("graph_kills")->item(0)->nodeValue,"Kills"); $DataSet->SetSerieName($lang->getElementsByTagName("graph_infect")->item(0)->nodeValue,"Infects"); $DataSet->SetSerieName($lang->getElementsByTagName("graph_damage")->item(0)->nodeValue,"Damage"); $Cache = new pCache('inc/Cache'); $Cache->GetFromCache("Graph_".$graph_type, $DataSet->GetData()); $Test = new pChart($graph_width, 230); $Test->drawGraphAreaGradient(90, 90, 90, 90, TARGET_BACKGROUND); // Prepare the graph area $Test->setFontProperties("inc/Fonts/tahoma.ttf",8); $Test->setGraphArea(60, 10, $graph_width - 175, 200); // Initialise graph area $Test->setFontProperties("inc/Fonts/tahoma.ttf",8); // Draw the SourceForge Rank graph $DataSet->SetYAxisName($lang->getElementsByTagName("graph_infect")->item(0)->nodeValue .'/'. $lang->getElementsByTagName("graph_kills")->item(0)->nodeValue .'/'. $lang->getElementsByTagName("graph_connections")->item(0)->nodeValue); $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0); $Test->drawGraphAreaGradient(40,40,40,-50); //$Test->drawGrid(4,TRUE,230,230,230,10); $Test->setShadowProperties(3,3,0,0,0,30,4); $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription()); $Test->clearShadow(); //$Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30); //$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); //$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); // Write the legend (box less) $Test->setFontProperties("inc/Fonts/tahoma.ttf",8); $Test->drawLegend($graph_width - 110, 75, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 200, 200, 200, FALSE); // Clear the scale $Test->clearScale(); // Draw the 2nd graph $DataSet->RemoveSerie("Connections"); $DataSet->RemoveSerie("Kills"); $DataSet->RemoveSerie("Infects"); $DataSet->AddSerie("Damage"); $DataSet->SetYAxisName($lang->getElementsByTagName("graph_damage")->item(0)->nodeValue); $Test->drawRightScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0); $Test->drawGrid(4,TRUE,230,230,230,10); $Test->setShadowProperties(3,3,0,0,0,30,4); $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription()); $Test->clearShadow(); //$Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30); //$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); //$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); //$Test->drawFromPNG("templates/$template_dir/img/zombie.png",660,150, 255); $Cache->WriteToCache("Graph_".$graph_type,$DataSet->GetData(),$Test); $Test->Stroke(); ?>