9 print "Usage: git chart\n";
16 print "Gathering data ...\n";
18 my $day=$options->{from};
19 my $to =$options->{to};
20 my $step=$options->{step};
21 my $max=$options->{max} || 0;
24 my $next = $day + $step;
25 my $val = `git log --pretty=%s --since="$next days ago" --until="$day days ago" | wc -l`;
28 $max = $val if $max < $val;
32 $options->{max} = $max;
39 # plot the dataset with google chart. the function can be called with either one or two parameters.
40 # when called with two parameters, the first is assumed to be the dataset, and the second the options
41 # (array and hash ref respectively).
42 # when called with a single parameter, it is assumed to be an options hash ref, and the dataset is
43 # created by calling gather_data with the passed options.
44 sub google_chart($;$) {
47 if (! defined $options) {
49 $dataset = gather_data($options);
52 my $height=$options->{chart_height};
53 my $max = $options->{max};
54 my $from = $options->{from};
55 my $to = $options->{to};
56 my $step = $options->{step};
57 my $width=($step < 20 ? 20 : $step)*@$dataset;
59 my $url="https://chart.googleapis.com/chart?chs=${width}x${height}&cht=bvg&chd=t:%s&chds=0,$max&chbh=a&chxt=y,x&chxr=0,0,$max|1,$to,$from,-$step";
61 my $launch = sprintf $url, join(",",reverse @$dataset);
62 # print $launch, "\n";
63 `git web--browse "$launch"`
68 if ($from =~/^\d+$/) {
72 warn "non-numeric from not supported yet\n";
82 warn "non-numeric to not supported yet\n";
88 if ($step =~/^\d+$/) {
91 return 1 if $step eq 'daily';
92 return 7 if $step eq 'weekly';
93 return 30 if $step eq 'monthly';
116 monthly => \$monthly,
122 $options{from} = parse_from($from) if $from;
125 $options{to} = $options{from} + 365;
128 $options{to} = $options{from} + 6*30;
131 $options{to} = $options{from} + 31;
135 $options{to} = parse_to($to) if $to;
136 $options{step} = parse_step($step) if $step;
138 die "step must be strictly positive!" unless $options{step} > 0;
140 google_chart(\%options);