$ydata2[$i] = 0; $i = 1; $xdata[$i] = $i; $xlabel[$i] = $month . "-" . $day + 1; $ydata1[$i] = 0; $ydata2[$i] = 0; $i = 2; } $graph = new Graph(600, 350); $graph->addDebug("We appended {$i} rows of data to the graphing set."); $graph->addDebug("{$begin_time}"); $graph->addDebug("{$sql}"); $data1 = $graph->AddData($xdata, $ydata1, $xlabel); $data2 = $graph->AddData($xdata, $ydata2, $xlabel); $graph->DrawGrid('gray'); $graph->LineGraph($data1, 'red'); $graph->LineGraph($data2, 'blue'); $pm = ProjectManager::instance(); $graph->SetTitle("Codendi Statistics: " . util_unconvert_htmlspecialchars($pm->getProject($group_id)->getPublicName())); $graph->SetSubTitle("Page Views (red) and Downloads (blue) for the past {$i} days"); $graph->SetxTitle('Date'); $graph->SetyTitle('Views (red) / Downloads (blue)'); $graph->DrawAxis(); //$graph->showDebug(); // If PHP3 then assume GD library < 1.6 with only GIF Support // if PHP4 then we have GD library >= 1.6 with only PNG Support if (substr(phpversion(), 0, 1) == "3") { $graph->ShowGraph('gif'); } else { $graph->ShowGraph('png'); }
// require you to be a member of the super-admin group session_require(array('group' => '1', 'admin_flags' => 'A')); $request = HTTPRequest::instance(); $group_id = $request->getValidated('group_id', 'GroupId'); if (!$group_id) { $group_id = 0; } $year = $request->getValidated('year', 'uint'); if (!$year) { $year = gmstrftime("%Y", time()); } $sql = "SELECT month,day,site_views,subdomain_views FROM stats_site ORDER BY month ASC, day ASC"; $res = db_query($sql); $i = 0; while ($row = db_fetch_array($res)) { $xdata[$i] = $i; $xlabel[$i] = substr($row['month'], 4) + 1 - 1 . "/" . $row['day']; $ydata1[$i] = $row["site_views"] + $row["subdomain_views"]; ++$i; } $graph = new Graph(750, 550); $data1 = $graph->AddData($xdata, $ydata1, $xlabel); $graph->DrawGrid('gray'); $graph->LineGraph($data1, 'red'); $graph->SetTitle("Codendi Page Views"); $graph->SetSubTitle("Page Views (RED) since beginning of time ( {$i} days )"); $graph->SetxTitle('Date'); $graph->SetyTitle('Views (RED)'); $graph->DrawAxis(); //$graph->showDebug(); $graph->ShowGraph('png');
// Need at least 2 data points // if ($i == 0) { $xdata[0] = 0; $xlabel[0] = ""; $ydata1[0] = 0; $ydata2[0] = 0; $xdata[1] = 1; $xlabel[1] = ""; $ydata1[1] = 0; $ydata2[1] = 0; } if ($i == 1) { $xdata[1] = 1; $xlabel[1] = $xlabel[0]; $ydata1[1] = $ydata1[0]; $ydata2[1] = $ydata2[0]; } $graph = new Graph(750, 550); $data1 = $graph->AddData($xdata, $ydata1, $xlabel); $data2 = $graph->AddData($xdata, $ydata2, $xlabel); $graph->DrawGrid('gray'); $graph->LineGraph($data1, 'red'); $graph->LineGraph($data2, 'blue'); $graph->SetTitle(_('New Additions, by Day')); $graph->SetSubTitle(_('New Users (RED), New Projects (BLUE)')); $graph->SetxTitle(_('Date')); $graph->SetyTitle(_('Users (RED) / Projects (BLUE)')); $graph->DrawAxis(); //$graph->showDebug(); $graph->ShowGraph('png');