omf_web 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. data/.gitignore +0 -1
  2. data/README.md +8 -2
  3. data/doc/screenshot.png +0 -0
  4. data/example/{basic → NOT_WORKING/basic}/hello-world-wired.rb +0 -0
  5. data/example/{basic → NOT_WORKING/basic}/visualisation.yml +0 -0
  6. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklynDemo.sq3 +0 -0
  7. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_gps.dat +0 -0
  8. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_server.rb +0 -0
  9. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_wimax.dat +0 -0
  10. data/example/{brooklyn → NOT_WORKING/brooklyn}/sql_source.rb +0 -0
  11. data/example/{code → NOT_WORKING/code}/code_server.rb +0 -0
  12. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/parse_log.rb +0 -0
  13. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/pxe_slice-2012-06-02t02.25.00-04.00.log +0 -0
  14. data/example/{frisbee → NOT_WORKING/frisbee}/progress_chart.yaml +0 -0
  15. data/example/{frisbee → NOT_WORKING/frisbee}/progress_tab.yaml +0 -0
  16. data/example/{frisbee → NOT_WORKING/frisbee}/progress_table.yaml +0 -0
  17. data/example/{frisbee → NOT_WORKING/frisbee}/viz_server.rb +0 -0
  18. data/example/{gec12 → NOT_WORKING/gec12}/gec12-53.rb +0 -0
  19. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo.sq3 +0 -0
  20. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo_server.rb +0 -0
  21. data/example/{gec12 → NOT_WORKING/gec12}/visualization.rb +0 -0
  22. data/example/{incoming → NOT_WORKING/incoming}/ofpu_barchart_widget.yaml +0 -0
  23. data/example/{log → NOT_WORKING/log}/log_config.xml +0 -0
  24. data/example/{log → NOT_WORKING/log}/log_server.rb +0 -0
  25. data/example/{network → NOT_WORKING/network}/flow_tab.yaml +0 -0
  26. data/example/{network → NOT_WORKING/network}/network_server.rb +0 -0
  27. data/example/{text → NOT_WORKING/text}/test.md +0 -0
  28. data/example/{text → NOT_WORKING/text}/test.rb +0 -0
  29. data/example/{wimax → NOT_WORKING/wimax}/downlink.yaml +0 -0
  30. data/example/{wimax → NOT_WORKING/wimax}/power.yaml +0 -0
  31. data/example/{wimax → NOT_WORKING/wimax}/snapshot.db +0 -0
  32. data/example/{wimax → NOT_WORKING/wimax}/snapshot.sql +0 -0
  33. data/example/{wimax → NOT_WORKING/wimax}/test.rb +0 -0
  34. data/example/{wimax → NOT_WORKING/wimax}/uplink.yaml +0 -0
  35. data/example/{wimax → NOT_WORKING/wimax}/viz_server.rb +0 -0
  36. data/example/demo/data_sources/mobile_network.rb +3 -0
  37. data/example/demo/data_sources/static_network.rb +54 -0
  38. data/example/demo/widgets/charts_tab.yaml +21 -16
  39. data/example/demo/widgets/linked_graphs_tab.yaml +95 -0
  40. data/example/demo/widgets/mobile_network_widget.yaml +1 -1
  41. data/example/demo/widgets/pie_chart_widget.yaml +1 -1
  42. data/lib/omf-web/config.ru +2 -2
  43. data/lib/omf-web/data_source_proxy.rb +81 -19
  44. data/lib/omf-web/rack/websocket_handler.rb +77 -23
  45. data/lib/omf-web/theme/abstract_page.rb +43 -26
  46. data/lib/omf-web/theme/bright/code_renderer.rb +1 -1
  47. data/lib/omf-web/theme/bright/page.rb +1 -0
  48. data/lib/omf-web/theme/bright/tabbed_renderer.rb +7 -0
  49. data/lib/omf-web/version.rb +7 -0
  50. data/lib/omf-web/widget/data_widget.rb +38 -46
  51. data/lib/omf-web/widget/layout/stacked_layout.rb +2 -1
  52. data/lib/omf-web/widget/layout/tabbed_layout.rb +1 -2
  53. data/{MARUKU-LICENSE → lib/omf-web/widget/text/maruku/MARUKU-LICENSE} +0 -0
  54. data/lib/{maruku → omf-web/widget/text/maruku}/helpers.rb +0 -0
  55. data/lib/{maruku → omf-web/widget/text/maruku}/input/parse_block.rb +0 -0
  56. data/lib/{maruku → omf-web/widget/text/maruku}/output/to_html.rb +26 -21
  57. data/lib/omf-web/widget/text/maruku.rb +5 -0
  58. data/omf_web.gemspec +2 -1
  59. data/share/htdocs/{js → UNUSED}/log/table.js +0 -0
  60. data/share/htdocs/{css → graph/css}/graph.css +0 -0
  61. data/share/htdocs/{image/graph → graph/img}/bar_chart.png +0 -0
  62. data/share/htdocs/{image/graph → graph/img}/donut_chart.png +0 -0
  63. data/share/htdocs/{image/graph → graph/img}/funnel.png +0 -0
  64. data/share/htdocs/{image/graph → graph/img}/info.png +0 -0
  65. data/share/htdocs/{image/graph → graph/img}/line_chart.png +0 -0
  66. data/share/htdocs/{image/graph → graph/img}/line_chart_fill.png +0 -0
  67. data/share/htdocs/{image/graph → graph/img}/misc.png +0 -0
  68. data/share/htdocs/{image/graph → graph/img}/overview.png +0 -0
  69. data/share/htdocs/{image/graph → graph/img}/pie_chart.png +0 -0
  70. data/share/htdocs/{image/graph → graph/img}/scatter_plot.png +0 -0
  71. data/share/htdocs/{image/graph → graph/img}/stacked_bar_chart.png +0 -0
  72. data/share/htdocs/{image/graph → graph/img}/stacked_line_chart.png +0 -0
  73. data/share/htdocs/{image/graph → graph/img}/table.png +0 -0
  74. data/share/htdocs/{js/graph → graph/js}/abstract_chart.js +1 -1
  75. data/share/htdocs/{js/graph → graph/js}/abstract_nv_chart.js +8 -13
  76. data/share/htdocs/{js/graph → graph/js}/abstract_widget.js +9 -16
  77. data/share/htdocs/{js/graph → graph/js}/axis.js +1 -1
  78. data/share/htdocs/{js/graph → graph/js}/barchart.js +2 -2
  79. data/share/htdocs/{js/graph → graph/js}/code_mirror.js +1 -5
  80. data/share/htdocs/{js/graph → graph/js}/discrete_bar_chart.js +1 -1
  81. data/share/htdocs/{js/graph → graph/js}/histogram2.js +1 -1
  82. data/share/htdocs/{js/graph → graph/js}/holt_winters_chart.js +1 -1
  83. data/share/htdocs/{js/graph → graph/js}/line_chart3.js +1 -1
  84. data/share/htdocs/{js/graph → graph/js}/line_chart_with_focus.js +1 -1
  85. data/share/htdocs/{js/graph → graph/js}/map2.js +1 -1
  86. data/share/htdocs/{js/graph → graph/js}/multi_barchart.js +1 -1
  87. data/share/htdocs/graph/js/network2.js +412 -0
  88. data/share/htdocs/{js/graph → graph/js}/pie_chart2.js +1 -1
  89. data/share/htdocs/{js/graph → graph/js}/scatter_plot.js +1 -1
  90. data/share/htdocs/{js/graph → graph/js}/table2.js +17 -20
  91. data/share/htdocs/js/data_source2.js +187 -60
  92. data/share/htdocs/js/require3.js +38 -57
  93. data/share/htdocs/theme/bright/css/bright.css +4 -4
  94. data/share/htdocs/vendor/jquery/jquery.js +9404 -0
  95. data/share/htdocs/vendor/osa/LICENSE.txt +11 -0
  96. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_green_left.svg +0 -0
  97. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_yellow_right.svg +0 -0
  98. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_awareness.svg +0 -0
  99. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_camera-web.svg +0 -0
  100. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_cloud.svg +0 -0
  101. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_contract.svg +0 -0
  102. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_database.svg +0 -0
  103. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop.svg +0 -0
  104. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop_imac.svg +0 -0
  105. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-music.svg +0 -0
  106. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-scanner.svg +0 -0
  107. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb-wifi.svg +0 -0
  108. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb.svg +0 -0
  109. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-wireless-router.svg +0 -0
  110. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_disposal.svg +0 -0
  111. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-harddisk.svg +0 -0
  112. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-optical.svg +0 -0
  113. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_firewall.svg +0 -0
  114. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_home.svg +0 -0
  115. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_hub.svg +0 -0
  116. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_iPhone.svg +0 -0
  117. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_drive.svg +0 -0
  118. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_plc.svg +0 -0
  119. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_thermometer.svg +0 -0
  120. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_id_card.svg +0 -0
  121. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_image-generic.svg +0 -0
  122. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_laptop.svg +0 -0
  123. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lifecycle.svg +0 -0
  124. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lightning.svg +0 -0
  125. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-flash.svg +0 -0
  126. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-optical.svg +0 -0
  127. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-tape.svg +0 -0
  128. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_mobile_pda.svg +0 -0
  129. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_padlock.svg +0 -0
  130. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_printer.svg +0 -0
  131. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server.svg +0 -0
  132. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_application.svg +0 -0
  133. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_database.svg +0 -0
  134. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_directory.svg +0 -0
  135. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_distribution.svg +0 -0
  136. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_file.svg +0 -0
  137. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_gateway.svg +0 -0
  138. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_identity.svg +0 -0
  139. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_mail.svg +0 -0
  140. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_media.svg +0 -0
  141. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_monitor.svg +0 -0
  142. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_proxy.svg +0 -0
  143. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_terminal.svg +0 -0
  144. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_web.svg +0 -0
  145. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-branch.svg +0 -0
  146. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-factory.svg +0 -0
  147. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-head-office.svg +0 -0
  148. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-neighbourhood.svg +0 -0
  149. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_audit.svg +0 -0
  150. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_black_hat.svg +0 -0
  151. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue.svg +0 -0
  152. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_security_specialist.svg +0 -0
  153. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_sysadmin.svg +0 -0
  154. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tester.svg +0 -0
  155. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tie.svg +0 -0
  156. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green.svg +0 -0
  157. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_architect.svg +0 -0
  158. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_business_manager.svg +0 -0
  159. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_developer.svg +0 -0
  160. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_operations.svg +0 -0
  161. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_project_manager.svg +0 -0
  162. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_service_manager.svg +0 -0
  163. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_warning.svg +0 -0
  164. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_large_group.svg +0 -0
  165. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_users_blue_green.svg +0 -0
  166. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_vpn.svg +0 -0
  167. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_warning.svg +0 -0
  168. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_wireless_network.svg +0 -0
  169. data/share/htdocs/{image → vendor/unknown/image}/.DS_Store +0 -0
  170. data/share/htdocs/{image → vendor/unknown/image}/add_icon.gif +0 -0
  171. data/share/htdocs/{image → vendor/unknown/image}/alertbad_icon.gif +0 -0
  172. data/share/htdocs/{image → vendor/unknown/image}/alertgood_icon.gif +0 -0
  173. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.jpg +0 -0
  174. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.png +0 -0
  175. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.jpg +0 -0
  176. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.png +0 -0
  177. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.jpg +0 -0
  178. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.png +0 -0
  179. data/share/htdocs/{image → vendor/unknown/image}/bottom-bg.gif +0 -0
  180. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.jpg +0 -0
  181. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.png +0 -0
  182. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.jpg +0 -0
  183. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.png +0 -0
  184. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.jpg +0 -0
  185. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.png +0 -0
  186. data/share/htdocs/{image → vendor/unknown/image}/icon-remove.gif +0 -0
  187. data/share/htdocs/{image → vendor/unknown/image}/indicator.gif +0 -0
  188. data/share/htdocs/{image → vendor/unknown/image}/laptop.png +0 -0
  189. data/share/htdocs/{image → vendor/unknown/image}/logo-bottom.gif +0 -0
  190. data/share/htdocs/{image → vendor/unknown/image}/nav-tab-arrow.gif +0 -0
  191. data/share/htdocs/{image → vendor/unknown/image}/norbit_big.gif +0 -0
  192. data/share/htdocs/{image → vendor/unknown/image}/norbit_clipart.png +0 -0
  193. data/share/htdocs/{image → vendor/unknown/image}/progress_bar.gif +0 -0
  194. data/share/htdocs/{image → vendor/unknown/image}/right-bg.gif +0 -0
  195. data/share/htdocs/{image → vendor/unknown/image}/sort_asc.png +0 -0
  196. data/share/htdocs/{image → vendor/unknown/image}/sort_asc_disabled.png +0 -0
  197. data/share/htdocs/{image → vendor/unknown/image}/sort_both.png +0 -0
  198. data/share/htdocs/{image → vendor/unknown/image}/sort_desc.png +0 -0
  199. data/share/htdocs/{image → vendor/unknown/image}/sort_desc_disabled.png +0 -0
  200. data/share/htdocs/{image → vendor/unknown/image}/spinner.gif +0 -0
  201. data/share/htdocs/{svg → vendor/unknown/svg}/ap.svg +0 -0
  202. data/share/htdocs/{svg → vendor/unknown/svg}/router.svg +0 -0
  203. metadata +198 -216
  204. data/example/demo/widgets/dashboard_tab.yaml +0 -28
  205. data/example/demo/widgets/download_tab.yaml +0 -42
  206. data/example/demo/widgets/edit_tab.yaml +0 -20
  207. data/example/demo/widgets/generator_tab.yaml +0 -12
  208. data/lib/omf-oml/endpoint.rb +0 -175
  209. data/lib/omf-oml/indexed_table.rb +0 -57
  210. data/lib/omf-oml/network.rb +0 -413
  211. data/lib/omf-oml/oml_tuple.rb +0 -62
  212. data/lib/omf-oml/schema.rb +0 -191
  213. data/lib/omf-oml/sequel/sequel_server.rb +0 -412
  214. data/lib/omf-oml/sql_row.rb +0 -302
  215. data/lib/omf-oml/sql_source.rb +0 -131
  216. data/lib/omf-oml/table.rb +0 -131
  217. data/lib/omf-oml/tuple.rb +0 -97
  218. data/lib/omf_oml.rb +0 -4
  219. data/share/htdocs/css/coderay.css +0 -127
  220. data/share/htdocs/css/ie.css +0 -40
  221. data/share/htdocs/css/lightbox.css +0 -62
  222. data/share/htdocs/css/scaffold.css +0 -74
  223. data/share/htdocs/css/screen.css +0 -1313
  224. data/share/htdocs/css/search.css +0 -102
  225. data/share/htdocs/css/table.css +0 -538
  226. data/share/htdocs/css/table2.css +0 -191
  227. data/share/htdocs/css/welcome.css +0 -103
  228. data/share/htdocs/css/wfob.css +0 -171
  229. data/share/htdocs/css/wshow.css +0 -69
  230. data/share/htdocs/gec9_demo.html +0 -39
  231. data/share/htdocs/images +0 -1
  232. data/share/htdocs/js/graph/histogram.js +0 -229
  233. data/share/htdocs/js/graph/line_chart.js +0 -342
  234. data/share/htdocs/js/graph/line_chart2.js +0 -232
  235. data/share/htdocs/js/graph/line_chart_fc.js +0 -94
  236. data/share/htdocs/js/graph/map.js +0 -85
  237. data/share/htdocs/js/graph/network.js +0 -591
  238. data/share/htdocs/js/graph/network2.js +0 -318
  239. data/share/htdocs/js/graph/pie_chart.js +0 -130
  240. data/share/htdocs/js/graph/table.js +0 -94
  241. data/share/htdocs/js/require2.js +0 -1998
  242. data/share/htdocs/js/timelines.js +0 -101
  243. data/share/htdocs/stylesheet/grid.css +0 -31
