Class: Reviewlette::Graphgenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewlette/graph_gen.rb

Instance Method Summary collapse

Constructor Details

#initializeGraphgenerator

Returns a new instance of Graphgenerator.



7
8
9
# File 'lib/reviewlette/graph_gen.rb', line 7

def initialize
  @db = Reviewlette::Database.new
end

Instance Method Details

#model_graphs(data2, data, type) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/reviewlette/graph_gen.rb', line 16

def model_graphs(data2, data, type)
  @content = %Q|
  <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.5.1.css">
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
  <script src="http://cdn.oesmith.co.uk/morris-0.5.1.min.js"></script>
  <meta http-equiv="refresh" content="15" />

  <div id="Donut" style="height: 250px;"></div>
  <div id="Line" style="height: 250px;"></div>
  <div id="Bar" style="height: 250px;"></div>

  <script>
  new Morris.#{type}({
  element: 'Donut',
  data: #{data},
  xkey: 'label',
  colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
  ykeys: ['value'],
  labels: ['Value']
  });
  </script>

  <script>
  new Morris.Line({
  element: 'Line',
  data: #{data2},
  xkey: 'created_at',
  colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
  ykeys: #{@db.get_users_trello_entries},
  labels: #{@db.get_users_trello_entries}
  });
  </script>

  <script>
  new Morris.Bar({
  element: 'Bar',
  data: #{data},
  xkey: 'label',
  colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
  ykeys: ['value'],
  labels: ['Value']
  });
  </script>|
end

#write_to_graphs(filename, content) ⇒ Object



11
12
13
# File 'lib/reviewlette/graph_gen.rb', line 11

def write_to_graphs(filename, content)
  File.open(filename, 'w') { |file| file.write(content) }
end