/[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 860 by dpavlin, Tue Dec 16 14:28:03 2008 UTC revision 869 by dpavlin, Tue Dec 16 23:03:21 2008 UTC
# Line 5  extends 'Frey'; Line 5  extends 'Frey';
5  with 'Frey::Web';  with 'Frey::Web';
6  #with 'Frey::Storage';  #with 'Frey::Storage';
7  with 'Frey::jQuery';  with 'Frey::jQuery';
8    with 'Frey::File'; # FIXME inline on demand?
9    
10    use DateTimeX::Easy;
11    
12    use lib 'lib';
13    use Frey::Shell::sar;
14    use JSON;
15    
16  has skeleton => (  has skeleton => (
17          is => 'rw',          is => 'rw',
# Line 25  sub as_markup { Line 32  sub as_markup {
32    
33          $self->add_css("$path/layout.css");          $self->add_css("$path/layout.css");
34    
35            my $sponge = Frey::Shell::sar->new( sar_command => 'sar -n 1' )->as_sponge;
36            warn $self->dump( $sponge );
37    
38            my $by_col;
39    
40            foreach my $row ( @{ $sponge->{rows} } ) {
41                    my $x = DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms
42                    foreach my $col ( 2 .. 8 ) {
43                            push @{ $by_col->{$col} }, [ $x, $row->[$col] ];
44                    }
45            }
46    
47            my $dataset;
48            my @names;
49            foreach my $nr ( keys %$by_col ) {
50                    my $name = $sponge->{NAME}->[$nr];
51                    $dataset->{ $name }->{label} ||= $name;
52                    $dataset->{ $name }->{data} = $by_col->{$nr};
53            }
54    
55            my $data_js = 'var datasets = ' . to_json( $dataset ) . ';';
56    
57            warn "# $data_js";
58    
59          q|          q|
60          <div id="placeholder" style="width:600px;height:300px;"></div>          <div id="placeholder" style="width:600px;height:300px;"></div>
61    
62                    <div id="choices">Show:</div>
63    
64                  <script id="source" language="javascript" type="text/javascript">                  <script id="source" language="javascript" type="text/javascript">
65                  $(function () {                  $(function () {
66                          var d1 = [];                          var options = {
67                          for (var i = 0; i < 14; i += 0.5)                                  //selection: { mode: "x" },
68                                  d1.push([i, Math.sin(i)]);                                  //yaxis: { min: 0, max: 100 },
69                                    xaxis: { mode: "time" }
70                          var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];                          };
71    
72                          // a null signifies separate line segments                          |
73                          var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];                          . $data_js
74                                                    . $self->read_file('static/Frey/jQuery/flot/dataset_checkboxes.js')
75                          $.plot($("#placeholder"), [ d1, d2, d3 ]);                          .
76                            q|
77    
78                  });                  });
79                  </script>                  </script>
80          |;          |;

Legend:
Removed from v.860  
changed lines
  Added in v.869

  ViewVC Help
Powered by ViewVC 1.1.26