Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added calculation of chart width/height and number of ticks on the y-…

…axis to display
  • Loading branch information...
commit 71570e287d871248a6cb8df1cd5ae289335aeee6 1 parent 6c27cb5
@aurora authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 libs/plugins/gitgraph.class.php
View
11 libs/plugins/gitgraph.class.php
@@ -492,9 +492,14 @@ protected function graph($data, array $types)
$data['deletes'][] = $values['deletes'];
}
+ $cnt = count($data['commits']);
+ $width = min(1000, $cnt * 20);
+ $height = min( 800, $width / 1.2);
+ $ticks = ($height / ($width / $cnt / 1.2));
+
if ($types['commits'] || $types['commits_avg']) {
// render commits
- $chart = new \chart($this->getContext(), 1000, 1000);
+ $chart = new \chart($this->getContext(), $width, $height, array('ticks' => $ticks));
$set = new \chart\dataset('commits', $data['commits']);
$set_avg = $set->getSimpleMovingAverage('commits avg');
@@ -506,7 +511,7 @@ protected function graph($data, array $types)
if ($types['files'] || $types['files_avg']) {
// render files
- $chart = new \chart($this->getContext(), 1000, 1000);
+ $chart = new \chart($this->getContext(), $width, $height, array('ticks' => $ticks));
$set = new \chart\dataset('files', $data['files']);
$set_avg = $set->getSimpleMovingAverage('files avg');
@@ -518,7 +523,7 @@ protected function graph($data, array $types)
if ($types['sloc'] || $types['sloc_avg']) {
// render sloc
- $chart = new \chart($this->getContext(), 1000, 1000);
+ $chart = new \chart($this->getContext(), $width, $height, array('ticks' => $ticks));
$set = new \chart\dataset('sloc', $data['sloc']);
$set_avg = $set->getSimpleMovingAverage('sloc avg');
Please sign in to comment.
Something went wrong with that request. Please try again.