maglev-webtools 0.2.1 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. data/README.rdoc +38 -29
  2. data/bin/webtools +22 -1
  3. data/lib/web_tools/code_browser.rb +156 -0
  4. data/lib/web_tools/debugger.rb +96 -199
  5. data/lib/web_tools/info.rb +1 -3
  6. data/lib/web_tools/method_list.rb +67 -0
  7. data/lib/web_tools/middleware/debugger.rb +10 -16
  8. data/lib/web_tools/object_log.rb +24 -0
  9. data/lib/web_tools/session_list.rb +119 -0
  10. data/lib/web_tools/shared_page_cache.rb +30 -0
  11. data/lib/web_tools/stat_process.rb +24 -0
  12. data/lib/web_tools/statistics.rb +14 -0
  13. data/lib/web_tools/support/app_model.rb +66 -101
  14. data/lib/web_tools/support/code_browser.rb +88 -86
  15. data/lib/web_tools/support/debugger.rb +303 -0
  16. data/lib/web_tools/support/error_log.rb +33 -0
  17. data/lib/web_tools/support/ruby.rb +60 -121
  18. data/lib/web_tools/support/service_helper.rb +38 -10
  19. data/lib/web_tools/support/smalltalk_extensions.rb +12 -0
  20. data/lib/web_tools/tool.rb +48 -0
  21. data/lib/web_tools/ui.rb +14 -53
  22. data/lib/web_tools/version_report.rb +29 -0
  23. data/lib/web_tools/workspace.rb +77 -0
  24. data/lib/web_tools.rb +14 -4
  25. data/public/CodeBrowser.html +51 -0
  26. data/public/CodeMirror/LICENSE +19 -0
  27. data/public/CodeMirror/css/codemirror.css +67 -0
  28. data/public/CodeMirror/css/default.css +18 -0
  29. data/public/CodeMirror/js/codemirror.js +2131 -0
  30. data/public/CodeMirror/js/ruby.js +195 -0
  31. data/public/CodeMirror/js/smalltalk.js +139 -0
  32. data/public/Debugger.html +28 -0
  33. data/public/MethodList.html +20 -0
  34. data/public/ObjectLog.html +20 -0
  35. data/public/SessionList.html +31 -0
  36. data/public/SharedPageCache.html +78 -0
  37. data/public/Statistics.html +64 -0
  38. data/public/VersionReport.html +50 -0
  39. data/public/Workspace.html +39 -0
  40. data/public/css/CodeBrowser.css +24 -0
  41. data/public/css/Debugger.css +32 -0
  42. data/public/css/MethodList.css +8 -0
  43. data/public/css/ObjectLog.css +5 -0
  44. data/public/css/SessionList.css +9 -0
  45. data/public/css/Statistics.css +24 -0
  46. data/public/{stylesheets → css}/base/images/ui-anim_basic_16x16.gif +0 -0
  47. data/public/{stylesheets → css}/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  48. data/public/{stylesheets → css}/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  49. data/public/{stylesheets → css}/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  50. data/public/{stylesheets → css}/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  51. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  52. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  53. data/public/{stylesheets → css}/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  54. data/public/{stylesheets → css}/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  55. data/public/{stylesheets → css}/base/images/ui-icons_222222_256x240.png +0 -0
  56. data/public/{stylesheets → css}/base/images/ui-icons_2e83ff_256x240.png +0 -0
  57. data/public/{stylesheets → css}/base/images/ui-icons_454545_256x240.png +0 -0
  58. data/public/{stylesheets → css}/base/images/ui-icons_888888_256x240.png +0 -0
  59. data/public/{stylesheets → css}/base/images/ui-icons_cd0a0a_256x240.png +0 -0
  60. data/public/{stylesheets → css}/base/jquery.ui.accordion.css +0 -0
  61. data/public/{stylesheets → css}/base/jquery.ui.all.css +0 -0
  62. data/public/{stylesheets → css}/base/jquery.ui.autocomplete.css +0 -0
  63. data/public/{stylesheets → css}/base/jquery.ui.base.css +0 -0
  64. data/public/{stylesheets → css}/base/jquery.ui.button.css +0 -0
  65. data/public/{stylesheets → css}/base/jquery.ui.core.css +0 -0
  66. data/public/{stylesheets → css}/base/jquery.ui.datepicker.css +0 -0
  67. data/public/{stylesheets → css}/base/jquery.ui.dialog.css +0 -0
  68. data/public/{stylesheets → css}/base/jquery.ui.progressbar.css +0 -0
  69. data/public/{stylesheets → css}/base/jquery.ui.resizable.css +0 -0
  70. data/public/{stylesheets → css}/base/jquery.ui.selectable.css +0 -0
  71. data/public/{stylesheets → css}/base/jquery.ui.slider.css +0 -0
  72. data/public/{stylesheets → css}/base/jquery.ui.tabs.css +0 -0
  73. data/public/{stylesheets → css}/base/jquery.ui.theme.css +0 -0
  74. data/public/css/editor.css +25 -0
  75. data/public/css/jjmenu.css +33 -0
  76. data/public/css/menuitem.gif +0 -0
  77. data/public/css/more.gif +0 -0
  78. data/public/{stylesheets → css}/reset.css +1 -1
  79. data/public/css/smoothness/images/ui-anim_basic_16x16.gif +0 -0
  80. data/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  81. data/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  82. data/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  83. data/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  84. data/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  85. data/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  86. data/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  87. data/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  88. data/public/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  89. data/public/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  90. data/public/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  91. data/public/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  92. data/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  93. data/public/css/smoothness/jquery-ui.css +489 -0
  94. data/public/css/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
  95. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  96. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  97. data/public/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  98. data/public/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  99. data/public/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  100. data/public/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  101. data/public/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  102. data/public/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  103. data/public/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  104. data/public/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  105. data/public/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  106. data/public/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  107. data/public/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  108. data/public/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  109. data/public/css/ui-lightness/jquery-ui.css +489 -0
  110. data/public/css/webtools.css +65 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/flot/API.txt +1201 -0
  113. data/public/flot/FAQ.txt +76 -0
  114. data/public/flot/LICENSE.txt +22 -0
  115. data/public/flot/Makefile +9 -0
  116. data/public/flot/NEWS.txt +508 -0
  117. data/public/flot/PLUGINS.txt +137 -0
  118. data/public/flot/README.txt +90 -0
  119. data/public/flot/examples/ajax.html +143 -0
  120. data/public/flot/examples/annotating.html +75 -0
  121. data/public/flot/examples/arrow-down.gif +0 -0
  122. data/public/flot/examples/arrow-left.gif +0 -0
  123. data/public/flot/examples/arrow-right.gif +0 -0
  124. data/public/flot/examples/arrow-up.gif +0 -0
  125. data/public/flot/examples/basic.html +38 -0
  126. data/public/flot/examples/data-eu-gdp-growth-1.json +4 -0
  127. data/public/flot/examples/data-eu-gdp-growth-2.json +4 -0
  128. data/public/flot/examples/data-eu-gdp-growth-3.json +4 -0
  129. data/public/flot/examples/data-eu-gdp-growth-4.json +4 -0
  130. data/public/flot/examples/data-eu-gdp-growth-5.json +4 -0
  131. data/public/flot/examples/data-eu-gdp-growth.json +4 -0
  132. data/public/flot/examples/data-japan-gdp-growth.json +4 -0
  133. data/public/flot/examples/data-usa-gdp-growth.json +4 -0
  134. data/public/flot/examples/graph-types.html +75 -0
  135. data/public/flot/examples/hs-2004-27-a-large_web.jpg +0 -0
  136. data/public/flot/examples/image.html +45 -0
  137. data/public/flot/examples/index.html +44 -0
  138. data/public/flot/examples/interacting-axes.html +97 -0
  139. data/public/flot/examples/interacting.html +93 -0
  140. data/public/flot/examples/layout.css +6 -0
  141. data/public/flot/examples/multiple-axes.html +60 -0
  142. data/public/flot/examples/navigate.html +118 -0
  143. data/public/flot/examples/percentiles.html +57 -0
  144. data/public/flot/examples/pie.html +756 -0
  145. data/public/flot/examples/realtime.html +83 -0
  146. data/public/flot/examples/resize.html +61 -0
  147. data/public/flot/examples/selection.html +114 -0
  148. data/public/flot/examples/setting-options.html +61 -0
  149. data/public/flot/examples/stacking.html +77 -0
  150. data/public/flot/examples/symbols.html +49 -0
  151. data/public/flot/examples/thresholding.html +54 -0
  152. data/public/flot/examples/time.html +71 -0
  153. data/public/flot/examples/tracking.html +95 -0
  154. data/public/flot/examples/turning-series.html +98 -0
  155. data/public/flot/examples/visitors.html +90 -0
  156. data/public/flot/examples/zooming.html +98 -0
  157. data/public/flot/excanvas.js +1427 -0
  158. data/public/flot/excanvas.min.js +1 -0
  159. data/public/flot/jquery.colorhelpers.js +179 -0
  160. data/public/flot/jquery.colorhelpers.min.js +1 -0
  161. data/public/flot/jquery.flot.crosshair.js +167 -0
  162. data/public/flot/jquery.flot.crosshair.min.js +1 -0
  163. data/public/flot/jquery.flot.fillbetween.js +183 -0
  164. data/public/flot/jquery.flot.fillbetween.min.js +1 -0
  165. data/public/flot/jquery.flot.image.js +238 -0
  166. data/public/flot/jquery.flot.image.min.js +1 -0
  167. data/public/flot/jquery.flot.js +2599 -0
  168. data/public/flot/jquery.flot.min.js +6 -0
  169. data/public/flot/jquery.flot.navigate.js +336 -0
  170. data/public/flot/jquery.flot.navigate.min.js +1 -0
  171. data/public/flot/jquery.flot.pie.js +750 -0
  172. data/public/flot/jquery.flot.pie.min.js +1 -0
  173. data/public/flot/jquery.flot.resize.js +60 -0
  174. data/public/flot/jquery.flot.resize.min.js +1 -0
  175. data/public/flot/jquery.flot.selection.js +344 -0
  176. data/public/flot/jquery.flot.selection.min.js +1 -0
  177. data/public/flot/jquery.flot.stack.js +184 -0
  178. data/public/flot/jquery.flot.stack.min.js +1 -0
  179. data/public/flot/jquery.flot.symbol.js +70 -0
  180. data/public/flot/jquery.flot.symbol.min.js +1 -0
  181. data/public/flot/jquery.flot.threshold.js +103 -0
  182. data/public/flot/jquery.flot.threshold.min.js +1 -0
  183. data/public/flot/jquery.js +8316 -0
  184. data/public/flot/jquery.min.js +23 -0
  185. data/public/genPacking.pl +30 -0
  186. data/public/index.html +28 -0
  187. data/public/install.tpz +66 -0
  188. data/public/installAndRun.tpz +5 -0
  189. data/public/jsTree/jquery.jstree.js +3510 -0
  190. data/public/jsTree/themes/default/d.gif +0 -0
  191. data/public/jsTree/themes/default/d.png +0 -0
  192. data/public/jsTree/themes/default/style.css +73 -0
  193. data/public/jsTree/themes/default/throbber.gif +0 -0
  194. data/public/readMe.txt +9 -0
  195. data/public/scripts/CodeBrowser.js +645 -0
  196. data/public/scripts/Debugger.js +134 -0
  197. data/public/scripts/MethodList.js +72 -0
  198. data/public/scripts/ObjectLog.js +59 -0
  199. data/public/scripts/SessionList.js +164 -0
  200. data/public/scripts/Statistics.js +266 -0
  201. data/public/scripts/editor.js +430 -0
  202. data/public/scripts/jjmenu.js +375 -0
  203. data/public/scripts/jquery-ui.js +1012 -0
  204. data/public/scripts/jquery.js +154 -0
  205. data/public/scripts/webtools.js +374 -0
  206. data/public/src/CodeBrowser.gs +416 -0
  207. data/public/src/Debugger.gs +132 -0
  208. data/public/src/MethodList.gs +130 -0
  209. data/public/src/ObjectLog.gs +73 -0
  210. data/public/src/Server.gs +544 -0
  211. data/public/src/SessionList.gs +172 -0
  212. data/public/src/SharedPageCache.gs +66 -0
  213. data/public/src/StatProcess.gs +280 -0
  214. data/public/src/StatProcessType.gs +242 -0
  215. data/public/src/StatStatistic.gs +381 -0
  216. data/public/src/Statistics.gs +222 -0
  217. data/public/src/Statmonitor.gs +490 -0
  218. data/public/src/Tool.gs +86 -0
  219. data/public/src/VersionReport.gs +52 -0
  220. data/public/src/Workspace.gs +163 -0
  221. data/views/debugger.rhtml +6 -9
  222. metadata +344 -243
  223. data/lib/web_tools/#debugger.rb# +0 -212
  224. data/lib/web_tools/browser.rb +0 -45
  225. data/public/images/favicon.ico +0 -0
  226. data/public/javascript/CodeMirror/LICENSE +0 -23
  227. data/public/javascript/CodeMirror/css/Smalltalk.css +0 -34
  228. data/public/javascript/CodeMirror/js/codemirror.js +0 -582
  229. data/public/javascript/CodeMirror/js/editor.js +0 -1671
  230. data/public/javascript/CodeMirror/js/highlight.js +0 -68
  231. data/public/javascript/CodeMirror/js/parseSmalltalk.js +0 -126
  232. data/public/javascript/CodeMirror/js/parsedummy.js +0 -32
  233. data/public/javascript/CodeMirror/js/select.js +0 -699
  234. data/public/javascript/CodeMirror/js/stringstream.js +0 -159
  235. data/public/javascript/CodeMirror/js/tokenize.js +0 -57
  236. data/public/javascript/CodeMirror/js/undo.js +0 -413
  237. data/public/javascript/CodeMirror/js/util.js +0 -133
  238. data/public/javascript/CodeMirror/testSmalltalkParser.html +0 -116
  239. data/public/javascript/ace/ace-uncompressed.js +0 -17299
  240. data/public/javascript/ace/ace.js +0 -1
  241. data/public/javascript/ace/keybinding-emacs.js +0 -1
  242. data/public/javascript/ace/keybinding-vim.js +0 -1
  243. data/public/javascript/ace/mode-c_cpp.js +0 -1
  244. data/public/javascript/ace/mode-clojure.js +0 -1
  245. data/public/javascript/ace/mode-coffee.js +0 -1
  246. data/public/javascript/ace/mode-csharp.js +0 -1
  247. data/public/javascript/ace/mode-css.js +0 -1
  248. data/public/javascript/ace/mode-groovy.js +0 -1
  249. data/public/javascript/ace/mode-html.js +0 -1
  250. data/public/javascript/ace/mode-java.js +0 -1
  251. data/public/javascript/ace/mode-javascript.js +0 -1
  252. data/public/javascript/ace/mode-json.js +0 -1
  253. data/public/javascript/ace/mode-lua.js +0 -1
  254. data/public/javascript/ace/mode-markdown.js +0 -1
  255. data/public/javascript/ace/mode-ocaml.js +0 -1
  256. data/public/javascript/ace/mode-perl.js +0 -1
  257. data/public/javascript/ace/mode-php.js +0 -1
  258. data/public/javascript/ace/mode-python.js +0 -1
  259. data/public/javascript/ace/mode-ruby.js +0 -1
  260. data/public/javascript/ace/mode-scad.js +0 -1
  261. data/public/javascript/ace/mode-scala.js +0 -1
  262. data/public/javascript/ace/mode-scss.js +0 -1
  263. data/public/javascript/ace/mode-svg.js +0 -1
  264. data/public/javascript/ace/mode-textile.js +0 -1
  265. data/public/javascript/ace/mode-xml.js +0 -1
  266. data/public/javascript/ace/theme-clouds.js +0 -1
  267. data/public/javascript/ace/theme-clouds_midnight.js +0 -1
  268. data/public/javascript/ace/theme-cobalt.js +0 -1
  269. data/public/javascript/ace/theme-crimson_editor.js +0 -1
  270. data/public/javascript/ace/theme-dawn.js +0 -1
  271. data/public/javascript/ace/theme-eclipse.js +0 -1
  272. data/public/javascript/ace/theme-idle_fingers.js +0 -1
  273. data/public/javascript/ace/theme-kr_theme.js +0 -1
  274. data/public/javascript/ace/theme-merbivore.js +0 -1
  275. data/public/javascript/ace/theme-merbivore_soft.js +0 -1
  276. data/public/javascript/ace/theme-mono_industrial.js +0 -1
  277. data/public/javascript/ace/theme-monokai.js +0 -1
  278. data/public/javascript/ace/theme-pastel_on_dark.js +0 -1
  279. data/public/javascript/ace/theme-solarized_dark.js +0 -1
  280. data/public/javascript/ace/theme-solarized_light.js +0 -1
  281. data/public/javascript/ace/theme-textmate.js +0 -1
  282. data/public/javascript/ace/theme-twilight.js +0 -1
  283. data/public/javascript/ace/theme-vibrant_ink.js +0 -1
  284. data/public/javascript/ace/worker-coffee.js +0 -1
  285. data/public/javascript/ace/worker-css.js +0 -1
  286. data/public/javascript/ace/worker-javascript.js +0 -1
  287. data/public/javascript/webtools/browser.js +0 -260
  288. data/public/javascript/webtools/debugger.coffee +0 -286
  289. data/public/javascript/webtools/debugger.js +0 -366
  290. data/public/javascript/webtools/sessions.coffee +0 -17
  291. data/public/javascript/webtools/sessions.js +0 -27
  292. data/public/javascript/webtools/version.coffee +0 -14
  293. data/public/javascript/webtools/version.js +0 -20
  294. data/public/stylesheets/jquery.contextMenu.css +0 -62
  295. data/public/stylesheets/webtools.css +0 -53
  296. data/public/test.html +0 -47
