omf_web 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/bin/omf_web_server +18 -0
  2. data/example/bridge/README.md +7 -0
  3. data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
  4. data/example/bridge/htdocs/graph/js/bridge.js +35 -45
  5. data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
  6. data/example/bridge/htdocs/graph/js/event_table.js +26 -28
  7. data/example/bridge/viz_server.rb +5 -9
  8. data/example/demo/demo_viz_server.rb +2 -2
  9. data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
  10. data/example/openflow-gec15/code_tab.yaml +7 -12
  11. data/example/openflow-gec15/dashboard_tab.yaml +11 -12
  12. data/example/openflow-gec15/exp_source.rb +26 -26
  13. data/example/openflow-gec15/of_viz_server.rb +7 -7
  14. data/example/simple/simple.yaml +2 -1
  15. data/example/simple/simple_dynamic.yaml +1 -1
  16. data/example/web_rtc/web_rtc.yaml +54 -0
  17. data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
  18. data/lib/omf-web/config.ru +1 -1
  19. data/lib/omf-web/content/content_proxy.rb +2 -2
  20. data/lib/omf-web/content/file_repository.rb +11 -53
  21. data/lib/omf-web/content/git_repository.rb +1 -1
  22. data/lib/omf-web/content/irods_repository.rb +1 -1
  23. data/lib/omf-web/content/repository.rb +5 -3
  24. data/lib/omf-web/content/static_repository.rb +25 -11
  25. data/lib/omf-web/data_source_proxy.rb +3 -3
  26. data/lib/omf-web/rack/content_handler.rb +2 -2
  27. data/lib/omf-web/rack/session_authenticator.rb +3 -3
  28. data/lib/omf-web/rack/tab_mapper.rb +2 -2
  29. data/lib/omf-web/rack/update_handler.rb +2 -2
  30. data/lib/omf-web/rack/websocket_handler.rb +3 -3
  31. data/lib/omf-web/rack/widget_mapper.rb +2 -2
  32. data/lib/omf-web/session_store.rb +2 -2
  33. data/lib/omf-web/theme/abstract_page.rb +15 -24
  34. data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
  35. data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
  36. data/lib/omf-web/theme/bright/page.rb +2 -1
  37. data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
  38. data/lib/omf-web/theme.rb +1 -1
  39. data/lib/omf-web/thin/logging.rb +18 -13
  40. data/lib/omf-web/thin/runner.rb +2 -2
  41. data/lib/omf-web/thin/server.rb +105 -27
  42. data/lib/omf-web/version.rb +1 -1
  43. data/lib/omf-web/widget/abstract_widget.rb +3 -3
  44. data/lib/omf-web/widget/data_widget.rb +1 -0
  45. data/lib/omf-web/widget/text/maruku.rb +1 -1
  46. data/lib/omf-web/widget.rb +22 -22
  47. data/lib/omf_web.rb +1 -1
  48. data/omf_web.gemspec +18 -15
  49. data/share/htdocs/graph/js/abstract_chart.js +69 -68
  50. data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
  51. data/share/htdocs/graph/js/abstract_widget.js +61 -62
  52. data/share/htdocs/graph/js/axis.js +30 -25
  53. data/share/htdocs/graph/js/barchart_brush.js +23 -21
  54. data/share/htdocs/graph/js/code_mirror.js +35 -33
  55. data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
  56. data/share/htdocs/graph/js/histogram2.js +37 -47
  57. data/share/htdocs/graph/js/line_chart3.js +36 -30
  58. data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
  59. data/share/htdocs/graph/js/multi_barchart.js +33 -30
  60. data/share/htdocs/graph/js/network2.js +98 -97
  61. data/share/htdocs/graph/js/pie_chart2.js +25 -23
  62. data/share/htdocs/graph/js/scatter_plot.js +38 -36
  63. data/share/htdocs/graph/js/table2.js +60 -54
  64. data/share/htdocs/js/app.js +43 -0
  65. data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
  66. data/share/htdocs/js/data_source_repo.js +42 -0
  67. data/share/htdocs/require/nv_d3.js +2 -0
  68. data/share/htdocs/theme/abstract/abstract.js +4 -4
  69. data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
  70. data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
  71. data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
  72. data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
  73. data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
  74. data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
  75. data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
  76. data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
  77. data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
  78. data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
  79. data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
  80. data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
  81. metadata +100 -74
  82. checksums.yaml +0 -7
  83. data/bin/omf_web_demo +0 -3
  84. data/bin/omf_web_demo.sh +0 -7
  85. data/bin/omf_web_server.rb +0 -157
  86. data/lib/omf_common/lobject.rb +0 -187
  87. data/lib/omf_common/log4r_outputter.rb +0 -69
  88. data/sample.sq3 +0 -0
  89. data/share/htdocs/js/data_source.js +0 -173
  90. data/share/htdocs/js/require3.js +0 -292