@@ -1,591 +0,0 @@
1
- L.provide('OML.network', ["/resource/vendor/d3/d3.js"], function () {
2
-
3
- OML['network'] = function(opts) {
4
- this.opts = opts || {};
5
- this.data = null;
6
-
7
- this.decl_properties = {
8
- nodes: [['key', 'key', {property: 'id'}],
9
- ['radius', 'int', 30],
10
- ['fill_color', 'color', 'blue'],
11
- ['stroke_width', 'int', 1],
12
- ['stroke_color', 'color', 'black'],
13
- ['x', 'int', 10],
14
- ['y', 'int', 10]
15
- ],
16
- links: [['key', 'key', {property: 'id'}],
17
- ['stroke_width', 'int', 2],
18
- ['stroke_color', 'color', 'black'],
19
- ['stroke_fill', 'color', 'blue'],
20
- ['from', 'index', {key: 'from_id', join_stream: 'nodes', join_key: 'id'}],
21
- ['to', 'index', {key: 'to_id', join_stream: 'nodes'}] // join_key: 'id' ... default
22
- ]
23
- };
24
-
25
- this.decl_color_func = {
26
- "green_yellow80_red": d3.scale.linear()
27
- .domain([0, 0.8, 1])
28
- .range(["green", "yellow", "red"]),
29
- "green_red": d3.scale.linear()
30
- .domain([0, 1])
31
- .range(["green", "red"])
32
- };
33
-
34
-
35
- this.init = function() {
36
- var o = this.opts;
37
- var self = this;
38
-
39
- var w = this.w = o['width'] || 700;
40
- var h = this.h = o['height'] || 400;
41
-
42
- var m = o['margin'] || {};
43
- var ml = m['left'] || 30;
44
- var mt = m['top'] || 20;
45
- var mr = m['right'] || 20;
46
- var mb = m['bottom'] || 20;
47
- var ca = this.chart_area = {x: ml, y: mb, w: w - ml - mr, h: h - mt - mb};
48
-
49
- var offset = o['offset'] || [0, 0];
50
-
51
- this.color = o['color'] || d3.scale.category10();
52
-
53
-
54
- var vis = this.init_svg(w, h);
55
-
56
- var g = this.base_layer = vis.append("svg:g")
57
- .attr("transform", "translate(0, " + h + ")")
58
- ;
59
-
60
- this.graph_layer = g.append("svg:g");
61
-
62
- var self = this;
63
- OHUB.bind("graph.highlighted", function(evt) {
64
- if (evt.source == self) return;
65
- self.on_highlighted(evt);
66
- });
67
-
68
- var schemas = this.schemas = {};
69
- _.map(o.schema, function(sa, name) {
70
- var schema = schemas[name] = {};
71
- _.map(sa, function(s, i) {
72
- s['index'] = i;
73
- schema[s.name] = s;
74
- })
75
- });
76
-
77
- var mapping = this.mapping = {};
78
- _.map(['nodes', 'links'], function(n) {
79
- var schema = schemas[n];
80
- // var schema = {};
81
- // _.map(o.schema[n], function(se, i) {
82
- // se['index'] = i;
83
- // schema[se.name] = se;
84
- // });
85
- var m = mapping[n] = {};
86
- var om = o.mapping[n] || {};
87
- _.map(self.decl_properties[n], function(a) {
88
- var pname = a[0]; var type = a[1]; var def = a[2];
89
- var descr = om[pname];
90
- // if (descr != undefined) {
91
- // if (descr['stream'] == undefined) descr['stream'] = n;
92
- // }
93
- m[pname] = self.create_mapping(pname, descr, n, type, def)
94
- });
95
- });
96
-
97
- var data = o.data;
98
- if (data) this.update(data);
99
-
100
- };
101
-
102
- this.append = function(a_data) {
103
- throw "DOESN'T WORK";
104
-
105
- var data = this.data;
106
- data.nodes = $.extend(data.nodes, a_data.nodes);
107
- data.links = $.extend(data.links, a_data.links);
108
- this.redraw();
109
- };
110
-
111
- this.update = function(sources) {
112
- if (! (sources instanceof Array)) {
113
- throw "Expected an array"
114
- }
115
- if (sources.length != 1) {
116
- throw "Can only process a SINGLE source"
117
- }
118
- var data_source = OML.data_sources[sources[0].stream];
119
- if ((this.data = data_source.events) == null) {
120
- throw "Missing events array in data source"
121
- }
122
-
123
-
124
- var data = this.data = {};
125
- _.each(sources, function(s) {
126
- data[s.stream] = s.events;
127
- });
128
-
129
- // clear indexed tables
130
- this.indexed_tables = {};
131
-
132
- this.redraw();
133
- };
134
-
135
- this.redraw = function() {
136
- var self = this;
137
- var data = this.data;
138
- var o = this.opts;
139
- var mapping = this.mapping; //o.mapping || {};
140
- var ca = this.chart_area;
141
-
142
- var x = function(v) {
143
- var x = v * ca.w + ca.x;
144
- return x;
145
- };
146
- var y = function(v) {
147
- var y = -1 * (v * ca.h + ca.y);
148
- return y;
149
- };
150
- // var c = d3.scale.linear()
151
- // .domain([0, 0.8, 1])
152
- // .range(["green", "yellow", "red"]);
153
- //
154
- // this._func = {};
155
- // var lmapping = mapping.link;
156
- // var lstroke = c(0);
157
- // var lstroke_width = 4;
158
- // if (typeof(lmapping) != "undefined") {
159
- // lstroke_width = this.property_mapper('stroke_width', lmapping.stroke_width, lstroke_width);
160
- // lstroke = this.property_mapper('stroke', lmapping.stroke_color, lstroke);
161
- // }
162
- // this._func.lstroke = lstroke;
163
- // this._func.lstroke_width = lstroke_width;
164
- //
165
- // var nmapping = mapping.node;
166
- // var nfill = "white";
167
- // var nradius = 10;
168
- // if (typeof(nmapping) != "undefined") {
169
- // nfill = this.property_mapper('fill', nmapping.fill_color, nfill);
170
- // nradius = this.property_mapper('radius', nmapping.radius, nradius);
171
- // }
172
- // this._func.nfill = nfill;
173
- // this._func.nradius = nradius;
174
-
175
-
176
- var vis = this.base_layer;
177
- // var link = vis.selectAll("line.link")
178
- // .data(d3.values(data.links))
179
- // .style("stroke", lstroke)
180
- // .style("stroke-width", lstroke_width)
181
- // .attr("x1", function(d) {
182
- // var x1 = x(data.nodes[d.from]);
183
- // return x(data.nodes[d.from]);
184
- // })
185
- // .attr("y1", function(d) { return y(data.nodes[d.from]); })
186
- // .attr("x2", function(d) { return x(data.nodes[d.to]); })
187
- // .attr("y2", function(d) { return y(data.nodes[d.to]); })
188
- // .enter().append("svg:line")
189
- // .attr("class", "link")
190
- // .style("stroke", lstroke)
191
- // .style("stroke-width", lstroke_width)
192
- // .attr("x1", function(d) {
193
- // var x1 = x(data.nodes[d.from]);
194
- // return x(data.nodes[d.from]);
195
- // })
196
- // .attr("y1", function(d) { return y(data.nodes[d.from]); })
197
- // .attr("x2", function(d) { return x(data.nodes[d.to]); })
198
- // .attr("y2", function(d) { return y(data.nodes[d.to]); })
199
- // .on("mouseover", function(data) {
200
- // var name = data.name;
201
- // self.on_highlighted({'elements': [{'name': name, 'type': 'link'}]});
202
- // })
203
- // .on("mouseout", function() {
204
- // self.on_dehighlighted({});
205
- // })
206
-
207
- var lmapping = mapping.links;
208
- var nmapping = mapping.nodes;
209
-
210
- // curved line
211
- var line_f = function(d) {
212
- var a = 0.2;
213
- var b = 0.3;
214
- var o = 30;
215
-
216
- var from = lmapping.from(d);
217
- var to = lmapping.to(d);
218
-
219
- var x1 = x(nmapping.x(from));
220
- var y1 = y(nmapping.y(from));
221
- var x3 = x(nmapping.x(to));
222
- var y3 = y(nmapping.y(to));
223
-
224
- var dx = x3 - x1;
225
- var dy = y3 - y1;
226
- var l = Math.sqrt(dx * dx + dy * dy);
227
-
228
- var mx = x1 + a * dx;
229
- var my = y1 + a * dy;
230
- var x2 = mx - (dy * o / l)
231
- var y2 = my + (dx * o / l);
232
-
233
- var l = d3.svg.line().interpolate('basis');
234
- return l([[x1, y1], [x2, y2], [x3, y3]]);
235
- };
236
-
237
- var link2 = vis.selectAll("path.link")
238
- .data(d3.values(data.links))
239
- .style("stroke", lmapping.stroke_color)
240
- .style("stroke-width", lmapping.stroke_width)
241
- .attr("d", line_f)
242
- .enter().append("svg:path")
243
- .attr("class", "link")
244
- .style("stroke", lmapping.stroke_color)
245
- .style("stroke-width", lmapping.stroke_width)
246
- .attr("fill", "none")
247
- .attr("d", line_f)
248
- .on("mouseover", function(d) {
249
- var id = lmapping.key(d);
250
- self.on_highlighted({'elements': [{'id': id, 'type': 'link'}]});
251
- })
252
- .on("mouseout", function(d) {
253
- var id = lmapping.key(d);
254
- self.on_dehighlighted({'elements': [{'id': id, 'type': 'link'}]});
255
- })
256
- ;
257
-
258
-
259
- // .on("mouseover", function() {
260
- // d3.select(this).transition()
261
- // .style("stroke-width", function(d) {
262
- // return d.stroke_width + 3
263
- // })
264
- // .delay(0)
265
- // .duration(300)
266
- // })
267
- // .on("mouseout", function() {
268
- // d3.select(this).transition()
269
- // .style("stroke-width", function(d) {return d.stroke_width})
270
- // .delay(0)
271
- // .duration(300)
272
- // })
273
- ;
274
-
275
- var node = vis.selectAll("circle.node")
276
- .data(d3.values(data.nodes))
277
- .attr("cx", function(d) { return x(nmapping.x(d)) })
278
- .attr("cy", function(d) { return y(nmapping.y(d)) })
279
- .attr("r", nmapping.radius)
280
- .style("fill", nmapping.fill_color)
281
- .enter().append("svg:circle")
282
- .attr("class", "node")
283
- .attr("cx", function(d) { return x(nmapping.x(d)) })
284
- .attr("cy", function(d) { return y(nmapping.y(d)) })
285
- .attr("r", nmapping.radius)
286
- .style("fill", nmapping.fill_color)
287
- .style("stroke", nmapping.stroke_color)
288
- .style("stroke-width", nmapping.stroke_width)
289
- .attr("fixed", true)
290
- //.call(force.drag)
291
- .on("mouseover", function(d) {
292
- var id = nmapping.key(d);
293
- self.on_highlighted({'elements': [{'id': id, 'type': 'node'}]});
294
- })
295
- .on("mouseout", function(d) {
296
- var id = nmapping.key(d);
297
- self.on_dehighlighted({'elements': [{'id': id, 'type': 'node'}]});
298
- })
299
- .transition()
300
- .attr("r", nmapping.radius)
301
- .delay(0)
302
- ;
303
- };
304
-
305
- this.init_svg = function(w, h) {
306
- var opts = this.opts;
307
-
308
- //if (opts.svg) return opts.svg;
309
-
310
- var base_el = opts.base_el || "body";
311
- if (typeof(base_el) == "string") base_el = d3.select(base_el);
312
- var vis = opts.svg = base_el.append("svg:svg")
313
- .attr("width", w)
314
- .attr("height", h)
315
- .attr('class', 'oml-network');
316
- return vis;
317
- }
318
-
319
- this.on_highlighted = function(evt) {
320
- var els = evt.elements;
321
- var links = _.filter(els, function(el) { return el.type == 'link'});
322
- if (links.length > 0) { this._on_links_highlighted(links); }
323
- var nodes = _.filter(els, function(el) { return el.type == 'node'});
324
- if (nodes.length > 0) { this._on_nodes_highlighted(nodes); }
325
-
326
- if (evt.source == null) {
327
- evt.source = this;
328
- OHUB.trigger("graph.highlighted", evt);
329
- }
330
- }
331
-
332
- this.on_dehighlighted = function(evt) {
333
- this._on_links_dehighlighted();
334
- this._on_nodes_dehighlighted();
335
-
336
- if (evt.source == null) {
337
- evt.source = this;
338
- OHUB.trigger("graph.dehighlighted", evt);
339
- }
340
- }
341
-
342
- this._on_nodes_highlighted = function(nodes) {
343
- var names = _.map(nodes, function(el) { return el.id});
344
- var vis = this.base_layer;
345
- var key_f = this.mapping.nodes.key;
346
- vis.selectAll("circle.node")
347
- .filter(function(d) {
348
- var key = key_f(d);
349
- return ! _.include(names, key);
350
- })
351
- .transition()
352
- .style("stroke", "lightgray")
353
- .style("fill", "rgb(240,240,240)")
354
- .delay(0)
355
- .duration(300);
356
- }
357
-
358
-
359
- this._on_nodes_dehighlighted = function() {
360
- var vis = this.base_layer;
361
- var nmapping = this.mapping.nodes;
362
- vis.selectAll("circle.node")
363
- .transition()
364
- .style("fill", nmapping.fill_color)
365
- .style("stroke", nmapping.stroke_color)
366
- .delay(0)
367
- .duration(300);
368
- }
369
-
370
- this._on_links_highlighted = function(links) {
371
- var names = _.map(links, function(el) { return el.id});
372
- var vis = this.base_layer;
373
- var key_f = this.mapping.links.key;
374
- vis.selectAll("path.link")
375
- .filter(function(d) {
376
- var key = key_f(d);
377
- return ! _.include(names, key);
378
- })
379
- .transition()
380
- .style("opacity", 0.1)
381
- .delay(0)
382
- .duration(300);
383
- }
384
-
385
- this._on_links_dehighlighted = function() {
386
- var vis = this.base_layer;
387
- vis.selectAll("path.link")
388
- .transition()
389
- .style("opacity", 1.0)
390
- .delay(0)
391
- .duration(300)
392
- }
393
-
394
- // this.property_mapper = function(name, sm, def_value) {
395
- // var mapper_f;
396
- // if (typeof(sm) != "undefined") {
397
- // var prop = sm.property;
398
- // var scale = sm.scale ? sm.scale : 1;
399
- // var color_f = sm.color ? this.color_func[sm.color] : null;
400
- // var max = sm.max ? sm.max : 10;
401
- // var min = sm.min ? sm.min : 1;
402
- // if (color_f == null) {
403
- // mapper_f = function(d) {
404
- // var v = d[prop] * scale;
405
- // var t = typeof(v);
406
- // if (v > max) {
407
- // v = max;
408
- // } else if (v < min) {
409
- // v = min;
410
- // } else if (isNaN(v)) {
411
- // v = max;
412
- // }
413
- // d[name] = v;
414
- // return v;
415
- // }
416
- // } else {
417
- // mapper_f = function(d) {
418
- // var v = d[prop] * scale;
419
- // if (v > 1.0) {
420
- // v = 1.0;
421
- // } else if (v < 0) {
422
- // v = 0;
423
- // } else if (isNaN(v)) {
424
- // v = 0;
425
- // }
426
- // v = color_f(v);
427
- // d[name] = v;
428
- // return v;
429
- // }
430
- // }
431
- // } else {
432
- // mapper_f = def_value;
433
- // }
434
- // return mapper_f;
435
- // }
436
-
437
- // :radius => {:property => :capacity, :scale => 20, :min => 4},
438
- // :fill_color => {:property => :capacity, :color => :green_yellow80_red}
439
- // },
440
- // :link => {
441
- // :stroke_width => {:property => :store_forward, :scale => 5, :min => 3},
442
- // :stroke_color => {:property => :store_forward, :scale => 1.0 / 1.3, :color => :green_yellow80_red}
443
-
444
- this.create_mapping = function(mname, descr, stream, type, def) {
445
- var self = this;
446
- if (descr == undefined && typeof(def) == 'object') {
447
- descr = def
448
- }
449
- if (descr == undefined) {
450
- if (type == 'index') {
451
- return this.create_mapping(mname, def, stream, type, null);
452
- } else {
453
- return function(d) {
454
- return def;
455
- }
456
- }
457
- }
458
- if (descr.stream != undefined) {
459
- stream = descr.stream; // override stream
460
- }
461
- var schema = this.schema_for_stream(stream);
462
- if (schema == undefined) {
463
- throw "Can't find schema for stream '" + stream + "'.";
464
- }
465
-
466
- if (type == 'index') {
467
- var key = descr.key;
468
- if (key == undefined || stream == undefined) {
469
- throw "Missing 'key' or 'stream' in mapping declaration for '" + mname + "'.";
470
- }
471
- var col_schema = schema[key];
472
- if (col_schema == undefined) {
473
- throw "Unknown stream element '" + key + "'.";
474
- }
475
- var vindex = col_schema.index;
476
-
477
- var jstream = descr.join_stream;
478
- if (jstream == undefined) {
479
- throw "Missing join stream declaration in '" + mname + "'.";
480
- }
481
- var jschema = this.schema_for_stream(jstream);
482
- if (jschema == undefined) {
483
- throw "Can't find schema for stream '" + jstream + "'.";
484
- }
485
-
486
- var jkey = descr.join_key;
487
- if (jkey == undefined) jkey = 'id';
488
- var jcol_schema = jschema[jkey];
489
- if (jcol_schema == undefined) {
490
- throw "Unknown stream element '" + jkey + "' in '" + jstream + "'.";
491
- }
492
- var jindex = jcol_schema.index;
493
-
494
- return function(d) {
495
- var join = d[vindex];
496
- var t = self.get_indexed_table(jstream, jindex);
497
- var r = t[join];
498
- return r;
499
- }
500
- } else {
501
- var pname = descr.property;
502
- var col_schema = schema[pname];
503
- if (col_schema == undefined) {
504
- throw "Unknown property '" + pname + "'.";
505
- }
506
- var index = col_schema.index;
507
- switch (type) {
508
- case 'int':
509
- var scale = descr.scale;
510
- var min_value = descr.min;
511
- var max_value = descr.max;
512
- return function(d) {
513
- var v = d[index];
514
- if (scale != undefined) v = v * scale;
515
- if (min_value != undefined && v < min_value) v = min_value;
516
- if (max_value != undefined && v > max_value) v = max_value;
517
- return v;
518
- };
519
- case 'color':
520
- var color_fname = descr.color;
521
- if (color_fname == undefined) {
522
- throw "Missing color function for '" + mname + "'.";
523
- }
524
- var color_f = self.decl_color_func[color_fname];
525
- if (color_f == undefined) {
526
- throw "Unknown color function '" + color_fname + "'.";
527
- }
528
- var scale = descr.scale;
529
- var min_value = descr.min;
530
- return function(d) {
531
- var v = d[index];
532
- if (scale != undefined) v = v * scale;
533
- if (min_value != undefined && v < min_value) v = min_value;
534
- var color = color_f(v);
535
- return color;
536
- };
537
- case 'key' :
538
- return function(d) {
539
- return d[index];
540
- }
541
- default:
542
- throw "Unknown mapping type '" + type + "'";
543
- }
544
- }
545
- var i = 0;
546
- };
547
-
548
- /*
549
- * This returns a table held in +data+ as a hash with the key taken
550
- * from the respective row at +index+.
551
- *
552
- * NOTE: This is a bit hack right now. We should really rap the sources/tables
553
- * into their own object.
554
- */
555
- this.get_indexed_table = function(stream, index) {
556
- var itbl_name = stream + index;
557
- var t = this.indexed_tables[itbl_name];
558
- if (t == undefined) {
559
- // build it
560
- var t = this.indexed_tables[itbl_name] = {};
561
- var st = this.data[stream];
562
- if (st == undefined) {
563
- throw "Unknown stream '" + stream + "'.";
564
- }
565
- _.each(st, function(r) {
566
- var idx = r[index]
567
- t[idx] = r;
568
- })
569
- }
570
- return t;
571
- }
572
-
573
- /*
574
- * Return schema for +stream+.
575
- */
576
- this.schema_for_stream = function(stream) {
577
- return this.schemas[stream];
578
- }
579
-
580
- this.init(opts);
581
- };
582
- })
583
-
584
-
585
- /*
586
- Local Variables:
587
- mode: Javascript
588
- tab-width: 2
589
- indent-tabs-mode: nil
590
- End:
591
- */