@@ -0,0 +1 @@
1
+ (function(b){function c(D){var h=null;var L=null;var n=null;var B=null;var p=null;var M=0;var F=true;var o=10;var w=0.95;var A=0;var d=false;var z=false;var j=[];D.hooks.processOptions.push(g);D.hooks.bindEvents.push(e);function g(O,N){if(N.series.pie.show){N.grid.show=false;if(N.series.pie.label.show=="auto"){if(N.legend.show){N.series.pie.label.show=false}else{N.series.pie.label.show=true}}if(N.series.pie.radius=="auto"){if(N.series.pie.label.show){N.series.pie.radius=3/4}else{N.series.pie.radius=1}}if(N.series.pie.tilt>1){N.series.pie.tilt=1}if(N.series.pie.tilt<0){N.series.pie.tilt=0}O.hooks.processDatapoints.push(E);O.hooks.drawOverlay.push(H);O.hooks.draw.push(r)}}function e(P,N){var O=P.getOptions();if(O.series.pie.show&&O.grid.hoverable){N.unbind("mousemove").mousemove(t)}if(O.series.pie.show&&O.grid.clickable){N.unbind("click").click(l)}}function G(O){var P="";function N(S,T){if(!T){T=0}for(var R=0;R<S.length;++R){for(var Q=0;Q<T;Q++){P+="\t"}if(typeof S[R]=="object"){P+=""+R+":\n";N(S[R],T+1)}else{P+=""+R+": "+S[R]+"\n"}}}N(O);alert(P)}function q(P){for(var N=0;N<P.length;++N){var O=parseFloat(P[N].data[0][1]);if(O){M+=O}}}function E(Q,N,O,P){if(!d){d=true;h=Q.getCanvas();L=b(h).parent();a=Q.getOptions();Q.setData(K(Q.getData()))}}function I(){A=L.children().filter(".legend").children().width();n=Math.min(h.width,(h.height/a.series.pie.tilt))/2;p=(h.height/2)+a.series.pie.offset.top;B=(h.width/2);if(a.series.pie.offset.left=="auto"){if(a.legend.position.match("w")){B+=A/2}else{B-=A/2}}else{B+=a.series.pie.offset.left}if(B<n){B=n}else{if(B>h.width-n){B=h.width-n}}}function v(O){for(var N=0;N<O.length;++N){if(typeof(O[N].data)=="number"){O[N].data=[[1,O[N].data]]}else{if(typeof(O[N].data)=="undefined"||typeof(O[N].data[0])=="undefined"){if(typeof(O[N].data)!="undefined"&&typeof(O[N].data.label)!="undefined"){O[N].label=O[N].data.label}O[N].data=[[1,0]]}}}return O}function K(Q){Q=v(Q);q(Q);var P=0;var S=0;var N=a.series.pie.combine.color;var R=[];for(var O=0;O<Q.length;++O){Q[O].data[0][1]=parseFloat(Q[O].data[0][1]);if(!Q[O].data[0][1]){Q[O].data[0][1]=0}if(Q[O].data[0][1]/M<=a.series.pie.combine.threshold){P+=Q[O].data[0][1];S++;if(!N){N=Q[O].color}}else{R.push({data:[[1,Q[O].data[0][1]]],color:Q[O].color,label:Q[O].label,angle:(Q[O].data[0][1]*(Math.PI*2))/M,percent:(Q[O].data[0][1]/M*100)})}}if(S>0){R.push({data:[[1,P]],color:N,label:a.series.pie.combine.label,angle:(P*(Math.PI*2))/M,percent:(P/M*100)})}return R}function r(S,Q){if(!L){return}ctx=Q;I();var T=S.getData();var P=0;while(F&&P<o){F=false;if(P>0){n*=w}P+=1;N();if(a.series.pie.tilt<=0.8){O()}R()}if(P>=o){N();L.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>')}if(S.setSeries&&S.insertLegend){S.setSeries(T);S.insertLegend()}function N(){ctx.clearRect(0,0,h.width,h.height);L.children().filter(".pieLabel, .pieLabelBackground").remove()}function O(){var Z=5;var Y=15;var W=10;var X=0.02;if(a.series.pie.radius>1){var U=a.series.pie.radius}else{var U=n*a.series.pie.radius}if(U>=(h.width/2)-Z||U*a.series.pie.tilt>=(h.height/2)-Y||U<=W){return}ctx.save();ctx.translate(Z,Y);ctx.globalAlpha=X;ctx.fillStyle="#000";ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);for(var V=1;V<=W;V++){ctx.beginPath();ctx.arc(0,0,U,0,Math.PI*2,false);ctx.fill();U-=V}ctx.restore()}function R(){startAngle=Math.PI*a.series.pie.startAngle;if(a.series.pie.radius>1){var U=a.series.pie.radius}else{var U=n*a.series.pie.radius}ctx.save();ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);ctx.save();var Y=startAngle;for(var W=0;W<T.length;++W){T[W].startAngle=Y;X(T[W].angle,T[W].color,true)}ctx.restore();ctx.save();ctx.lineWidth=a.series.pie.stroke.width;Y=startAngle;for(var W=0;W<T.length;++W){X(T[W].angle,a.series.pie.stroke.color,false)}ctx.restore();J(ctx);if(a.series.pie.label.show){V()}ctx.restore();function X(ab,Z,aa){if(ab<=0){return}if(aa){ctx.fillStyle=Z}else{ctx.strokeStyle=Z;ctx.lineJoin="round"}ctx.beginPath();if(Math.abs(ab-Math.PI*2)>1e-9){ctx.moveTo(0,0)}else{if(b.browser.msie){ab-=0.0001}}ctx.arc(0,0,U,Y,Y+ab,false);ctx.closePath();Y+=ab;if(aa){ctx.fill()}else{ctx.stroke()}}function V(){var ac=startAngle;if(a.series.pie.label.radius>1){var Z=a.series.pie.label.radius}else{var Z=n*a.series.pie.label.radius}for(var ab=0;ab<T.length;++ab){if(T[ab].percent>=a.series.pie.label.threshold*100){aa(T[ab],ac,ab)}ac+=T[ab].angle}function aa(ap,ai,ag){if(ap.data[0][1]==0){return}var ar=a.legend.labelFormatter,aq,ae=a.series.pie.label.formatter;if(ar){aq=ar(ap.label,ap)}else{aq=ap.label}if(ae){aq=ae(aq,ap)}var aj=((ai+ap.angle)+ai)/2;var ao=B+Math.round(Math.cos(aj)*Z);var am=p+Math.round(Math.sin(aj)*Z)*a.series.pie.tilt;var af='<span class="pieLabel" id="pieLabel'+ag+'" style="position:absolute;top:'+am+"px;left:"+ao+'px;">'+aq+"</span>";L.append(af);var an=L.children("#pieLabel"+ag);var ad=(am-an.height()/2);var ah=(ao-an.width()/2);an.css("top",ad);an.css("left",ah);if(0-ad>0||0-ah>0||h.height-(ad+an.height())<0||h.width-(ah+an.width())<0){F=true}if(a.series.pie.label.background.opacity!=0){var ak=a.series.pie.label.background.color;if(ak==null){ak=ap.color}var al="top:"+ad+"px;left:"+ah+"px;";b('<div class="pieLabelBackground" style="position:absolute;width:'+an.width()+"px;height:"+an.height()+"px;"+al+"background-color:"+ak+';"> </div>').insertBefore(an).css("opacity",a.series.pie.label.background.opacity)}}}}}function J(N){if(a.series.pie.innerRadius>0){N.save();innerRadius=a.series.pie.innerRadius>1?a.series.pie.innerRadius:n*a.series.pie.innerRadius;N.globalCompositeOperation="destination-out";N.beginPath();N.fillStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.fill();N.closePath();N.restore();N.save();N.beginPath();N.strokeStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.stroke();N.closePath();N.restore()}}function s(Q,R){for(var S=false,P=-1,N=Q.length,O=N-1;++P<N;O=P){((Q[P][1]<=R[1]&&R[1]<Q[O][1])||(Q[O][1]<=R[1]&&R[1]<Q[P][1]))&&(R[0]<(Q[O][0]-Q[P][0])*(R[1]-Q[P][1])/(Q[O][1]-Q[P][1])+Q[P][0])&&(S=!S)}return S}function u(R,P){var T=D.getData(),O=D.getOptions(),N=O.series.pie.radius>1?O.series.pie.radius:n*O.series.pie.radius;for(var Q=0;Q<T.length;++Q){var S=T[Q];if(S.pie.show){ctx.save();ctx.beginPath();ctx.moveTo(0,0);ctx.arc(0,0,N,S.startAngle,S.startAngle+S.angle,false);ctx.closePath();x=R-B;y=P-p;if(ctx.isPointInPath){if(ctx.isPointInPath(R-B,P-p)){ctx.restore();return{datapoint:[S.percent,S.data],dataIndex:0,series:S,seriesIndex:Q}}}else{p1X=(N*Math.cos(S.startAngle));p1Y=(N*Math.sin(S.startAngle));p2X=(N*Math.cos(S.startAngle+(S.angle/4)));p2Y=(N*Math.sin(S.startAngle+(S.angle/4)));p3X=(N*Math.cos(S.startAngle+(S.angle/2)));p3Y=(N*Math.sin(S.startAngle+(S.angle/2)));p4X=(N*Math.cos(S.startAngle+(S.angle/1.5)));p4Y=(N*Math.sin(S.startAngle+(S.angle/1.5)));p5X=(N*Math.cos(S.startAngle+S.angle));p5Y=(N*Math.sin(S.startAngle+S.angle));arrPoly=[[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];arrPoint=[x,y];if(s(arrPoly,arrPoint)){ctx.restore();return{datapoint:[S.percent,S.data],dataIndex:0,series:S,seriesIndex:Q}}}ctx.restore()}}return null}function t(N){m("plothover",N)}function l(N){m("plotclick",N)}function m(N,T){var O=D.offset(),R=parseInt(T.pageX-O.left),P=parseInt(T.pageY-O.top),V=u(R,P);if(a.grid.autoHighlight){for(var Q=0;Q<j.length;++Q){var S=j[Q];if(S.auto==N&&!(V&&S.series==V.series)){f(S.series)}}}if(V){k(V.series,N)}var U={pageX:T.pageX,pageY:T.pageY};L.trigger(N,[U,V])}function k(O,P){if(typeof O=="number"){O=series[O]}var N=C(O);if(N==-1){j.push({series:O,auto:P});D.triggerRedrawOverlay()}else{if(!P){j[N].auto=false}}}function f(O){if(O==null){j=[];D.triggerRedrawOverlay()}if(typeof O=="number"){O=series[O]}var N=C(O);if(N!=-1){j.splice(N,1);D.triggerRedrawOverlay()}}function C(P){for(var N=0;N<j.length;++N){var O=j[N];if(O.series==P){return N}}return -1}function H(Q,R){var P=Q.getOptions();var N=P.series.pie.radius>1?P.series.pie.radius:n*P.series.pie.radius;R.save();R.translate(B,p);R.scale(1,P.series.pie.tilt);for(i=0;i<j.length;++i){O(j[i].series)}J(R);R.restore();function O(S){if(S.angle<0){return}R.fillStyle="rgba(255, 255, 255, "+P.series.pie.highlight.opacity+")";R.beginPath();if(Math.abs(S.angle-Math.PI*2)>1e-9){R.moveTo(0,0)}R.arc(0,0,N,S.startAngle,S.startAngle+S.angle,false);R.closePath();R.fill()}}}var a={series:{pie:{show:false,radius:"auto",innerRadius:0,startAngle:3/2,tilt:1,offset:{top:0,left:"auto"},stroke:{color:"#FFF",width:1},label:{show:"auto",formatter:function(d,e){return'<div style="font-size:x-small;text-align:center;padding:2px;color:'+e.color+';">'+d+"<br/>"+Math.round(e.percent)+"%</div>"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:0.5}}}};b.plot.plugins.push({init:c,options:a,name:"pie",version:"1.0"})})(jQuery);
@@ -0,0 +1,60 @@
1
+ /*
2
+ Flot plugin for automatically redrawing plots when the placeholder
3
+ size changes, e.g. on window resizes.
4
+
5
+ It works by listening for changes on the placeholder div (through the
6
+ jQuery resize event plugin) - if the size changes, it will redraw the
7
+ plot.
8
+
9
+ There are no options. If you need to disable the plugin for some
10
+ plots, you can just fix the size of their placeholders.
11
+ */
12
+
13
+
14
+ /* Inline dependency:
15
+ * jQuery resize event - v1.1 - 3/14/2010
16
+ * http://benalman.com/projects/jquery-resize-plugin/
17
+ *
18
+ * Copyright (c) 2010 "Cowboy" Ben Alman
19
+ * Dual licensed under the MIT and GPL licenses.
20
+ * http://benalman.com/about/license/
21
+ */
22
+ (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
23
+
24
+
25
+ (function ($) {
26
+ var options = { }; // no options
27
+
28
+ function init(plot) {
29
+ function onResize() {
30
+ var placeholder = plot.getPlaceholder();
31
+
32
+ // somebody might have hidden us and we can't plot
33
+ // when we don't have the dimensions
34
+ if (placeholder.width() == 0 || placeholder.height() == 0)
35
+ return;
36
+
37
+ plot.resize();
38
+ plot.setupGrid();
39
+ plot.draw();
40
+ }
41
+
42
+ function bindEvents(plot, eventHolder) {
43
+ plot.getPlaceholder().resize(onResize);
44
+ }
45
+
46
+ function shutdown(plot, eventHolder) {
47
+ plot.getPlaceholder().unbind("resize", onResize);
48
+ }
49
+
50
+ plot.hooks.bindEvents.push(bindEvents);
51
+ plot.hooks.shutdown.push(shutdown);
52
+ }
53
+
54
+ $.plot.plugins.push({
55
+ init: init,
56
+ options: options,
57
+ name: 'resize',
58
+ version: '1.0'
59
+ });
60
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this);(function(b){var a={};function c(f){function e(){var h=f.getPlaceholder();if(h.width()==0||h.height()==0){return}f.resize();f.setupGrid();f.draw()}function g(i,h){i.getPlaceholder().resize(e)}function d(i,h){i.getPlaceholder().unbind("resize",e)}f.hooks.bindEvents.push(g);f.hooks.shutdown.push(d)}b.plot.plugins.push({init:c,options:a,name:"resize",version:"1.0"})})(jQuery);
@@ -0,0 +1,344 @@
1
+ /*
2
+ Flot plugin for selecting regions.
3
+
4
+ The plugin defines the following options:
5
+
6
+ selection: {
7
+ mode: null or "x" or "y" or "xy",
8
+ color: color
9
+ }
10
+
11
+ Selection support is enabled by setting the mode to one of "x", "y" or
12
+ "xy". In "x" mode, the user will only be able to specify the x range,
13
+ similarly for "y" mode. For "xy", the selection becomes a rectangle
14
+ where both ranges can be specified. "color" is color of the selection
15
+ (if you need to change the color later on, you can get to it with
16
+ plot.getOptions().selection.color).
17
+
18
+ When selection support is enabled, a "plotselected" event will be
19
+ emitted on the DOM element you passed into the plot function. The
20
+ event handler gets a parameter with the ranges selected on the axes,
21
+ like this:
22
+
23
+ placeholder.bind("plotselected", function(event, ranges) {
24
+ alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
25
+ // similar for yaxis - with multiple axes, the extra ones are in
26
+ // x2axis, x3axis, ...
27
+ });
28
+
29
+ The "plotselected" event is only fired when the user has finished
30
+ making the selection. A "plotselecting" event is fired during the
31
+ process with the same parameters as the "plotselected" event, in case
32
+ you want to know what's happening while it's happening,
33
+
34
+ A "plotunselected" event with no arguments is emitted when the user
35
+ clicks the mouse to remove the selection.
36
+
37
+ The plugin allso adds the following methods to the plot object:
38
+
39
+ - setSelection(ranges, preventEvent)
40
+
41
+ Set the selection rectangle. The passed in ranges is on the same
42
+ form as returned in the "plotselected" event. If the selection mode
43
+ is "x", you should put in either an xaxis range, if the mode is "y"
44
+ you need to put in an yaxis range and both xaxis and yaxis if the
45
+ selection mode is "xy", like this:
46
+
47
+ setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
48
+
49
+ setSelection will trigger the "plotselected" event when called. If
50
+ you don't want that to happen, e.g. if you're inside a
51
+ "plotselected" handler, pass true as the second parameter. If you
52
+ are using multiple axes, you can specify the ranges on any of those,
53
+ e.g. as x2axis/x3axis/... instead of xaxis, the plugin picks the
54
+ first one it sees.
55
+
56
+ - clearSelection(preventEvent)
57
+
58
+ Clear the selection rectangle. Pass in true to avoid getting a
59
+ "plotunselected" event.
60
+
61
+ - getSelection()
62
+
63
+ Returns the current selection in the same format as the
64
+ "plotselected" event. If there's currently no selection, the
65
+ function returns null.
66
+
67
+ */
68
+
69
+ (function ($) {
70
+ function init(plot) {
71
+ var selection = {
72
+ first: { x: -1, y: -1}, second: { x: -1, y: -1},
73
+ show: false,
74
+ active: false
75
+ };
76
+
77
+ // FIXME: The drag handling implemented here should be
78
+ // abstracted out, there's some similar code from a library in
79
+ // the navigation plugin, this should be massaged a bit to fit
80
+ // the Flot cases here better and reused. Doing this would
81
+ // make this plugin much slimmer.
82
+ var savedhandlers = {};
83
+
84
+ var mouseUpHandler = null;
85
+
86
+ function onMouseMove(e) {
87
+ if (selection.active) {
88
+ updateSelection(e);
89
+
90
+ plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
91
+ }
92
+ }
93
+
94
+ function onMouseDown(e) {
95
+ if (e.which != 1) // only accept left-click
96
+ return;
97
+
98
+ // cancel out any text selections
99
+ document.body.focus();
100
+
101
+ // prevent text selection and drag in old-school browsers
102
+ if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
103
+ savedhandlers.onselectstart = document.onselectstart;
104
+ document.onselectstart = function () { return false; };
105
+ }
106
+ if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
107
+ savedhandlers.ondrag = document.ondrag;
108
+ document.ondrag = function () { return false; };
109
+ }
110
+
111
+ setSelectionPos(selection.first, e);
112
+
113
+ selection.active = true;
114
+
115
+ // this is a bit silly, but we have to use a closure to be
116
+ // able to whack the same handler again
117
+ mouseUpHandler = function (e) { onMouseUp(e); };
118
+
119
+ $(document).one("mouseup", mouseUpHandler);
120
+ }
121
+
122
+ function onMouseUp(e) {
123
+ mouseUpHandler = null;
124
+
125
+ // revert drag stuff for old-school browsers
126
+ if (document.onselectstart !== undefined)
127
+ document.onselectstart = savedhandlers.onselectstart;
128
+ if (document.ondrag !== undefined)
129
+ document.ondrag = savedhandlers.ondrag;
130
+
131
+ // no more dragging
132
+ selection.active = false;
133
+ updateSelection(e);
134
+
135
+ if (selectionIsSane())
136
+ triggerSelectedEvent();
137
+ else {
138
+ // this counts as a clear
139
+ plot.getPlaceholder().trigger("plotunselected", [ ]);
140
+ plot.getPlaceholder().trigger("plotselecting", [ null ]);
141
+ }
142
+
143
+ return false;
144
+ }
145
+
146
+ function getSelection() {
147
+ if (!selectionIsSane())
148
+ return null;
149
+
150
+ var r = {}, c1 = selection.first, c2 = selection.second;
151
+ $.each(plot.getAxes(), function (name, axis) {
152
+ if (axis.used) {
153
+ var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
154
+ r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
155
+ }
156
+ });
157
+ return r;
158
+ }
159
+
160
+ function triggerSelectedEvent() {
161
+ var r = getSelection();
162
+
163
+ plot.getPlaceholder().trigger("plotselected", [ r ]);
164
+
165
+ // backwards-compat stuff, to be removed in future
166
+ if (r.xaxis && r.yaxis)
167
+ plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
168
+ }
169
+
170
+ function clamp(min, value, max) {
171
+ return value < min ? min: (value > max ? max: value);
172
+ }
173
+
174
+ function setSelectionPos(pos, e) {
175
+ var o = plot.getOptions();
176
+ var offset = plot.getPlaceholder().offset();
177
+ var plotOffset = plot.getPlotOffset();
178
+ pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
179
+ pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
180
+
181
+ if (o.selection.mode == "y")
182
+ pos.x = pos == selection.first ? 0 : plot.width();
183
+
184
+ if (o.selection.mode == "x")
185
+ pos.y = pos == selection.first ? 0 : plot.height();
186
+ }
187
+
188
+ function updateSelection(pos) {
189
+ if (pos.pageX == null)
190
+ return;
191
+
192
+ setSelectionPos(selection.second, pos);
193
+ if (selectionIsSane()) {
194
+ selection.show = true;
195
+ plot.triggerRedrawOverlay();
196
+ }
197
+ else
198
+ clearSelection(true);
199
+ }
200
+
201
+ function clearSelection(preventEvent) {
202
+ if (selection.show) {
203
+ selection.show = false;
204
+ plot.triggerRedrawOverlay();
205
+ if (!preventEvent)
206
+ plot.getPlaceholder().trigger("plotunselected", [ ]);
207
+ }
208
+ }
209
+
210
+ // function taken from markings support in Flot
211
+ function extractRange(ranges, coord) {
212
+ var axis, from, to, key, axes = plot.getAxes();
213
+
214
+ for (var k in axes) {
215
+ axis = axes[k];
216
+ if (axis.direction == coord) {
217
+ key = coord + axis.n + "axis";
218
+ if (!ranges[key] && axis.n == 1)
219
+ key = coord + "axis"; // support x1axis as xaxis
220
+ if (ranges[key]) {
221
+ from = ranges[key].from;
222
+ to = ranges[key].to;
223
+ break;
224
+ }
225
+ }
226
+ }
227
+
228
+ // backwards-compat stuff - to be removed in future
229
+ if (!ranges[key]) {
230
+ axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
231
+ from = ranges[coord + "1"];
232
+ to = ranges[coord + "2"];
233
+ }
234
+
235
+ // auto-reverse as an added bonus
236
+ if (from != null && to != null && from > to) {
237
+ var tmp = from;
238
+ from = to;
239
+ to = tmp;
240
+ }
241
+
242
+ return { from: from, to: to, axis: axis };
243
+ }
244
+
245
+ function setSelection(ranges, preventEvent) {
246
+ var axis, range, o = plot.getOptions();
247
+
248
+ if (o.selection.mode == "y") {
249
+ selection.first.x = 0;
250
+ selection.second.x = plot.width();
251
+ }
252
+ else {
253
+ range = extractRange(ranges, "x");
254
+
255
+ selection.first.x = range.axis.p2c(range.from);
256
+ selection.second.x = range.axis.p2c(range.to);
257
+ }
258
+
259
+ if (o.selection.mode == "x") {
260
+ selection.first.y = 0;
261
+ selection.second.y = plot.height();
262
+ }
263
+ else {
264
+ range = extractRange(ranges, "y");
265
+
266
+ selection.first.y = range.axis.p2c(range.from);
267
+ selection.second.y = range.axis.p2c(range.to);
268
+ }
269
+
270
+ selection.show = true;
271
+ plot.triggerRedrawOverlay();
272
+ if (!preventEvent && selectionIsSane())
273
+ triggerSelectedEvent();
274
+ }
275
+
276
+ function selectionIsSane() {
277
+ var minSize = 5;
278
+ return Math.abs(selection.second.x - selection.first.x) >= minSize &&
279
+ Math.abs(selection.second.y - selection.first.y) >= minSize;
280
+ }
281
+
282
+ plot.clearSelection = clearSelection;
283
+ plot.setSelection = setSelection;
284
+ plot.getSelection = getSelection;
285
+
286
+ plot.hooks.bindEvents.push(function(plot, eventHolder) {
287
+ var o = plot.getOptions();
288
+ if (o.selection.mode != null) {
289
+ eventHolder.mousemove(onMouseMove);
290
+ eventHolder.mousedown(onMouseDown);
291
+ }
292
+ });
293
+
294
+
295
+ plot.hooks.drawOverlay.push(function (plot, ctx) {
296
+ // draw selection
297
+ if (selection.show && selectionIsSane()) {
298
+ var plotOffset = plot.getPlotOffset();
299
+ var o = plot.getOptions();
300
+
301
+ ctx.save();
302
+ ctx.translate(plotOffset.left, plotOffset.top);
303
+
304
+ var c = $.color.parse(o.selection.color);
305
+
306
+ ctx.strokeStyle = c.scale('a', 0.8).toString();
307
+ ctx.lineWidth = 1;
308
+ ctx.lineJoin = "round";
309
+ ctx.fillStyle = c.scale('a', 0.4).toString();
310
+
311
+ var x = Math.min(selection.first.x, selection.second.x),
312
+ y = Math.min(selection.first.y, selection.second.y),
313
+ w = Math.abs(selection.second.x - selection.first.x),
314
+ h = Math.abs(selection.second.y - selection.first.y);
315
+
316
+ ctx.fillRect(x, y, w, h);
317
+ ctx.strokeRect(x, y, w, h);
318
+
319
+ ctx.restore();
320
+ }
321
+ });
322
+
323
+ plot.hooks.shutdown.push(function (plot, eventHolder) {
324
+ eventHolder.unbind("mousemove", onMouseMove);
325
+ eventHolder.unbind("mousedown", onMouseDown);
326
+
327
+ if (mouseUpHandler)
328
+ $(document).unbind("mouseup", mouseUpHandler);
329
+ });
330
+
331
+ }
332
+
333
+ $.plot.plugins.push({
334
+ init: init,
335
+ options: {
336
+ selection: {
337
+ mode: null, // one of null, "x", "y" or "xy"
338
+ color: "#e8cfac"
339
+ }
340
+ },
341
+ name: 'selection',
342
+ version: '1.1'
343
+ });
344
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger("plotselecting",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one("mouseup",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger("plotunselected",[]);k.getPlaceholder().trigger("plotselecting",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger("plotselected",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger("selected",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode=="y"){w.x=w==p.first?0:k.width()}if(v.selection.mode=="x"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger("plotunselected",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+"axis";if(!s[A]&&t.n==1){A=w+"axis"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w=="x"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+"1"];z=s[w+"2"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode=="y"){p.first.x=0;p.second.x=k.width()}else{u=c(t,"x");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode=="x"){p.first.y=0;p.second.y=k.height()}else{u=c(t,"y");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale("a",0.8).toString();D.lineWidth=1;D.lineJoin="round";D.fillStyle=z.scale("a",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind("mousemove",e);s.unbind("mousedown",n);if(r){a(document).unbind("mouseup",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:"#e8cfac"}},name:"selection",version:"1.1"})})(jQuery);
@@ -0,0 +1,184 @@
1
+ /*
2
+ Flot plugin for stacking data sets, i.e. putting them on top of each
3
+ other, for accumulative graphs.
4
+
5
+ The plugin assumes the data is sorted on x (or y if stacking
6
+ horizontally). For line charts, it is assumed that if a line has an
7
+ undefined gap (from a null point), then the line above it should have
8
+ the same gap - insert zeros instead of "null" if you want another
9
+ behaviour. This also holds for the start and end of the chart. Note
10
+ that stacking a mix of positive and negative values in most instances
11
+ doesn't make sense (so it looks weird).
12
+
13
+ Two or more series are stacked when their "stack" attribute is set to
14
+ the same key (which can be any number or string or just "true"). To
15
+ specify the default stack, you can set
16
+
17
+ series: {
18
+ stack: null or true or key (number/string)
19
+ }
20
+
21
+ or specify it for a specific series
22
+
23
+ $.plot($("#placeholder"), [{ data: [ ... ], stack: true }])
24
+
25
+ The stacking order is determined by the order of the data series in
26
+ the array (later series end up on top of the previous).
27
+
28
+ Internally, the plugin modifies the datapoints in each series, adding
29
+ an offset to the y value. For line series, extra data points are
30
+ inserted through interpolation. If there's a second y value, it's also
31
+ adjusted (e.g for bar charts or filled areas).
32
+ */
33
+
34
+ (function ($) {
35
+ var options = {
36
+ series: { stack: null } // or number/string
37
+ };
38
+
39
+ function init(plot) {
40
+ function findMatchingSeries(s, allseries) {
41
+ var res = null
42
+ for (var i = 0; i < allseries.length; ++i) {
43
+ if (s == allseries[i])
44
+ break;
45
+
46
+ if (allseries[i].stack == s.stack)
47
+ res = allseries[i];
48
+ }
49
+
50
+ return res;
51
+ }
52
+
53
+ function stackData(plot, s, datapoints) {
54
+ if (s.stack == null)
55
+ return;
56
+
57
+ var other = findMatchingSeries(s, plot.getData());
58
+ if (!other)
59
+ return;
60
+
61
+ var ps = datapoints.pointsize,
62
+ points = datapoints.points,
63
+ otherps = other.datapoints.pointsize,
64
+ otherpoints = other.datapoints.points,
65
+ newpoints = [],
66
+ px, py, intery, qx, qy, bottom,
67
+ withlines = s.lines.show,
68
+ horizontal = s.bars.horizontal,
69
+ withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
70
+ withsteps = withlines && s.lines.steps,
71
+ fromgap = true,
72
+ keyOffset = horizontal ? 1 : 0,
73
+ accumulateOffset = horizontal ? 0 : 1,
74
+ i = 0, j = 0, l;
75
+
76
+ while (true) {
77
+ if (i >= points.length)
78
+ break;
79
+
80
+ l = newpoints.length;
81
+
82
+ if (points[i] == null) {
83
+ // copy gaps
84
+ for (m = 0; m < ps; ++m)
85
+ newpoints.push(points[i + m]);
86
+ i += ps;
87
+ }
88
+ else if (j >= otherpoints.length) {
89
+ // for lines, we can't use the rest of the points
90
+ if (!withlines) {
91
+ for (m = 0; m < ps; ++m)
92
+ newpoints.push(points[i + m]);
93
+ }
94
+ i += ps;
95
+ }
96
+ else if (otherpoints[j] == null) {
97
+ // oops, got a gap
98
+ for (m = 0; m < ps; ++m)
99
+ newpoints.push(null);
100
+ fromgap = true;
101
+ j += otherps;
102
+ }
103
+ else {
104
+ // cases where we actually got two points
105
+ px = points[i + keyOffset];
106
+ py = points[i + accumulateOffset];
107
+ qx = otherpoints[j + keyOffset];
108
+ qy = otherpoints[j + accumulateOffset];
109
+ bottom = 0;
110
+
111
+ if (px == qx) {
112
+ for (m = 0; m < ps; ++m)
113
+ newpoints.push(points[i + m]);
114
+
115
+ newpoints[l + accumulateOffset] += qy;
116
+ bottom = qy;
117
+
118
+ i += ps;
119
+ j += otherps;
120
+ }
121
+ else if (px > qx) {
122
+ // we got past point below, might need to
123
+ // insert interpolated extra point
124
+ if (withlines && i > 0 && points[i - ps] != null) {
125
+ intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
126
+ newpoints.push(qx);
127
+ newpoints.push(intery + qy);
128
+ for (m = 2; m < ps; ++m)
129
+ newpoints.push(points[i + m]);
130
+ bottom = qy;
131
+ }
132
+
133
+ j += otherps;
134
+ }
135
+ else { // px < qx
136
+ if (fromgap && withlines) {
137
+ // if we come from a gap, we just skip this point
138
+ i += ps;
139
+ continue;
140
+ }
141
+
142
+ for (m = 0; m < ps; ++m)
143
+ newpoints.push(points[i + m]);
144
+
145
+ // we might be able to interpolate a point below,
146
+ // this can give us a better y
147
+ if (withlines && j > 0 && otherpoints[j - otherps] != null)
148
+ bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
149
+
150
+ newpoints[l + accumulateOffset] += bottom;
151
+
152
+ i += ps;
153
+ }
154
+
155
+ fromgap = false;
156
+
157
+ if (l != newpoints.length && withbottom)
158
+ newpoints[l + 2] += bottom;
159
+ }
160
+
161
+ // maintain the line steps invariant
162
+ if (withsteps && l != newpoints.length && l > 0
163
+ && newpoints[l] != null
164
+ && newpoints[l] != newpoints[l - ps]
165
+ && newpoints[l + 1] != newpoints[l - ps + 1]) {
166
+ for (m = 0; m < ps; ++m)
167
+ newpoints[l + ps + m] = newpoints[l + m];
168
+ newpoints[l + 1] = newpoints[l - ps + 1];
169
+ }
170
+ }
171
+
172
+ datapoints.points = newpoints;
173
+ }
174
+
175
+ plot.hooks.processDatapoints.push(stackData);
176
+ }
177
+
178
+ $.plot.plugins.push({
179
+ init: init,
180
+ options: options,
181
+ name: 'stack',
182
+ version: '1.2'
183
+ });
184
+ })(jQuery);