@@ -34,7 +34,7 @@ module OMF::Web::Widget::Text
34
34
  raise "Expected content proxy, but got '#{content_proxy.class}'"
35
35
  end
36
36
  content = content_proxy.content
37
- puts ">>>> CREATING NEW MARUKU"
37
+ #puts ">>>> CREATING NEW MARUKU"
38
38
  ::Maruku.new(content)
39
39
  end
40
40
 
@@ -2,12 +2,12 @@
2
2
  require 'erector'
3
3
 
4
4
  module OMF::Web::Widget
5
-
6
-
5
+
6
+
7
7
  @@widgets = {}
8
- @@descriptions = {}
9
- @@type2class = {}
10
-
8
+ @@descriptions = {}
9
+ @@type2class = {}
10
+
11
11
  def self.register_widget(wdescr)
12
12
  unless id = wdescr[:id]
13
13
  raise "Missing 'id' for widget '#{wdescr.inspect}'"
@@ -15,25 +15,25 @@ module OMF::Web::Widget
15
15
  id = id.to_sym
16
16
  if (@@descriptions.key? id)
17
17
  raise "Repeated try to register widget '#{id}'"
18
- end
18
+ end
19
19
  @@descriptions[id] = wdescr
20
20
  end
21
-
21
+
22
22
  def self.registered_widgets()
23
23
  @@descriptions
24
24
  end
25
-
25
+
26
26
  def self.register_widget_type(id, widget_class)
27
27
  id = id.to_sym
28
28
  if (@@type2class.key? id)
29
29
  raise "Repeated try to register widget type '#{id}'"
30
- end
30
+ end
31
31
  @@type2class[id] = widget_class
32
32
  end
33
-
34
-
33
+
34
+
35
35
  # Return the number of top level widgets. If 'restrict_to' is an
36
- # array, only return those.
36
+ # array, only return those.
37
37
  #
38
38
  def self.toplevel_widgets(restrict_to = nil)
39
39
  if restrict_to
@@ -49,15 +49,15 @@ module OMF::Web::Widget
49
49
  end.compact
50
50
  end
51
51
  wa.sort do |a, b|
52
- (b[:priority] || 100) <=> (a[:priority] || 100)
52
+ (b[:priority] || 100) <=> (a[:priority] || 100)
53
53
  end
54
- end
55
-
54
+ end
55
+
56
56
  def self.create_widget(name)
57
57
  if name.is_a? Array
58
58
  # this is short notation for a stacked widget
59
59
  #
60
- wdescr = { :type => 'layout/stacked', :widgets => name}
60
+ wdescr = { :type => 'layout/stacked', :widgets => name}
61
61
  elsif name.is_a? Hash
62
62
  wdescr = name
63
63
  else
@@ -85,25 +85,25 @@ module OMF::Web::Widget
85
85
  w = OMF::Web::Widget::DataWidget.new(wdescr)
86
86
  when /^layout/
87
87
  require 'omf-web/widget/layout'
88
- w = OMF::Web::Widget::Layout.create_layout_widget(type, wdescr)
88
+ w = OMF::Web::Widget::Layout.create_layout_widget(type, wdescr)
89
89
  when /^text/
90
90
  require 'omf-web/widget/text/text_widget'
91
- w = OMF::Web::Widget::TextWidget.create_text_widget(type, wdescr)
91
+ w = OMF::Web::Widget::TextWidget.create_text_widget(type, wdescr)
92
92
  when /^code/
