Skip to content

Commit

Permalink
Get charts and write images to disk (thanks Google) & fixed one chart…
Browse files Browse the repository at this point in the history
… title.
  • Loading branch information
jarofgreen committed Apr 3, 2011
1 parent 98b8b5e commit f47995c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/WriteDayOfWeekData.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,25 @@ public function write() {
$data[$item->getDateTimeAs('D')]++;
}

if (true) {
if (isset($this->configData['graphfile']) && $this->configData['graphfile']) {
$maxCommits = max($data);
$dataArray = $labelArray = array();
foreach($data as $day=>$commits) {
$dataArray[] = intval($commits / $maxCommits * 100);
$labelArray[] = $day;
}
$url = 'http://chart.apis.google.com/chart?cht=bvg&chtt=Hour+Of+Day&chs=220x300&chxt=x&chxl=0:|'.implode('|',$labelArray).'&chd=t:'.implode(',',$dataArray);
$url = 'http://chart.apis.google.com/chart?cht=bvg&chtt=Day+Of+Week&chs=220x300&chxt=x&chxl=0:|'.implode('|',$labelArray).'&chd=t:'.implode(',',$dataArray);

print "URL: $url \n\n";

$ch = curl_init($url);
$fp = fopen($this->configData['graphfile'], "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

}

if (isset($this->configData['file']) && $this->configData['file']) {
Expand Down
12 changes: 11 additions & 1 deletion src/WriteHourOfDayData.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function write() {
$data[intval($item->getDateTimeAs('G'))]++;
}

if (true) {
if (isset($this->configData['graphfile']) && $this->configData['graphfile']) {
$maxCommits = max($data);
$dataArray = $labelArray = array();
foreach($data as $day=>$commits) {
Expand All @@ -38,6 +38,16 @@ public function write() {
$url = 'http://chart.apis.google.com/chart?cht=bvg&chtt=Hour+Of+Day&chs=700x400&chbh=18&chxt=x&chxl=0:|'.implode('|',$labelArray).'&chd=t:'.implode(',',$dataArray);

print "URL: $url \n\n";

$ch = curl_init($url);
$fp = fopen($this->configData['graphfile'], "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);


}

if (isset($this->configData['file']) && $this->configData['file']) {
Expand Down

0 comments on commit f47995c

Please sign in to comment.