/[Frey]/trunk/lib/Frey/jQuery/flot.pm
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 /trunk/lib/Frey/jQuery/flot.pm

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

revision 867 by dpavlin, Tue Dec 16 14:28:03 2008 UTC revision 868 by dpavlin, Tue Dec 16 22:37:18 2008 UTC
# Line 6  with 'Frey::Web'; Line 6  with 'Frey::Web';
6  #with 'Frey::Storage';  #with 'Frey::Storage';
7  with 'Frey::jQuery';  with 'Frey::jQuery';
8    
9    use DateTimeX::Easy;
10    
11    use lib 'lib';
12    use Frey::Shell::sar;
13    use JSON;
14    
15  has skeleton => (  has skeleton => (
16          is => 'rw',          is => 'rw',
17          isa => 'Str',          isa => 'Str',
# Line 25  sub as_markup { Line 31  sub as_markup {
31    
32          $self->add_css("$path/layout.css");          $self->add_css("$path/layout.css");
33    
34            my $sponge = Frey::Shell::sar->new()->as_sponge;
35            warn $self->dump( $sponge );
36    
37            my $by_col;
38    
39            foreach my $row ( @{ $sponge->{rows} } ) {
40                    my $x = DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms
41                    foreach my $col ( 2 .. 8 ) {
42                            push @{ $by_col->{$col} }, [ $x, $row->[$col] ];
43                    }
44            }
45    
46            my $data_js;
47            my @names;
48            foreach my $nr ( keys %$by_col ) {
49                    my $name = 'd' . $nr;
50                    push @names, $name;
51                    $data_js .= qq|var $name = |  . to_json( $by_col->{$nr} ) . qq|;\n|;
52            }
53    
54            warn "# $data_js";
55    
56          q|          q|
57          <div id="placeholder" style="width:600px;height:300px;"></div>          <div id="placeholder" style="width:600px;height:300px;"></div>
58    
59                  <script id="source" language="javascript" type="text/javascript">                  <script id="source" language="javascript" type="text/javascript">
60                  $(function () {                  $(function () {
61                          var d1 = [];                          var options = {
62                          for (var i = 0; i < 14; i += 0.5)                                  xaxis: { mode: "time" },
63                                  d1.push([i, Math.sin(i)]);                                  selection: { mode: "x" }
64                            };
65                          var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];          | . $data_js . q|
66                            $.plot($("#placeholder"), [
67                          // a null signifies separate line segments          | . join(',',@names) . q|              
68                          var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];                          ], options);
                           
                         $.plot($("#placeholder"), [ d1, d2, d3 ]);  
69                  });                  });
70                  </script>                  </script>
71          |;          |;

Legend:
Removed from v.867  
changed lines
  Added in v.868

  ViewVC Help
Powered by ViewVC 1.1.26