93
93
  require 'omf-web/widget/code_widget'
94
- w = OMF::Web::Widget::CodeWidget.create_code_widget(type, wdescr)
94
+ w = OMF::Web::Widget::CodeWidget.create_code_widget(type, wdescr)
95
95
  when /^moustache/
96
96
  require 'omf-web/widget/mustache_widget'
97
- w = OMF::Web::Widget::MustacheWidget.create_mustache_widget(type, wdescr)
97
+ w = OMF::Web::Widget::MustacheWidget.create_mustache_widget(type, wdescr)
98
98
  else
99
99
  raise "Unknown widget type '#{type}' (#{wdescr.inspect})"
100
100
  end
101
101
  @@widgets[wdescr[:id]] = w
102
102
  end
103
-
103
+
104
104
  def self._init()
105
105
  register_widget
106
106
  end
107
-
107
+
108
108
 
109
109
  end # OMF::Web::Widget
data/lib/omf_web.rb CHANGED
@@ -42,7 +42,7 @@ module OMF
42
42
  if w = y['widget']
43
43
  OMF::Web.register_widget w
44
44
  else
45
- OMF::Common::LObject.error "Doesn't seem to be a widget definition. Expected 'widget' but found '#{y.keys.join(', ')}'"
45
+ OMF::Base::LObject.error "Doesn't seem to be a widget definition. Expected 'widget' but found '#{y.keys.join(', ')}'"
46
46
  end
47
47
  end
48
48
 
data/omf_web.gemspec CHANGED
@@ -20,21 +20,24 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "minitest", "~> 2.11.3"
23
- s.add_runtime_dependency "omf_oml", "~> 1.0"
24
- s.add_runtime_dependency "erector", "~> 0.8.3"
25
- s.add_runtime_dependency "activesupport", "~> 3.0.0" # required by erector:table
26
- s.add_runtime_dependency "rack", "~> 1.3.5"
27
- s.add_runtime_dependency "thin", "~> 1.3.1"
28
- s.add_runtime_dependency "coderay", "~> 1.0.6"
29
- s.add_runtime_dependency "log4r", "~> 1.1.10"
30
- s.add_runtime_dependency "maruku", "~> 0.6.0"
31
- s.add_runtime_dependency "ritex", "~> 1.0.1"
32
- s.add_runtime_dependency "json", "~> 1.7.3"
33
- s.add_runtime_dependency "grit", "~> 2.5.0"
34
- s.add_runtime_dependency "sqlite3", "~> 1.3.6"
35
- s.add_runtime_dependency "postgres-pr", "~> 0.6.3"
36
- s.add_runtime_dependency "websocket-rack", "~> 0.4.0"
37
- s.add_runtime_dependency "rack-accept", "~> 0.4.5"
23
+ s.add_runtime_dependency "omf_oml", "~> 1"
24
+ s.add_runtime_dependency "omf_base"
25
+ s.add_runtime_dependency "erector", "~> 0.9"
26
+ s.add_runtime_dependency "activesupport", "~> 3.0" # required by erector:table
27
+ s.add_runtime_dependency "rack", "~> 1"
28
+ s.add_runtime_dependency "thin", "~> 1"
29
+ s.add_runtime_dependency "coderay", "~> 1"
30
+ s.add_runtime_dependency "maruku", "~> 0.6"
31
+ s.add_runtime_dependency "ritex", "~> 1.0"
32
+ s.add_runtime_dependency "json", "~> 1.7"
33
+ s.add_runtime_dependency "grit", "~> 2.5"
34
+ s.add_runtime_dependency "websocket-rack", "~> 0.4"
35
+ s.add_runtime_dependency "rack-accept", "~> 0.4"
36
+ s.add_runtime_dependency "i18n"
37
+
38
+ # Do we need the next two dependencies?
39
+ #s.add_runtime_dependency "sqlite3", "~> 1.3.6"
40
+ #s.add_runtime_dependency "postgres-pr", "~> 0.6.3"
38
41
 
39
42
  s.add_runtime_dependency "ruby-openid", "~> 2.2.3"
40
43
 
@@ -1,46 +1,47 @@
1
1
 
