From b9a4e9c8a68dcb6b17617f4f7a5ad5ad3298bfa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 9 Mar 2016 22:05:38 +0100 Subject: Imported Upstream version 1.7.1 --- lib/gcstar/GCStats.pm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'lib/gcstar/GCStats.pm') diff --git a/lib/gcstar/GCStats.pm b/lib/gcstar/GCStats.pm index 439c6d1..4cf18a8 100644 --- a/lib/gcstar/GCStats.pm +++ b/lib/gcstar/GCStats.pm @@ -66,6 +66,7 @@ BEGIN { { my ($self, $items, $sort, $type, $useNumbers) = @_; my %stats; + $self->{yMax} = 0; foreach my $item(@$items) { if (ref($item) eq 'ARRAY') @@ -94,7 +95,9 @@ BEGIN { $val = $key; $val .= ' ('.$stats{$key}.')' if $useNumbers; push @val1, $val; - push @val2, $stats{$key}; + my $stat = $stats{$key}; + push @val2, $stat; + $self->{yMax} = $stat if $stat > $self->{yMax}; } $self->{data} = [\@val1, \@val2]; } @@ -155,6 +158,7 @@ BEGIN { $_ += $prev; $prev = $_; } + $self->{yMax} = $prev; } # Transform dates into numbers of days # Reference is the 1st one as they are ordered @@ -171,6 +175,7 @@ BEGIN { @refDate = Date::Calc::Add_Delta_Days(@refDate, -1); $self->{data}->[0]->[0] = sprintf('%d/%02d/%02d', @refDate); } + @refDate = GCPreProcess::completePartialDate(@refDate); my $prev = -1; my @newDates; my $dateFormat = $self->{parent}->{options}->dateFormat; @@ -183,6 +188,7 @@ BEGIN { next; } my @cmpDate = split m|/|, $date; + @cmpDate = GCPreProcess::completePartialDate(@cmpDate); my $diff = Date::Calc::Delta_Days(@refDate, @cmpDate); if ($diff > $prev + 1) { @@ -245,8 +251,9 @@ BEGIN { l_margin => 20, r_margin => 20, text_space => 20, + y_max_value => $self->{yMax}, + y_number_format => "%d", ); - my $gd = $graph->plot($self->{data}); # Now, resample the graph down to the desired size, effectively anti-aliasing the sharp edges @@ -300,6 +307,15 @@ BEGIN { $self->{accumulateOption}->setValue(1); $self->{useNumberOption} = new GCCheckBox($parent->{lang}->{StatsDisplayNumber}); $self->{useNumberOption}->setValue(0); + + $self->{groupDatesByChoices} = [ + {value => 'days', displayed => 'Days'}, + {value => 'months', displayed => 'Months'}, + {value => 'years', displayed => 'Years'}, + ]; + $self->{groupDatesByOption} = new GCMenuList($self->{groupDatesByChoices}); + $self->{groupDatesByOption}->setValue('days'); + my $groupDatesByLabel = new GCLabel('Group dates by'); my $widthLabel = new GCLabel($parent->{lang}->{StatsWidth}); $self->{widthOption} = new GCCheckedText('0-9'); @@ -334,6 +350,8 @@ BEGIN { $table->attach($self->{sortByNumberOption}, 3, 5, 1, 2, 'fill', 'fill', 0, 0); $table->attach($self->{accumulateOption}, 3, 5, 1, 2, 'fill', 'fill', 0, 0); $table->attach($self->{useNumberOption}, 6, 8, 1, 2, 'fill', 'fill', 0, 0); + $table->attach($groupDatesByLabel, 9, 10, 1, 2, 'fill', 'fill', 0, 0); + $table->attach($self->{groupDatesByOption}, 10, 11, 1, 2, 'fill', 'fill', 0, 0); $self->{image} = Gtk2::Image->new; @@ -412,6 +430,7 @@ BEGIN { my $accumulate = $self->{accumulateOption}->getValue; my $useNumber = ($graphType =~ /pie/) && $self->{useNumberOption}->getValue; my $showValues = ($graphType !~ /pie/) && $self->{useNumberOption}->getValue; + my $groupDatesBy = $self->{groupDatesByOption}->getValue; my $width = $self->{widthOption}->getValue; my $height = $self->{heightOption}->getValue; my $fontSize = $self->{fontOption}->getValue; @@ -420,7 +439,10 @@ BEGIN { my @valuesList; if ($type eq 'date') { - @valuesList = map {GCPreProcess::reverseDate($_->{$sortField})} @{$self->{data}}; + @valuesList = map {GCPreProcess::cutReversedDate( + GCPreProcess::reverseDate($_->{$sortField}), + $self->{groupDatesByOption}->getValue)} + @{$self->{data}}; } else { -- cgit v1.2.3