blib/lib/Chart/Timecard.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 25 | 25 | 100.0 |
branch | n/a | ||
condition | 3 | 4 | 75.0 |
subroutine | 4 | 4 | 100.0 |
pod | 1 | 1 | 100.0 |
total | 33 | 34 | 97.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Chart::Timecard; | ||||||
2 | |||||||
3 | 2 | 2 | 834 | use strict; | |||
2 | 4 | ||||||
2 | 71 | ||||||
4 | 2 | 2 | 10 | use warnings; | |||
2 | 4 | ||||||
2 | 67 | ||||||
5 | 2 | 2 | 1804 | use Object::Tiny qw(times size); | |||
2 | 712 | ||||||
2 | 11 | ||||||
6 | |||||||
7 | our $VERSION = '0.02'; | ||||||
8 | |||||||
9 | sub url { | ||||||
10 | 3 | 3 | 1 | 31 | my $self = shift; | ||
11 | |||||||
12 | 3 | 4 | my @times = @{ $self->times }; | ||||
3 | 101 | ||||||
13 | |||||||
14 | 3 | 51 | my $xy = {}; | ||||
15 | 3 | 5 | my (@x, @y, @z); | ||||
16 | |||||||
17 | 3 | 6 | for my $dt (@times) { | ||||
18 | 300 | 2373 | $xy->{ $dt->hour }{ $dt->wday - 1 }++; | ||||
19 | } | ||||||
20 | |||||||
21 | 3 | 26 | for my $day (0..6) { | ||||
22 | 21 | 36 | for my $hour (0..23) { | ||||
23 | 504 | 100 | 1552 | my $size = $xy->{$hour}{$day} || 0; | |||
24 | 504 | 688 | push @x, $hour; | ||||
25 | 504 | 607 | push @y, $day; | ||||
26 | 504 | 698 | push @z, $size; | ||||
27 | } | ||||||
28 | } | ||||||
29 | |||||||
30 | 3 | 6 | local $" = ","; | ||||
31 | 3 | 50 | 91 | my $chart_size = $self->size || "900x300"; | |||
32 | 3 | 378 | return "http://chart.apis.google.com/chart?cht=s&chs=${chart_size}&chxt=x,y&chxl=0:||0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23||1:||Sun|Mon|Tue|Wed|Thu|Fri|Sat|&chm=o,333333,1,1.0,25,0&chds=-1,24,-1,7,0,20&chd=t:@x|@y|@z"; | ||||
33 | } | ||||||
34 | |||||||
35 | 1; | ||||||
36 | |||||||
37 | __END__ |