/[simile]/sparklines/create.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sparklines/create.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by dpavlin, Fri Oct 17 11:32:35 2008 UTC revision 28 by dpavlin, Mon Oct 20 18:59:48 2008 UTC
# Line 31  foreach my $file ( @ARGV ) { Line 31  foreach my $file ( @ARGV ) {
31                  if ( ! defined $data->{$instance} ) {                  if ( ! defined $data->{$instance} ) {
32                          $data->{$instance} = [];                          $data->{$instance} = [];
33                          $json->{$instance}->{$type}->{sum} = 0;                          $json->{$instance}->{$type}->{sum} = 0;
34                          $json->{$instance}->{$type}->{min} = 0;  #                       $json->{$instance}->{$type}->{min} = 0;
35                          $json->{$instance}->{$type}->{max} = 0;  #                       $json->{$instance}->{$type}->{max} = 0;
36                  }                  }
37    
38                  $max_month = $month if $month > $max_month;                  $max_month = $month if $month > $max_month;
# Line 50  foreach my $file ( @ARGV ) { Line 50  foreach my $file ( @ARGV ) {
50                          push @x, $month;                          push @x, $month;
51                          my $y = $data->{$instance}->[$month] || 0;                          my $y = $data->{$instance}->[$month] || 0;
52                          push @y, $y;                          push @y, $y;
53                          $json->{$instance}->{$type}->{min} = $y if $json->{$instance}->{$type}->{min} > $y;  #                       $json->{$instance}->{$type}->{min} = $y if $json->{$instance}->{$type}->{min} > $y;
54                          $json->{$instance}->{$type}->{max} = $y if $json->{$instance}->{$type}->{max} < $y;  #                       $json->{$instance}->{$type}->{max} = $y if $json->{$instance}->{$type}->{max} < $y;
55                          $json->{$instance}->{$type}->{sum} += $y;                          $json->{$instance}->{$type}->{sum} += $y;
56                  }                  }
57                  warn "x = ",dump( @x ), "\ny = ", dump( @y ) if $debug;                  warn "x = ",dump( @x ), "\ny = ", dump( @y ) if $debug;
# Line 71  foreach my $instance ( keys %$json ) { Line 71  foreach my $instance ( keys %$json ) {
71                  id => $instance,                  id => $instance,
72                  label => $instance,                  label => $instance,
73                  uri => "http://www.$instance.skole.hr",                  uri => "http://www.$instance.skole.hr",
74                    visits_sum => 0,
75                    visits_anonymous_sum => 0,
76                    changes_sum => 0,
77                    categories_changed_sum => 0,
78                    unique_users_sum => 0,
79          };          };
80          foreach my $type ( keys %{ $json->{$instance} } ) {          foreach my $type ( keys %{ $json->{$instance} } ) {
81                  foreach my $p ( keys %{ $json->{$instance}->{$type} } ) {                  foreach my $p ( keys %{ $json->{$instance}->{$type} } ) {
82                          $item->{ $type . '_' . $p } = $json->{$instance}->{$type}->{$p};                          my $val = $json->{$instance}->{$type}->{$p};
83                            $item->{ $type . '_' . $p } = $val;
84                  }                  }
85          }          }
86          push @items, $item;          push @items, $item;
87  }  }
88    
89  write_file( 'sparklines.js', to_json({ items => \@items }) );  #warn dump( @items );
90    
91    my $items_json = encode_json({
92            properties => {
93                    visits_sum => { valueType => 'number' },
94                    visits_anonymous_sum => { valueType => 'number' },
95                    changes_sum => { valueType => 'number' },
96                    categories_changed_sum => { valueType => 'number' },
97                    unique_users_sum => { valueType => 'number' },
98            },
99            items => [ @items ]
100    });
101    #$items_json =~ s/(_sum":)"(\d+)"/$1$2/gs;
102    write_file( 'sparklines.js', $items_json );
103    

Legend:
Removed from v.23  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26