2
- L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widget", "vendor/d3/d3.js"], function () {
2
+ //L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widget", "vendor/d3/d3.js"], function () {
3
+
4
+ define(["graph/abstract_widget"], function (abstract_widget) {
5
+
6
+ var abstract_chart = abstract_widget.extend({
3
7
 
4
-
5
- OML.abstract_chart = OML.abstract_widget.extend({
6
-
7
8
  decl_color_func: {
8
9
  // scale
9
10
  "green_yellow80_red()": function() {
10
11
  return d3.scale.linear()
11
12
  .domain([0, 0.8, 1])
12
- .range(["green", "yellow", "red"])
13
+ .range(["green", "yellow", "red"]);
13
14
  },
14
15
  "green_red()": function() {
15
16
  return d3.scale.linear()
16
17
  .domain([0, 1])
17
- .range(["green", "red"])
18
+ .range(["green", "red"]);
18
19
  },
19
20
  "red_yellow20_green()": function() {
20
21
  return d3.scale.linear()
21
22
  .domain([0, 0.2, 1])
22
- .range(["red", "yellow", "green"])
23
+ .range(["red", "yellow", "green"]);
23
24
  },
24
25
  "red_green()": function() {
25
26
  return d3.scale.linear()
26
27
  .domain([0, 1])
27
- .range(["red", "green"])
28
+ .range(["red", "green"]);
28
29
  },
29
30
  // category
30
31
  "category10()": function() {
31
- return d3.scale.category10()
32
+ return d3.scale.category10();
32
33
  },
33
34
  "category20()": function() {
34
- return d3.scale.category20()
35
+ return d3.scale.category20();
35
36
  },
36
37
  "category20b()": function() {
37
- return d3.scale.category20b()
38
+ return d3.scale.category20b();
38
39
  },
39
40
  "category20c()": function() {
40
- return d3.scale.category20c()
41
+ return d3.scale.category20c();
41
42
  },
42
43
  },
43
-
44
+
44
45
  defaults: function() {
45
46
  return this.deep_defaults({
46
47
  margin: {
@@ -49,19 +50,19 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
49
50
  right: 50,
50
51
  bottom: 40
51
52
  },
52
- }, OML.abstract_chart.__super__.defaults.call(this));
53
- },
54
-
55
-
53
+ }, abstract_chart.__super__.defaults.call(this));
54
+ },
55
+
56
+
56
57
  //base_css_class: 'oml-chart',
57
-
58
+
58
59
  initialize: function(opts) {
59
- OML.abstract_chart.__super__.initialize.call(this, opts);
60
-
61
-
60
+ abstract_chart.__super__.initialize.call(this, opts);
61
+
62
+
62
63
  var vis = this.init_svg(this.w, this.h);
63
64
  this.configure_base_layer(vis);
64
-
65
+
65
66
  var self = this;
66
67
  OHUB.bind("graph.highlighted", function(evt) {
67
68
  if (evt.source == self) return;
@@ -71,43 +72,43 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
71
72
  if (evt.source == self) return;
72
73
  self.on_dehighlighted(evt);
73
74
  });
74
-
75
+
75
76
  //this.update(null);
76
- this.update();
77
+ this.update();
77
78
  },
78
-
79
- _resize_base_el: function(w, h) {
79
+
80
+ _resize_base_el: function(w, h) {
80
81
  // Do not add margins to the base_el, but to the inside of the SVG panes
81
82
  this.w = w;
82
83
  this.h = h;
83
84
  this.base_el
84
85
  .style('height', this.h + 'px')
85
- .style('width', this.w + 'px')
86
+ .style('width', this.w + 'px')
86
87
  .style('margin-left', 0 + 'px')
87
- .style('margin-right', 0 + 'px')
88
- .style('margin-top', 0 + 'px')
89
- .style('margin-bottom', 0 + 'px')
88
+ .style('margin-right', 0 + 'px')
89
+ .style('margin-top', 0 + 'px')
90
+ .style('margin-bottom', 0 + 'px')
90
91
  ;
91
-
92
+
92
93
  //var m = _.defaults(opts.margin || {}, this.defaults.margin);
93
94
  var m = this.opts.margin;
94
95
  var ca = this.widget_area = {
95
- x: m.left,
96
- rx: w - m.left,
97
- y: m.bottom,
98
- ty: m.top,
99
- w: w - m.left - m.right,
96
+ x: m.left,
97
+ rx: w - m.left,
98
+ y: m.bottom,
99
+ ty: m.top,
100
+ w: w - m.left - m.right,
100
101
  h: h - m.top - m.bottom,
101
102
  ow: w, // outer dimensions
102
103
  oh: h
103
104
  };
104
-
105
- },
106
-
107
-
105
+
106
+ },
107
+
108
+
108
109
  init_svg: function(w, h) {
109
110
  var opts = this.opts;
110
-
111
+
111
112
  var vis = opts.svg = this.svg_base = this.base_el.append("svg:svg")
112
113
  // .attr("width", w)
113
114
  // .attr("height", h)
@@ -116,25 +117,25 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
116
117
  .attr('class', this.base_css_class);
117
118
  var offset = opts.offset;
118
119
  if (offset.x) {
119
- // the next two lines do the same, but only one works
120
+ // the next two lines do the same, but only one works
120
121
  // in the specific context
121
122
  vis.attr("x", offset.x);
122
- vis.style("margin-left", offset.x + "px");
123
+ vis.style("margin-left", offset.x + "px");
123
124
  }
124
125
  if (offset.y) {
125
126
  vis.attr("y", offset.y);
126
- vis.style("margin-top", offset.y + "px");
127
+ vis.style("margin-top", offset.y + "px");
127
128
  }
128
129
  return vis;
129
130
  },
130
131
 
131
- // Split tuple array into array of tuple arrays grouped by
132
+ // Split tuple array into array of tuple arrays grouped by
132
133
  // the tuple element at +index+.
133
134
  //
134
135
  group_by: function(in_data, index_f) {
135
136
  var data = [];
136
137
  var groups = {};
137
-
138
+
138
139
  _.map(in_data, function(d) {
139
140
  var key = index_f(d);
140
141
  var a = groups[key];
@@ -147,7 +148,7 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
147
148
  // Sort by 'group_by' index to keep the same order and with it same color assignment.
148
149
  var data = _.sortBy(data, function(a) {
149
150
  return index_f(a[0])
150
- });
151
+ });
151
152
  return data;
152
153
  },
153
154
 
@@ -156,11 +157,11 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
156
157
  this.ic = {
157
158
  handler: handler,
158
159
  };
159
-
160
+
160
161
  var ig = this.base_layer.append("svg:g")
161
162
  .attr("pointer-events", "all")
162
163
  .on("mousedown", mousedown);
163
-
164
+
164
165
  var ca = this.chart_area;
165
166
  var frame = ig.append("svg:rect")
166
167
  .attr("class", "graph-area")
@@ -171,7 +172,7 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
171
172
  .attr("fill", "none")
172
173
  .attr("stroke", "none")
173
174
  ;
174
-
175
+
175
176
  function mousedown() {
176
177
  var ic = self.ic;
177
178
  if (!ic.rect) {
@@ -189,7 +190,7 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
189
190
  ic.move_event_consumed = false;
190
191
  d3.event.preventDefault();
191
192
  }
192
-
193
+
193
194
  function mousedown_box() {
194
195
  var ic = self.ic;
195
196
  mousedown();
@@ -197,20 +198,20 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
197
198
  ic.offsetx = ic.x0[0] - ic.minx;
198
199
  }
199
200
  }
200
-
201
+
201
202
  function mousemove(x, d, i) {
202
203
  var ic = self.ic;
203
204
  var ca = self.chart_area;
204
-
205
+
205
206
  if (!ic.rect) return;
206
207
  if (!ic.is_dragging) return;
207
208
  ic.has_moved = true;
208
-
209
+
209
210
  var x1 = d3.svg.mouse(ic.rect.node());
210
211
  var minx;
211
212
  if (ic.offsetx) {
212
213
  minx = Math.max(ca.x, x1[0] - ic.offsetx);
213
- minx = ic.minx = Math.min(minx, ca.x + ca.w - ic.width);
214
+ minx = ic.minx = Math.min(minx, ca.x + ca.w - ic.width);
214
215
  } else {
215
216
  minx = ic.minx = Math.max(ca.x, Math.min(ic.x0[0], x1[0]));
216
217
  var maxx = Math.min(ca.x + ca.w, Math.max(ic.x0[0], x1[0]));
@@ -218,7 +219,7 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
218
219
  }
219
220
  self.update_selection({screen_minx: minx});
220
221
  }
221
-
222
+
222
223
  function mouseup() {
223
224
  var ic = self.ic;
224
225
  if (!ic.rect) return;
@@ -231,18 +232,18 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
231
232
  if (ic.handler) ic.handler(this, 0, 0);
232
233
  }
233
234
  }
234
-
235
+
235
236
  d3.select(window)
236
237
  .on("mousemove", mousemove)
237
238
  .on("mouseup", mouseup);
238
239
  },
239
-
240
+
240
241
  update_selection: function(selection) {
241
242
  if (!this.ic) return;
242
-
243
+
243
244
  var ic = this.ic;
244
245
  var ca = this.chart_area;
245
-
246
+
246
247
  var sminx = selection.screen_minx;
247
248
  if (sminx) {
248
249
  ic.rect
@@ -260,16 +261,16 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
260
261
  ic.handler(this, imin, imax);
261
262
  }
262
263
  },
263
-
264
+
264
265
  /*************
265
266
  * Deal with schema and turn +mapping+ instructions into actionable functions.
266
267
  */
267
-
268
-
268
+
269
+
269
270
  on_highlighted: function(evt) {},
270
271
  on_dehighlighted: function(evt) {},
271
-
272
-
272
+
273
+
273
274
  // Return an array with the 'min' and 'max' value returned by running 'f' over 'data'
274
275
  // However, any 'min' and 'max' values in 'opts' take precedence.
275
276
  //
@@ -286,7 +287,7 @@ L.provide('OML.abstract_chart', ["graph/js/abstract_widget", "#OML.abstract_widg
286
287
  var min = o.min != undefined ? o.min : d3.min(data, function(s) {return d3.min(s, f)});
287
288
  return [min, max];
288
289
  }
289
-
290
-
291
290
  });
