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,137 @@
1
+ Writing plugins
2
+ ---------------
3
+
4
+ All you need to do to make a new plugin is creating an init function
5
+ and a set of options (if needed), stuffing it into an object and
6
+ putting it in the $.plot.plugins array. For example:
7
+
8
+ function myCoolPluginInit(plot) {
9
+ plot.coolstring = "Hello!";
10
+ };
11
+
12
+ $.plot.plugins.push({ init: myCoolPluginInit, options: { ... } });
13
+
14
+ // if $.plot is called, it will return a plot object with the
15
+ // attribute "coolstring"
16
+
17
+ Now, given that the plugin might run in many different places, it's
18
+ a good idea to avoid leaking names. The usual trick here is wrap the
19
+ above lines in an anonymous function which is called immediately, like
20
+ this: (function () { inner code ... })(). To make it even more robust
21
+ in case $ is not bound to jQuery but some other Javascript library, we
22
+ can write it as
23
+
24
+ (function ($) {
25
+ // plugin definition
26
+ // ...
27
+ })(jQuery);
28
+
29
+ There's a complete example below, but you should also check out the
30
+ plugins bundled with Flot.
31
+
32
+
33
+ Complete example
34
+ ----------------
35
+
36
+ Here is a simple debug plugin which alerts each of the series in the
37
+ plot. It has a single option that control whether it is enabled and
38
+ how much info to output:
39
+
40
+ (function ($) {
41
+ function init(plot) {
42
+ var debugLevel = 1;
43
+
44
+ function checkDebugEnabled(plot, options) {
45
+ if (options.debug) {
46
+ debugLevel = options.debug;
47
+
48
+ plot.hooks.processDatapoints.push(alertSeries);
49
+ }
50
+ }
51
+
52
+ function alertSeries(plot, series, datapoints) {
53
+ var msg = "series " + series.label;
54
+ if (debugLevel > 1)
55
+ msg += " with " + series.data.length + " points";
56
+ alert(msg);
57
+ }
58
+
59
+ plot.hooks.processOptions.push(checkDebugEnabled);
60
+ }
61
+
62
+ var options = { debug: 0 };
63
+
64
+ $.plot.plugins.push({
65
+ init: init,
66
+ options: options,
67
+ name: "simpledebug",
68
+ version: "0.1"
69
+ });
70
+ })(jQuery);
71
+
72
+ We also define "name" and "version". It's not used by Flot, but might
73
+ be helpful for other plugins in resolving dependencies.
74
+
75
+ Put the above in a file named "jquery.flot.debug.js", include it in an
76
+ HTML page and then it can be used with:
77
+
78
+ $.plot($("#placeholder"), [...], { debug: 2 });
79
+
80
+ This simple plugin illustrates a couple of points:
81
+
82
+ - It uses the anonymous function trick to avoid name pollution.
83
+ - It can be enabled/disabled through an option.
84
+ - Variables in the init function can be used to store plot-specific
85
+ state between the hooks.
86
+
87
+ The two last points are important because there may be multiple plots
88
+ on the same page, and you'd want to make sure they are not mixed up.
89
+
90
+
91
+ Shutting down a plugin
92
+ ----------------------
93
+
94
+ Each plot object has a shutdown hook which is run when plot.shutdown()
95
+ is called. This usually mostly happens in case another plot is made on
96
+ top of an existing one.
97
+
98
+ The purpose of the hook is to give you a chance to unbind any event
99
+ handlers you've registered and remove any extra DOM things you've
100
+ inserted.
101
+
102
+ The problem with event handlers is that you can have registered a
103
+ handler which is run in some point in the future, e.g. with
104
+ setTimeout(). Meanwhile, the plot may have been shutdown and removed,
105
+ but because your event handler is still referencing it, it can't be
106
+ garbage collected yet, and worse, if your handler eventually runs, it
107
+ may overwrite stuff on a completely different plot.
108
+
109
+
110
+ Some hints on the options
111
+ -------------------------
112
+
113
+ Plugins should always support appropriate options to enable/disable
114
+ them because the plugin user may have several plots on the same page
115
+ where only one should use the plugin. In most cases it's probably a
116
+ good idea if the plugin is turned off rather than on per default, just
117
+ like most of the powerful features in Flot.
118
+
119
+ If the plugin needs options that are specific to each series, like the
120
+ points or lines options in core Flot, you can put them in "series" in
121
+ the options object, e.g.
122
+
123
+ var options = {
124
+ series: {
125
+ downsample: {
126
+ algorithm: null,
127
+ maxpoints: 1000
128
+ }
129
+ }
130
+ }
131
+
132
+ Then they will be copied by Flot into each series, providing default
133
+ values in case none are specified.
134
+
135
+ Think hard and long about naming the options. These names are going to
136
+ be public API, and code is going to depend on them if the plugin is
137
+ successful.
@@ -0,0 +1,90 @@
1
+ About
2
+ -----
3
+
4
+ Flot is a Javascript plotting library for jQuery. Read more at the
5
+ website:
6
+
7
+ http://code.google.com/p/flot/
8
+
9
+ Take a look at the examples linked from above, they should give a good
10
+ impression of what Flot can do and the source code of the examples is
11
+ probably the fastest way to learn how to use Flot.
12
+
13
+
14
+ Installation
15
+ ------------
16
+
17
+ Just include the Javascript file after you've included jQuery.
18
+
19
+ Generally, all browsers that support the HTML5 canvas tag are
20
+ supported.
21
+
22
+ For support for Internet Explorer < 9, you can use Excanvas, a canvas
23
+ emulator; this is used in the examples bundled with Flot. You just
24
+ include the excanvas script like this:
25
+
26
+ <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
27
+
28
+ If it's not working on your development IE 6.0, check that it has
29
+ support for VML which Excanvas is relying on. It appears that some
30
+ stripped down versions used for test environments on virtual machines
31
+ lack the VML support.
32
+
33
+ You can also try using Flashcanvas (see
34
+ http://code.google.com/p/flashcanvas/), which uses Flash to do the
35
+ emulation. Although Flash can be a bit slower to load than VML, if
36
+ you've got a lot of points, the Flash version can be much faster
37
+ overall. Flot contains some wrapper code for activating Excanvas which
38
+ Flashcanvas is compatible with.
39
+
40
+ You need at least jQuery 1.2.6, but try at least 1.3.2 for interactive
41
+ charts because of performance improvements in event handling.
42
+
43
+
44
+ Basic usage
45
+ -----------
46
+
47
+ Create a placeholder div to put the graph in:
48
+
49
+ <div id="placeholder"></div>
50
+
51
+ You need to set the width and height of this div, otherwise the plot
52
+ library doesn't know how to scale the graph. You can do it inline like
53
+ this:
54
+
55
+ <div id="placeholder" style="width:600px;height:300px"></div>
56
+
57
+ You can also do it with an external stylesheet. Make sure that the
58
+ placeholder isn't within something with a display:none CSS property -
59
+ in that case, Flot has trouble measuring label dimensions which
60
+ results in garbled looks and might have trouble measuring the
61
+ placeholder dimensions which is fatal (it'll throw an exception).
62
+
63
+ Then when the div is ready in the DOM, which is usually on document
64
+ ready, run the plot function:
65
+
66
+ $.plot($("#placeholder"), data, options);
67
+
68
+ Here, data is an array of data series and options is an object with
69
+ settings if you want to customize the plot. Take a look at the
70
+ examples for some ideas of what to put in or look at the reference
71
+ in the file "API.txt". Here's a quick example that'll draw a line from
72
+ (0, 0) to (1, 1):
73
+
74
+ $.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
75
+
76
+ The plot function immediately draws the chart and then returns a plot
77
+ object with a couple of methods.
78
+
79
+
80
+ What's with the name?
81
+ ---------------------
82
+
83
+ First: it's pronounced with a short o, like "plot". Not like "flawed".
84
+
85
+ So "Flot" rhymes with "plot".
86
+
87
+ And if you look up "flot" in a Danish-to-English dictionary, some up
88
+ the words that come up are "good-looking", "attractive", "stylish",
89
+ "smart", "impressive", "extravagant". One of the main goals with Flot
90
+ is pretty looks.
@@ -0,0 +1,143 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Flot Examples</title>
6
+ <link href="layout.css" rel="stylesheet" type="text/css">
7
+ <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
8
+ <script language="javascript" type="text/javascript" src="../jquery.js"></script>
9
+ <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
10
+ </head>
11
+ <body>
12
+ <h1>Flot Examples</h1>
13
+
14
+ <div id="placeholder" style="width:600px;height:300px;"></div>
15
+
16
+ <p>Example of loading data dynamically with AJAX. Percentage change in GDP (source: <a href="http://epp.eurostat.ec.europa.eu/tgm/table.do?tab=table&init=1&plugin=1&language=en&pcode=tsieb020">Eurostat</a>). Click the buttons below.</p>
17
+
18
+ <p>The data is fetched over HTTP, in this case directly from text
19
+ files. Usually the URL would point to some web server handler
20
+ (e.g. a PHP page or Java/.NET/Python/Ruby on Rails handler) that
21
+ extracts it from a database and serializes it to JSON.</p>
22
+
23
+ <p>
24
+ <input class="fetchSeries" type="button" value="First dataset"> -
25
+ <a href="data-eu-gdp-growth.json">data</a> -
26
+ <span></span>
27
+ </p>
28
+
29
+ <p>
30
+ <input class="fetchSeries" type="button" value="Second dataset"> -
31
+ <a href="data-japan-gdp-growth.json">data</a> -
32
+ <span></span>
33
+ </p>
34
+
35
+ <p>
36
+ <input class="fetchSeries" type="button" value="Third dataset"> -
37
+ <a href="data-usa-gdp-growth.json">data</a> -
38
+ <span></span>
39
+ </p>
40
+
41
+ <p>If you combine AJAX with setTimeout, you can poll the server
42
+ for new data.</p>
43
+
44
+ <p>
45
+ <input class="dataUpdate" type="button" value="Poll for data">
46
+ </p>
47
+
48
+ <script type="text/javascript">
49
+ $(function () {
50
+ var options = {
51
+ lines: { show: true },
52
+ points: { show: true },
53
+ xaxis: { tickDecimals: 0, tickSize: 1 }
54
+ };
55
+ var data = [];
56
+ var placeholder = $("#placeholder");
57
+
58
+ $.plot(placeholder, data, options);
59
+
60
+
61
+ // fetch one series, adding to what we got
62
+ var alreadyFetched = {};
63
+
64
+ $("input.fetchSeries").click(function () {
65
+ var button = $(this);
66
+
67
+ // find the URL in the link right next to us
68
+ var dataurl = button.siblings('a').attr('href');
69
+
70
+ // then fetch the data with jQuery
71
+ function onDataReceived(series) {
72
+ // extract the first coordinate pair so you can see that
73
+ // data is now an ordinary Javascript object
74
+ var firstcoordinate = '(' + series.data[0][0] + ', ' + series.data[0][1] + ')';
75
+
76
+ button.siblings('span').text('Fetched ' + series.label + ', first point: ' + firstcoordinate);
77
+
78
+ // let's add it to our current data
79
+ if (!alreadyFetched[series.label]) {
80
+ alreadyFetched[series.label] = true;
81
+ data.push(series);
82
+ }
83
+
84
+ // and plot all we got
85
+ $.plot(placeholder, data, options);
86
+ }
87
+
88
+ $.ajax({
89
+ url: dataurl,
90
+ method: 'GET',
91
+ dataType: 'json',
92
+ success: onDataReceived
93
+ });
94
+ });
95
+
96
+
97
+ // initiate a recurring data update
98
+ $("input.dataUpdate").click(function () {
99
+ // reset data
100
+ data = [];
101
+ alreadyFetched = {};
102
+
103
+ $.plot(placeholder, data, options);
104
+
105
+ var iteration = 0;
106
+
107
+ function fetchData() {
108
+ ++iteration;
109
+
110
+ function onDataReceived(series) {
111
+ // we get all the data in one go, if we only got partial
112
+ // data, we could merge it with what we already got
113
+ data = [ series ];
114
+
115
+ $.plot($("#placeholder"), data, options);
116
+ }
117
+
118
+ $.ajax({
119
+ // usually, we'll just call the same URL, a script
120
+ // connected to a database, but in this case we only
121
+ // have static example files so we need to modify the
122
+ // URL
123
+ url: "data-eu-gdp-growth-" + iteration + ".json",
124
+ method: 'GET',
125
+ dataType: 'json',
126
+ success: onDataReceived
127
+ });
128
+
129
+ if (iteration < 5)
130
+ setTimeout(fetchData, 1000);
131
+ else {
132
+ data = [];
133
+ alreadyFetched = {};
134
+ }
135
+ }
136
+
137
+ setTimeout(fetchData, 1000);
138
+ });
139
+ });
140
+ </script>
141
+
142
+ </body>
143
+ </html>
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Flot Examples</title>
6
+ <link href="layout.css" rel="stylesheet" type="text/css">
7
+ <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
8
+ <script language="javascript" type="text/javascript" src="../jquery.js"></script>
9
+ <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
10
+ </head>
11
+ <body>
12
+ <h1>Flot Examples</h1>
13
+
14
+ <div id="placeholder" style="width:600px;height:300px;"></div>
15
+
16
+ <p>Flot has support for simple background decorations such as
17
+ lines and rectangles. They can be useful for marking up certain
18
+ areas. You can easily add any HTML you need with standard DOM
19
+ manipulation, e.g. for labels. For drawing custom shapes there is
20
+ also direct access to the canvas.</p>
21
+
22
+ <script type="text/javascript">
23
+ $(function () {
24
+ // generate a dataset
25
+ var d1 = [];
26
+ for (var i = 0; i < 20; ++i)
27
+ d1.push([i, Math.sin(i)]);
28
+
29
+ var data = [{ data: d1, label: "Pressure", color: "#333" }];
30
+
31
+ // setup background areas
32
+ var markings = [
33
+ { color: '#f6f6f6', yaxis: { from: 1 } },
34
+ { color: '#f6f6f6', yaxis: { to: -1 } },
35
+ { color: '#000', lineWidth: 1, xaxis: { from: 2, to: 2 } },
36
+ { color: '#000', lineWidth: 1, xaxis: { from: 8, to: 8 } }
37
+ ];
38
+
39
+ var placeholder = $("#placeholder");
40
+
41
+ // plot it
42
+ var plot = $.plot(placeholder, data, {
43
+ bars: { show: true, barWidth: 0.5, fill: 0.9 },
44
+ xaxis: { ticks: [], autoscaleMargin: 0.02 },
45
+ yaxis: { min: -2, max: 2 },
46
+ grid: { markings: markings }
47
+ });
48
+
49
+ // add labels
50
+ var o;
51
+
52
+ o = plot.pointOffset({ x: 2, y: -1.2});
53
+ // we just append it to the placeholder which Flot already uses
54
+ // for positioning
55
+ placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Warming up</div>');
56
+
57
+ o = plot.pointOffset({ x: 8, y: -1.2});
58
+ placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Actual measurements</div>');
59
+
60
+ // draw a little arrow on top of the last label to demonstrate
61
+ // canvas drawing
62
+ var ctx = plot.getCanvas().getContext("2d");
63
+ ctx.beginPath();
64
+ o.left += 4;
65
+ ctx.moveTo(o.left, o.top);
66
+ ctx.lineTo(o.left, o.top - 10);
67
+ ctx.lineTo(o.left + 10, o.top - 5);
68
+ ctx.lineTo(o.left, o.top);
69
+ ctx.fillStyle = "#000";
70
+ ctx.fill();
71
+ });
72
+ </script>
73
+
74
+ </body>
75
+ </html>