292
- })
291
+
292
+ return abstract_chart;
293
+ });
@@ -1,17 +1,17 @@
1
1
 
2
- L.provide('d3', ["vendor/d3/d3.js"], function() {
3
- L.provide('nv_d3', ["vendor/nv_d3/js/nv.d3.js", "vendor/nv_d3/css/nv.d3.css"]);
4
- })
2
+ require.config({
3
+ shim: {
4
+ "vendor/nv_d3/js/nv.d3": ["vendor/d3/d3", "css!vendor/nv_d3/css/nv.d3"]
5
+ }
6
+ });
5
7
 
6
- L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_chart",
7
- //"graph/js/axis", "#OML.axis", "graph/css/graph.css",
8
- "#nv_d3"], function () {
8
+ define(["graph/abstract_chart", 'vendor/nv_d3/js/nv.d3'], function (abstract_chart) {
9
9
 
10
- OML.abstract_nv_chart = OML.abstract_chart.extend({
10
+ var abstract_nv_chart = abstract_chart.extend({
11
11
  axis_defaults: {
12
12
  legend: {
13
13
  text: 'DESCRIBE ME',
14
- offset: 40
14
+ offset: 40
15
15
  },
16
16
  ticks: {
17
17
  // type: 'date',
@@ -25,15 +25,15 @@ L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_ch
25
25
  },
26
26
  margin: {
27
27
  top: 0, right: 0, bottom: 0, left: 50 // not sure what impact this really has?
28
- }
28
+ }
29
29
  },
30
-
30
+
31
31
  defaults: function() {
32
32
  return this.deep_defaults({
33
33
  transition_duration: 500
34
- }, OML.abstract_nv_chart.__super__.defaults.call(this));
35
- },
36
-
34
+ }, abstract_nv_chart.__super__.defaults.call(this));
35
+ },
36
+
37
37
 
38
38
  configure_base_layer: function(vis) {
39
39
  this.base_layer = vis;
@@ -41,24 +41,24 @@ L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_ch
41
41
  this._configure_mapping(this.mapping, chart);
42
42
  this._configure_options(this.opts, chart);
43
43
  },
44
-
44
+
45
45
  _configure_mapping: function(m, chart) {
46
46
  },
47
-
47
+
48
48
  _configure_options: function(opts, chart) {
49
49
  chart.margin(opts.margin);
50
50
  },
51
-
51
+
52
52
  _configure_xy_axis: function(opts, chart) {
53
53
  var oaxis = opts.axis || {};
54
54
  var a_defaults = this.axis_defaults;
55
-
55
+
56
56
  var xao = _.defaults(oaxis.x || {}, a_defaults);
57
57
  this._configure_axis('x', chart.xAxis, xao);
58
58
  var yao = _.defaults(oaxis.y || {}, a_defaults);
59
59
  this._configure_axis('y', chart.yAxis, yao);
60
60
  },
61
-
61
+
62
62
  _configure_axis: function(name, axis, opts) {
63
63
  // LABEL
64
64
  var ol = opts.legend;
@@ -67,15 +67,15 @@ L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_ch
67
67
  //ol = _.defaults(ol, defaults.axis);
68
68
  axis.axisLabel(ol.text);
69
69
  }
70
-
70
+
71
71
  // TICKS
72
- var ot = opts.ticks // _.defaults(opts.ticks || {}, defaults.ticks);
72
+ var ot = opts.ticks; // _.defaults(opts.ticks || {}, defaults.ticks);
73
73
  // Check if we need a special formatter for the tick labels
74
74
  if (ot.type == 'date' || ot.type == 'dateTime') {
75
75
  var d_f = d3.time.format(ot.format || "%X");
76
76
  axis.tickFormat(function(d) {
77
77
  var date = new Date(1000 * d); // TODO: Implicitly assuming that value is in seconds is most likely NOT a good idea
78
- var fs = d_f(date);
78
+ var fs = d_f(date);
79
79
  return fs;
80
80
  });
81
81
  } else if (ot.type == 'key') {
@@ -90,7 +90,7 @@ L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_ch
90
90
  if (ot.subdivide) axis.tickSubdivide(ot.subdivide);
91
91
  if (ot.size) {
92
92
  // apply doesn't seem to work here
93
- if (typeof ot.size === 'number')
93
+ if (typeof ot.size === 'number')
94
94
  axis.tickSize(ot.size);
95
95
  else {
96
96
  var a = ot.size;
@@ -103,37 +103,39 @@ L.provide('OML.abstract_nv_chart', ["graph/js/abstract_chart", "#OML.abstract_ch
103
103
  }
104
104
  if (ot.padding) axis.tickPadding(ot.padding);
105
105
  if (ot.count) axis.ticks(ot.count);
106
-
106
+
107
107
  // MARGIN
108
- var om = opts.margin //_.defaults(ot.margin || {}, defaults.margin);
108
+ var om = opts.margin; //_.defaults(ot.margin || {}, defaults.margin);
109
109
  axis.margin(om);
110
110
 
111
111
  // MISC
112
- axis.showMaxMin(false)
112
+ axis.showMaxMin(false);
113
113
  },
114
114
 
115
115
  resize: function() {
116
116
  var self = this;
117
- OML.abstract_nv_chart.__super__.resize.call(this);
117
+ abstract_nv_chart.__super__.resize.call(this);
118
118
  if (this.chart) {
119
119
  this.chart.width(self.width);
120
- this.chart.height(self.height);
120
+ this.chart.height(self.height);
121
121
  this.chart.update();
122
- }
122
+ }
123
123
  },
124
-
124
+
125
125
  redraw: function(data) {
126
126
  var bl = this.base_layer//.select(".chart_layer")
127
127
  .datum(this._datum(data, this.chart))
128
128
  ;
129
129
  if (this.opts.transition_duration > 0) {
130
- bl = bl.transition().duration(500)
130
+ bl = bl.transition().duration(500);
131
131
  }
132
132
  bl.call(this.chart);
133
133
  },
134
-
135
- })
136
- })
134
+
135
+ });
136
+
137
+ return abstract_nv_chart;
138
+ });
137
139
 
138
140
  /*
139
141
  Local Variables: