jquery_cheats 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/README.md +1 -0
  2. data/app/assets/javascripts/jquery_cheats/jquery_cheats.js +1 -1
  3. data/app/assets/javascripts/jquery_cheats/replacementContextMenu.js +62 -0
  4. data/jquery_cheats.gemspec +2 -2
  5. data/lib/jquery_cheats/jquery_cheats.rb +58 -0
  6. data/vendor/assets/javascripts/jqplot/excanvas.js +1438 -0
  7. data/vendor/assets/javascripts/jqplot/jquery.jqplot.js +10901 -0
  8. data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.js +312 -0
  9. data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.min.js +57 -0
  10. data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.js +747 -0
  11. data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.min.js +57 -0
  12. data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.js +234 -0
  13. data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.min.js +57 -0
  14. data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.js +754 -0
  15. data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.min.js +57 -0
  16. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js +202 -0
  17. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js +57 -0
  18. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.js +242 -0
  19. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js +57 -0
  20. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.js +864 -0
  21. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.min.js +57 -0
  22. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.js +448 -0
  23. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.min.js +57 -0
  24. data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.js +636 -0
  25. data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.min.js +57 -0
  26. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.js +115 -0
  27. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.min.js +57 -0
  28. data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.js +1093 -0
  29. data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.min.js +57 -0
  30. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.js +702 -0
  31. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.min.js +57 -0
  32. data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.js +800 -0
  33. data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.min.js +57 -0
  34. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.js +224 -0
  35. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.min.js +57 -0
  36. data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.js +241 -0
  37. data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js +57 -0
  38. data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.js +938 -0
  39. data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.min.js +57 -0
  40. data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.js +454 -0
  41. data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.min.js +57 -0
  42. data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.js +475 -0
  43. data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.min.js +57 -0
  44. data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.js +528 -0
  45. data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.min.js +57 -0
  46. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.js +610 -0
  47. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js +57 -0
  48. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.js +436 -0
  49. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.min.js +57 -0
  50. data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.js +1029 -0
  51. data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.min.js +57 -0
  52. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.js +372 -0
  53. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.min.js +57 -0
  54. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.js +899 -0
  55. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.min.js +57 -0
  56. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.js +362 -0
  57. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.min.js +57 -0
  58. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.js +730 -0
  59. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js +57 -0
  60. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.js +423 -0
  61. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.min.js +57 -0
  62. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.js +490 -0
  63. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.min.js +57 -0
  64. data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.js +222 -0
  65. data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.min.js +57 -0
  66. data/vendor/assets/javascripts/jquery_cheats/spinjs/spin.min.js +1 -1
  67. data/vendor/assets/stylesheets/jquery.jqplot.css +259 -0
  68. metadata +66 -3
@@ -0,0 +1,312 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b2_r1012
6
+ *
7
+ * Copyright (c) 2009-2011 Chris Leonello
8
+ * jqPlot is currently available for use in all personal or commercial projects
9
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
10
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
11
+ * choose the license that best suits your project and use it accordingly.
12
+ *
13
+ * Although not required, the author would appreciate an email letting him
14
+ * know of any substantial use of jqPlot. You can reach the author at:
15
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
16
+ *
17
+ * If you are feeling kind and generous, consider supporting the project by
18
+ * making a donation at: http://www.jqplot.com/donate.php .
19
+ *
20
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
21
+ *
22
+ * version 2007.04.27
23
+ * author Ash Searle
24
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
25
+ * http://hexmen.com/js/sprintf.js
26
+ * The author (Ash Searle) has placed this code in the public domain:
27
+ * "This code is unrestricted: you are free to use it however you like."
28
+ *
29
+ */
30
+ (function($) {
31
+ // Class: $.jqplot.BezierCurveRenderer.js
32
+ // Renderer which draws lines as stacked bezier curves.
33
+ // Data for the line will not be specified as an array of
34
+ // [x, y] data point values, but as a an array of [start piont, bezier curve]
35
+ // So, the line is specified as: [[xstart, ystart], [cp1x, cp1y, cp2x, cp2y, xend, yend]].
36
+ $.jqplot.BezierCurveRenderer = function(){
37
+ $.jqplot.LineRenderer.call(this);
38
+ };
39
+
40
+ $.jqplot.BezierCurveRenderer.prototype = new $.jqplot.LineRenderer();
41
+ $.jqplot.BezierCurveRenderer.prototype.constructor = $.jqplot.BezierCurveRenderer;
42
+
43
+
44
+ // Method: setGridData
45
+ // converts the user data values to grid coordinates and stores them
46
+ // in the gridData array.
47
+ // Called with scope of a series.
48
+ $.jqplot.BezierCurveRenderer.prototype.setGridData = function(plot) {
49
+ // recalculate the grid data
50
+ var xp = this._xaxis.series_u2p;
51
+ var yp = this._yaxis.series_u2p;
52
+ // this._plotData should be same as this.data
53
+ var data = this.data;
54
+ this.gridData = [];
55
+ this._prevGridData = [];
56
+ // if seriesIndex = 0, fill to x axis.
57
+ // if seriesIndex > 0, fill to previous series data.
58
+ var idx = this.index;
59
+ if (data.length == 2) {
60
+ if (idx == 0) {
61
+ this.gridData = [
62
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
63
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
64
+ xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),
65
+ xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
66
+ [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)],
67
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
68
+ ];
69
+ }
70
+ else {
71
+ var psd = plot.series[idx-1].data;
72
+ this.gridData = [
73
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
74
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
75
+ xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),
76
+ xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
77
+ [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])],
78
+ [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]),
79
+ xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),
80
+ xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
81
+ ];
82
+ }
83
+ }
84
+ else {
85
+ if (idx == 0) {
86
+ this.gridData = [
87
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
88
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
89
+ xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),
90
+ xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
91
+ [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)],
92
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
93
+ ];
94
+ }
95
+ else {
96
+ var psd = plot.series[idx-1].data;
97
+ this.gridData = [
98
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
99
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
100
+ xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),
101
+ xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
102
+ [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])],
103
+ [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]),
104
+ xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),
105
+ xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
106
+ ];
107
+ }
108
+ }
109
+ };
110
+
111
+ // Method: makeGridData
112
+ // converts any arbitrary data values to grid coordinates and
113
+ // returns them. This method exists so that plugins can use a series'
114
+ // linerenderer to generate grid data points without overwriting the
115
+ // grid data associated with that series.
116
+ // Called with scope of a series.
117
+ $.jqplot.BezierCurveRenderer.prototype.makeGridData = function(data, plot) {
118
+ // recalculate the grid data
119
+ var xp = this._xaxis.series_u2p;
120
+ var yp = this._yaxis.series_u2p;
121
+ var gd = [];
122
+ var pgd = [];
123
+ // if seriesIndex = 0, fill to x axis.
124
+ // if seriesIndex > 0, fill to previous series data.
125
+ var idx = this.index;
126
+ if (data.length == 2) {
127
+ if (idx == 0) {
128
+ gd = [
129
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
130
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
131
+ xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),
132
+ xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
133
+ [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)],
134
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
135
+ ];
136
+ }
137
+ else {
138
+ var psd = plot.series[idx-1].data;
139
+ gd = [
140
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
141
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
142
+ xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),
143
+ xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
144
+ [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])],
145
+ [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]),
146
+ xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),
147
+ xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
148
+ ];
149
+ }
150
+ }
151
+ else {
152
+ if (idx == 0) {
153
+ gd = [
154
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
155
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
156
+ xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),
157
+ xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
158
+ [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)],
159
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
160
+ ];
161
+ }
162
+ else {
163
+ var psd = plot.series[idx-1].data;
164
+ gd = [
165
+ [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])],
166
+ [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]),
167
+ xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),
168
+ xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
169
+ [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])],
170
+ [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]),
171
+ xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),
172
+ xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
173
+ ];
174
+ }
175
+ }
176
+ return gd;
177
+ };
178
+
179
+
180
+ // called within scope of series.
181
+ $.jqplot.BezierCurveRenderer.prototype.draw = function(ctx, gd, options) {
182
+ var i;
183
+ ctx.save();
184
+ if (gd.length) {
185
+ if (this.showLine) {
186
+ ctx.save();
187
+ var opts = (options != null) ? options : {};
188
+ ctx.fillStyle = opts.fillStyle || this.color;
189
+ ctx.beginPath();
190
+ ctx.moveTo(gd[0][0], gd[0][1]);
191
+ ctx.bezierCurveTo(gd[1][0], gd[1][1], gd[1][2], gd[1][3], gd[1][4], gd[1][5]);
192
+ ctx.lineTo(gd[2][0], gd[2][1]);
193
+ if (gd[3].length == 2) {
194
+ ctx.lineTo(gd[3][0], gd[3][1]);
195
+ }
196
+ else {
197
+ ctx.bezierCurveTo(gd[3][0], gd[3][1], gd[3][2], gd[3][3], gd[3][4], gd[3][5]);
198
+ }
199
+ ctx.closePath();
200
+ ctx.fill();
201
+ ctx.restore();
202
+ }
203
+ }
204
+
205
+ ctx.restore();
206
+ };
207
+
208
+ $.jqplot.BezierCurveRenderer.prototype.drawShadow = function(ctx, gd, options) {
209
+ // This is a no-op, shadows drawn with lines.
210
+ };
211
+
212
+ $.jqplot.BezierAxisRenderer = function() {
213
+ $.jqplot.LinearAxisRenderer.call(this);
214
+ };
215
+
216
+ $.jqplot.BezierAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
217
+ $.jqplot.BezierAxisRenderer.prototype.constructor = $.jqplot.BezierAxisRenderer;
218
+
219
+
220
+ // Axes on a plot with Bezier Curves
221
+ $.jqplot.BezierAxisRenderer.prototype.init = function(options){
222
+ $.extend(true, this, options);
223
+ var db = this._dataBounds;
224
+ // Go through all the series attached to this axis and find
225
+ // the min/max bounds for this axis.
226
+ for (var i=0; i<this._series.length; i++) {
227
+ var s = this._series[i];
228
+ var d = s.data;
229
+ if (d.length == 4) {
230
+ for (var j=0; j<d.length; j++) {
231
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
232
+ if (d[j][0] < db.min || db.min == null) {
233
+ db.min = d[j][0];
234
+ }
235
+ if (d[j][0] > db.max || db.max == null) {
236
+ db.max = d[j][0];
237
+ }
238
+ }
239
+ else {
240
+ if (d[j][1] < db.min || db.min == null) {
241
+ db.min = d[j][1];
242
+ }
243
+ if (d[j][1] > db.max || db.max == null) {
244
+ db.max = d[j][1];
245
+ }
246
+ }
247
+ }
248
+ }
249
+ else {
250
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
251
+ if (d[0][0] < db.min || db.min == null) {
252
+ db.min = d[0][0];
253
+ }
254
+ if (d[0][0] > db.max || db.max == null) {
255
+ db.max = d[0][0];
256
+ }
257
+ for (var j=0; j<5; j+=2) {
258
+ if (d[1][j] < db.min || db.min == null) {
259
+ db.min = d[1][j];
260
+ }
261
+ if (d[1][j] > db.max || db.max == null) {
262
+ db.max = d[1][j];
263
+ }
264
+ }
265
+ }
266
+ else {
267
+ if (d[0][1] < db.min || db.min == null) {
268
+ db.min = d[0][1];
269
+ }
270
+ if (d[0][1] > db.max || db.max == null) {
271
+ db.max = d[0][1];
272
+ }
273
+ for (var j=1; j<6; j+=2) {
274
+ if (d[1][j] < db.min || db.min == null) {
275
+ db.min = d[1][j];
276
+ }
277
+ if (d[1][j] > db.max || db.max == null) {
278
+ db.max = d[1][j];
279
+ }
280
+ }
281
+ }
282
+ }
283
+ }
284
+ };
285
+
286
+ // setup default renderers for axes and legend so user doesn't have to
287
+ // called with scope of plot
288
+ function preInit(target, data, options) {
289
+ options = options || {};
290
+ options.axesDefaults = $.extend(true, {pad:0}, options.axesDefaults);
291
+ options.legend = $.extend(true, {placement:'outside'}, options.legend);
292
+ // only set these if there is a pie series
293
+ var setopts = false;
294
+ if (options.seriesDefaults.renderer == $.jqplot.BezierCurveRenderer) {
295
+ setopts = true;
296
+ }
297
+ else if (options.series) {
298
+ for (var i=0; i < options.series.length; i++) {
299
+ if (options.series[i].renderer == $.jqplot.BezierCurveRenderer) {
300
+ setopts = true;
301
+ }
302
+ }
303
+ }
304
+
305
+ if (setopts) {
306
+ options.axesDefaults.renderer = $.jqplot.BezierAxisRenderer;
307
+ }
308
+ }
309
+
310
+ $.jqplot.preInitHooks.push(preInit);
311
+
312
+ })(jQuery);
@@ -0,0 +1,57 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b2_r1012
6
+ *
7
+ * Copyright (c) 2009-2011 Chris Leonello
8
+ * jqPlot is currently available for use in all personal or commercial projects
9
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
10
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
11
+ * choose the license that best suits your project and use it accordingly.
12
+ *
13
+ * Although not required, the author would appreciate an email letting him
14
+ * know of any substantial use of jqPlot. You can reach the author at:
15
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
16
+ *
17
+ * If you are feeling kind and generous, consider supporting the project by
18
+ * making a donation at: http://www.jqplot.com/donate.php .
19
+ *
20
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
21
+ *
22
+ * version 2007.04.27
23
+ * author Ash Searle
24
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
25
+ * http://hexmen.com/js/sprintf.js
26
+ * The author (Ash Searle) has placed this code in the public domain:
27
+ * "This code is unrestricted: you are free to use it however you like."
28
+ *
29
+ * included jsDate library by Chris Leonello:
30
+ *
31
+ * Copyright (c) 2010-2011 Chris Leonello
32
+ *
33
+ * jsDate is currently available for use in all personal or commercial projects
34
+ * under both the MIT and GPL version 2.0 licenses. This means that you can
35
+ * choose the license that best suits your project and use it accordingly.
36
+ *
37
+ * jsDate borrows many concepts and ideas from the Date Instance
38
+ * Methods by Ken Snyder along with some parts of Ken's actual code.
39
+ *
40
+ * Ken's origianl Date Instance Methods and copyright notice:
41
+ *
42
+ * Ken Snyder (ken d snyder at gmail dot com)
43
+ * 2008-09-10
44
+ * version 2.0.2 (http://kendsnyder.com/sandbox/date/)
45
+ * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
46
+ *
47
+ * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
48
+ * Larry has generously given permission to adapt his code for inclusion
49
+ * into jqPlot.
50
+ *
51
+ * Larry's original code can be found here:
52
+ *
53
+ * https://github.com/lsiden/export-jqplot-to-png
54
+ *
55
+ *
56
+ */
57
+ (function(b){b.jqplot.BezierCurveRenderer=function(){b.jqplot.LineRenderer.call(this)};b.jqplot.BezierCurveRenderer.prototype=new b.jqplot.LineRenderer();b.jqplot.BezierCurveRenderer.prototype.constructor=b.jqplot.BezierCurveRenderer;b.jqplot.BezierCurveRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var g=this._yaxis.series_u2p;var f=this.data;this.gridData=[];this._prevGridData=[];var d=this.index;if(f.length==2){if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,f[1][4]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,c[1][4]),g.call(this._yaxis,c[1][5])],[e.call(this._xaxis,c[1][2]),g.call(this._yaxis,c[1][3]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}else{if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,f[3][1]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,c[3][0]),g.call(this._yaxis,c[3][1])],[e.call(this._xaxis,c[2][0]),g.call(this._yaxis,c[2][1]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}};b.jqplot.BezierCurveRenderer.prototype.makeGridData=function(g,i){var f=this._xaxis.series_u2p;var h=this._yaxis.series_u2p;var e=[];var j=[];var d=this.index;if(g.length==2){if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,g[1][4]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,c[1][4]),h.call(this._yaxis,c[1][5])],[f.call(this._xaxis,c[1][2]),h.call(this._yaxis,c[1][3]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}else{if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,g[3][1]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,c[3][0]),h.call(this._yaxis,c[3][1])],[f.call(this._xaxis,c[2][0]),h.call(this._yaxis,c[2][1]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}return e};b.jqplot.BezierCurveRenderer.prototype.draw=function(c,g,d){var e;c.save();if(g.length){if(this.showLine){c.save();var f=(d!=null)?d:{};c.fillStyle=f.fillStyle||this.color;c.beginPath();c.moveTo(g[0][0],g[0][1]);c.bezierCurveTo(g[1][0],g[1][1],g[1][2],g[1][3],g[1][4],g[1][5]);c.lineTo(g[2][0],g[2][1]);if(g[3].length==2){c.lineTo(g[3][0],g[3][1])}else{c.bezierCurveTo(g[3][0],g[3][1],g[3][2],g[3][3],g[3][4],g[3][5])}c.closePath();c.fill();c.restore()}}c.restore()};b.jqplot.BezierCurveRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.BezierAxisRenderer=function(){b.jqplot.LinearAxisRenderer.call(this)};b.jqplot.BezierAxisRenderer.prototype=new b.jqplot.LinearAxisRenderer();b.jqplot.BezierAxisRenderer.prototype.constructor=b.jqplot.BezierAxisRenderer;b.jqplot.BezierAxisRenderer.prototype.init=function(f){b.extend(true,this,f);var c=this._dataBounds;for(var g=0;g<this._series.length;g++){var h=this._series[g];var k=h.data;if(k.length==4){for(var e=0;e<k.length;e++){if(this.name=="xaxis"||this.name=="x2axis"){if(k[e][0]<c.min||c.min==null){c.min=k[e][0]}if(k[e][0]>c.max||c.max==null){c.max=k[e][0]}}else{if(k[e][1]<c.min||c.min==null){c.min=k[e][1]}if(k[e][1]>c.max||c.max==null){c.max=k[e][1]}}}}else{if(this.name=="xaxis"||this.name=="x2axis"){if(k[0][0]<c.min||c.min==null){c.min=k[0][0]}if(k[0][0]>c.max||c.max==null){c.max=k[0][0]}for(var e=0;e<5;e+=2){if(k[1][e]<c.min||c.min==null){c.min=k[1][e]}if(k[1][e]>c.max||c.max==null){c.max=k[1][e]}}}else{if(k[0][1]<c.min||c.min==null){c.min=k[0][1]}if(k[0][1]>c.max||c.max==null){c.max=k[0][1]}for(var e=1;e<6;e+=2){if(k[1][e]<c.min||c.min==null){c.min=k[1][e]}if(k[1][e]>c.max||c.max==null){c.max=k[1][e]}}}}}};function a(g,f,d){d=d||{};d.axesDefaults=b.extend(true,{pad:0},d.axesDefaults);d.legend=b.extend(true,{placement:"outside"},d.legend);var c=false;if(d.seriesDefaults.renderer==b.jqplot.BezierCurveRenderer){c=true}else{if(d.series){for(var e=0;e<d.series.length;e++){if(d.series[e].renderer==b.jqplot.BezierCurveRenderer){c=true}}}}if(c){d.axesDefaults.renderer=b.jqplot.BezierAxisRenderer}}b.jqplot.preInitHooks.push(a)})(jQuery);
@@ -0,0 +1,747 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b2_r1012
6
+ *
7
+ * Copyright (c) 2009-2011 Chris Leonello
8
+ * jqPlot is currently available for use in all personal or commercial projects
9
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
10
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
11
+ * choose the license that best suits your project and use it accordingly.
12
+ *
13
+ * Although not required, the author would appreciate an email letting him
14
+ * know of any substantial use of jqPlot. You can reach the author at:
15
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
16
+ *
17
+ * If you are feeling kind and generous, consider supporting the project by
18
+ * making a donation at: http://www.jqplot.com/donate.php .
19
+ *
20
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
21
+ *
22
+ * version 2007.04.27
23
+ * author Ash Searle
24
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
25
+ * http://hexmen.com/js/sprintf.js
26
+ * The author (Ash Searle) has placed this code in the public domain:
27
+ * "This code is unrestricted: you are free to use it however you like."
28
+ *
29
+ */
30
+ (function($) {
31
+
32
+ // Class: $.jqplot.BarRenderer
33
+ // A plugin renderer for jqPlot to draw a bar plot.
34
+ // Draws series as a line.
35
+
36
+ $.jqplot.BarRenderer = function(){
37
+ $.jqplot.LineRenderer.call(this);
38
+ };
39
+
40
+ $.jqplot.BarRenderer.prototype = new $.jqplot.LineRenderer();
41
+ $.jqplot.BarRenderer.prototype.constructor = $.jqplot.BarRenderer;
42
+
43
+ // called with scope of series.
44
+ $.jqplot.BarRenderer.prototype.init = function(options, plot) {
45
+ // Group: Properties
46
+ //
47
+ // prop: barPadding
48
+ // Number of pixels between adjacent bars at the same axis value.
49
+ this.barPadding = 8;
50
+ // prop: barMargin
51
+ // Number of pixels between groups of bars at adjacent axis values.
52
+ this.barMargin = 10;
53
+ // prop: barDirection
54
+ // 'vertical' = up and down bars, 'horizontal' = side to side bars
55
+ this.barDirection = 'vertical';
56
+ // prop: barWidth
57
+ // Width of the bar in pixels (auto by devaul). null = calculated automatically.
58
+ this.barWidth = null;
59
+ // prop: shadowOffset
60
+ // offset of the shadow from the slice and offset of
61
+ // each succesive stroke of the shadow from the last.
62
+ this.shadowOffset = 2;
63
+ // prop: shadowDepth
64
+ // number of strokes to apply to the shadow,
65
+ // each stroke offset shadowOffset from the last.
66
+ this.shadowDepth = 5;
67
+ // prop: shadowAlpha
68
+ // transparency of the shadow (0 = transparent, 1 = opaque)
69
+ this.shadowAlpha = 0.08;
70
+ // prop: waterfall
71
+ // true to enable waterfall plot.
72
+ this.waterfall = false;
73
+ // prop: groups
74
+ // group bars into this many groups
75
+ this.groups = 1;
76
+ // prop: varyBarColor
77
+ // true to color each bar of a series separately rather than
78
+ // have every bar of a given series the same color.
79
+ // If used for non-stacked multiple series bar plots, user should
80
+ // specify a separate 'seriesColors' array for each series.
81
+ // Otherwise, each series will set their bars to the same color array.
82
+ // This option has no Effect for stacked bar charts and is disabled.
83
+ this.varyBarColor = false;
84
+ // prop: highlightMouseOver
85
+ // True to highlight slice when moused over.
86
+ // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
87
+ this.highlightMouseOver = true;
88
+ // prop: highlightMouseDown
89
+ // True to highlight when a mouse button is pressed over a slice.
90
+ // This will be disabled if highlightMouseOver is true.
91
+ this.highlightMouseDown = false;
92
+ // prop: highlightColors
93
+ // an array of colors to use when highlighting a bar.
94
+ this.highlightColors = [];
95
+ // prop: transposedData
96
+ // NOT IMPLEMENTED YET. True if this is a horizontal bar plot and
97
+ // x and y values are "transposed". Tranposed, or "swapped", data is
98
+ // required prior to rev. 894 builds of jqPlot with horizontal bars.
99
+ // Allows backward compatability of bar renderer horizontal bars with
100
+ // old style data sets.
101
+ this.transposedData = true;
102
+ this.renderer.animation = {
103
+ show: false,
104
+ direction: 'down',
105
+ speed: 3000,
106
+ _supported: true
107
+ };
108
+ this._type = 'bar';
109
+
110
+ // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
111
+ if (options.highlightMouseDown && options.highlightMouseOver == null) {
112
+ options.highlightMouseOver = false;
113
+ }
114
+
115
+ //////
116
+ // This is probably wrong here.
117
+ // After going back and forth on wether renderer should be the thing
118
+ // or extend the thing, it seems that it it best if it is a property
119
+ // on the thing. This should be something that is commonized
120
+ // among series renderers in the future.
121
+ //////
122
+ $.extend(true, this, options);
123
+
124
+ // really should probably do this
125
+ $.extend(true, this.renderer, options);
126
+ // fill is still needed to properly draw the legend.
127
+ // bars have to be filled.
128
+ this.fill = true;
129
+
130
+ // if horizontal bar and animating, reset the default direction
131
+ if (this.barDirection === 'horizontal' && this.rendererOptions.animation && this.rendererOptions.animation.direction == null) {
132
+ this.renderer.animation.direction = 'left';
133
+ }
134
+
135
+ if (this.waterfall) {
136
+ this.fillToZero = false;
137
+ this.disableStack = true;
138
+ }
139
+
140
+ if (this.barDirection == 'vertical' ) {
141
+ this._primaryAxis = '_xaxis';
142
+ this._stackAxis = 'y';
143
+ this.fillAxis = 'y';
144
+ }
145
+ else {
146
+ this._primaryAxis = '_yaxis';
147
+ this._stackAxis = 'x';
148
+ this.fillAxis = 'x';
149
+ }
150
+ // index of the currenty highlighted point, if any
151
+ this._highlightedPoint = null;
152
+ // total number of values for all bar series, total number of bar series, and position of this series
153
+ this._plotSeriesInfo = null;
154
+ // Array of actual data colors used for each data point.
155
+ this._dataColors = [];
156
+ this._barPoints = [];
157
+
158
+ // set the shape renderer options
159
+ var opts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill};
160
+ this.renderer.shapeRenderer.init(opts);
161
+ // set the shadow renderer options
162
+ var sopts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill};
163
+ this.renderer.shadowRenderer.init(sopts);
164
+
165
+ plot.postInitHooks.addOnce(postInit);
166
+ plot.postDrawHooks.addOnce(postPlotDraw);
167
+ plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
168
+ plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
169
+ plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
170
+ plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
171
+ plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
172
+ };
173
+
174
+ // called with scope of series
175
+ function barPreInit(target, data, seriesDefaults, options) {
176
+ if (this.rendererOptions.barDirection == 'horizontal') {
177
+ this._stackAxis = 'x';
178
+ this._primaryAxis = '_yaxis';
179
+ }
180
+ if (this.rendererOptions.waterfall == true) {
181
+ this._data = $.extend(true, [], this.data);
182
+ var sum = 0;
183
+ var pos = (!this.rendererOptions.barDirection || this.rendererOptions.barDirection === 'vertical' || this.transposedData === false) ? 1 : 0;
184
+ for(var i=0; i<this.data.length; i++) {
185
+ sum += this.data[i][pos];
186
+ if (i>0) {
187
+ this.data[i][pos] += this.data[i-1][pos];
188
+ }
189
+ }
190
+ this.data[this.data.length] = (pos == 1) ? [this.data.length+1, sum] : [sum, this.data.length+1];
191
+ this._data[this._data.length] = (pos == 1) ? [this._data.length+1, sum] : [sum, this._data.length+1];
192
+ }
193
+ if (this.rendererOptions.groups > 1) {
194
+ this.breakOnNull = true;
195
+ var l = this.data.length;
196
+ var skip = parseInt(l/this.rendererOptions.groups, 10);
197
+ var count = 0;
198
+ for (var i=skip; i<l; i+=skip) {
199
+ this.data.splice(i+count, 0, [null, null]);
200
+ count++;
201
+ }
202
+ for (i=0; i<this.data.length; i++) {
203
+ if (this._primaryAxis == '_xaxis') {
204
+ this.data[i][0] = i+1;
205
+ }
206
+ else {
207
+ this.data[i][1] = i+1;
208
+ }
209
+ }
210
+ }
211
+ }
212
+
213
+ $.jqplot.preSeriesInitHooks.push(barPreInit);
214
+
215
+ // needs to be called with scope of series, not renderer.
216
+ $.jqplot.BarRenderer.prototype.calcSeriesNumbers = function() {
217
+ var nvals = 0;
218
+ var nseries = 0;
219
+ var paxis = this[this._primaryAxis];
220
+ var s, series, pos;
221
+ // loop through all series on this axis
222
+ for (var i=0; i < paxis._series.length; i++) {
223
+ series = paxis._series[i];
224
+ if (series === this) {
225
+ pos = i;
226
+ }
227
+ // is the series rendered as a bar?
228
+ if (series.renderer.constructor == $.jqplot.BarRenderer) {
229
+ // gridData may not be computed yet, use data length insted
230
+ nvals += series.data.length;
231
+ nseries += 1;
232
+ }
233
+ }
234
+ // return total number of values for all bar series, total number of bar series, and position of this series
235
+ return [nvals, nseries, pos];
236
+ };
237
+
238
+ $.jqplot.BarRenderer.prototype.setBarWidth = function() {
239
+ // need to know how many data values we have on the approprate axis and figure it out.
240
+ var i;
241
+ var nvals = 0;
242
+ var nseries = 0;
243
+ var paxis = this[this._primaryAxis];
244
+ var s, series, pos;
245
+ var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
246
+ nvals = temp[0];
247
+ nseries = temp[1];
248
+ var nticks = paxis.numberTicks;
249
+ var nbins = (nticks-1)/2;
250
+ // so, now we have total number of axis values.
251
+ if (paxis.name == 'xaxis' || paxis.name == 'x2axis') {
252
+ if (this._stack) {
253
+ this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals * nseries - this.barMargin;
254
+ }
255
+ else {
256
+ this.barWidth = ((paxis._offsets.max - paxis._offsets.min)/nbins - this.barPadding * (nseries-1) - this.barMargin*2)/nseries;
257
+ // this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding - this.barMargin/nseries;
258
+ }
259
+ }
260
+ else {
261
+ if (this._stack) {
262
+ this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals * nseries - this.barMargin;
263
+ }
264
+ else {
265
+ this.barWidth = ((paxis._offsets.min - paxis._offsets.max)/nbins - this.barPadding * (nseries-1) - this.barMargin*2)/nseries;
266
+ // this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding - this.barMargin/nseries;
267
+ }
268
+ }
269
+ return [nvals, nseries];
270
+ };
271
+
272
+ function computeHighlightColors (colors) {
273
+ var ret = [];
274
+ for (var i=0; i<colors.length; i++){
275
+ var rgba = $.jqplot.getColorComponents(colors[i]);
276
+ var newrgb = [rgba[0], rgba[1], rgba[2]];
277
+ var sum = newrgb[0] + newrgb[1] + newrgb[2];
278
+ for (var j=0; j<3; j++) {
279
+ // when darkening, lowest color component can be is 60.
280
+ newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
281
+ newrgb[j] = parseInt(newrgb[j], 10);
282
+ }
283
+ ret.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
284
+ }
285
+ return ret;
286
+ }
287
+
288
+ $.jqplot.BarRenderer.prototype.draw = function(ctx, gridData, options) {
289
+ var i;
290
+ // Ughhh, have to make a copy of options b/c it may be modified later.
291
+ var opts = $.extend({}, options);
292
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
293
+ var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
294
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
295
+ var xaxis = this.xaxis;
296
+ var yaxis = this.yaxis;
297
+ var xp = this._xaxis.series_u2p;
298
+ var yp = this._yaxis.series_u2p;
299
+ var pointx, pointy;
300
+ // clear out data colors.
301
+ this._dataColors = [];
302
+ this._barPoints = [];
303
+
304
+ if (this.barWidth == null) {
305
+ this.renderer.setBarWidth.call(this);
306
+ }
307
+
308
+ var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
309
+ var nvals = temp[0];
310
+ var nseries = temp[1];
311
+ var pos = temp[2];
312
+ var points = [];
313
+
314
+ if (this._stack) {
315
+ this._barNudge = 0;
316
+ }
317
+ else {
318
+ this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding);
319
+ }
320
+ if (showLine) {
321
+ var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors);
322
+ var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors);
323
+ var negativeColor = negativeColors.get(this.index);
324
+ if (! this.useNegativeColors) {
325
+ negativeColor = opts.fillStyle;
326
+ }
327
+ var positiveColor = opts.fillStyle;
328
+ var base;
329
+ var xstart;
330
+ var ystart;
331
+
332
+ if (this.barDirection == 'vertical') {
333
+ for (var i=0; i<gridData.length; i++) {
334
+ if (this.data[i][1] == null) {
335
+ continue;
336
+ }
337
+ points = [];
338
+ base = gridData[i][0] + this._barNudge;
339
+ ystart;
340
+
341
+ // stacked
342
+ if (this._stack && this._prevGridData.length) {
343
+ ystart = this._prevGridData[i][1];
344
+ }
345
+ // not stacked and first series in stack
346
+ else {
347
+ if (this.fillToZero) {
348
+ ystart = this._yaxis.series_u2p(0);
349
+ }
350
+ else if (this.waterfall && i > 0 && i < this.gridData.length-1) {
351
+ ystart = this.gridData[i-1][1];
352
+ }
353
+ else if (this.waterfall && i == 0 && i < this.gridData.length-1) {
354
+ if (this._yaxis.min <= 0 && this._yaxis.max >= 0) {
355
+ ystart = this._yaxis.series_u2p(0);
356
+ }
357
+ else if (this._yaxis.min > 0) {
358
+ ystart = ctx.canvas.height;
359
+ }
360
+ else {
361
+ ystart = 0;
362
+ }
363
+ }
364
+ else if (this.waterfall && i == this.gridData.length - 1) {
365
+ if (this._yaxis.min <= 0 && this._yaxis.max >= 0) {
366
+ ystart = this._yaxis.series_u2p(0);
367
+ }
368
+ else if (this._yaxis.min > 0) {
369
+ ystart = ctx.canvas.height;
370
+ }
371
+ else {
372
+ ystart = 0;
373
+ }
374
+ }
375
+ else {
376
+ ystart = ctx.canvas.height;
377
+ }
378
+ }
379
+ if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) {
380
+ if (this.varyBarColor && !this._stack) {
381
+ if (this.useNegativeColors) {
382
+ opts.fillStyle = negativeColors.next();
383
+ }
384
+ else {
385
+ opts.fillStyle = positiveColors.next();
386
+ }
387
+ }
388
+ else {
389
+ opts.fillStyle = negativeColor;
390
+ }
391
+ }
392
+ else {
393
+ if (this.varyBarColor && !this._stack) {
394
+ opts.fillStyle = positiveColors.next();
395
+ }
396
+ else {
397
+ opts.fillStyle = positiveColor;
398
+ }
399
+ }
400
+
401
+ if (!this.fillToZero || this._plotData[i][1] >= 0) {
402
+ points.push([base-this.barWidth/2, ystart]);
403
+ points.push([base-this.barWidth/2, gridData[i][1]]);
404
+ points.push([base+this.barWidth/2, gridData[i][1]]);
405
+ points.push([base+this.barWidth/2, ystart]);
406
+ }
407
+ // for negative bars make sure points are always ordered clockwise
408
+ else {
409
+ points.push([base-this.barWidth/2, gridData[i][1]]);
410
+ points.push([base-this.barWidth/2, ystart]);
411
+ points.push([base+this.barWidth/2, ystart]);
412
+ points.push([base+this.barWidth/2, gridData[i][1]]);
413
+ }
414
+ this._barPoints.push(points);
415
+ // now draw the shadows if not stacked.
416
+ // for stacked plots, they are predrawn by drawShadow
417
+ if (shadow && !this._stack) {
418
+ var sopts = $.extend(true, {}, opts);
419
+ // need to get rid of fillStyle on shadow.
420
+ delete sopts.fillStyle;
421
+ this.renderer.shadowRenderer.draw(ctx, points, sopts);
422
+ }
423
+ var clr = opts.fillStyle || this.color;
424
+ this._dataColors.push(clr);
425
+ this.renderer.shapeRenderer.draw(ctx, points, opts);
426
+ }
427
+ }
428
+
429
+ else if (this.barDirection == 'horizontal'){
430
+ for (var i=0; i<gridData.length; i++) {
431
+ if (this.data[i][0] == null) {
432
+ continue;
433
+ }
434
+ points = [];
435
+ base = gridData[i][1] - this._barNudge;
436
+ xstart;
437
+
438
+ if (this._stack && this._prevGridData.length) {
439
+ xstart = this._prevGridData[i][0];
440
+ }
441
+ // not stacked and first series in stack
442
+ else {
443
+ if (this.fillToZero) {
444
+ xstart = this._xaxis.series_u2p(0);
445
+ }
446
+ else if (this.waterfall && i > 0 && i < this.gridData.length-1) {
447
+ xstart = this.gridData[i-1][1];
448
+ }
449
+ else if (this.waterfall && i == 0 && i < this.gridData.length-1) {
450
+ if (this._xaxis.min <= 0 && this._xaxis.max >= 0) {
451
+ xstart = this._xaxis.series_u2p(0);
452
+ }
453
+ else if (this._xaxis.min > 0) {
454
+ xstart = 0;
455
+ }
456
+ else {
457
+ xstart = ctx.canvas.width;
458
+ }
459
+ }
460
+ else if (this.waterfall && i == this.gridData.length - 1) {
461
+ if (this._xaxis.min <= 0 && this._xaxis.max >= 0) {
462
+ xstart = this._xaxis.series_u2p(0);
463
+ }
464
+ else if (this._xaxis.min > 0) {
465
+ xstart = 0;
466
+ }
467
+ else {
468
+ xstart = ctx.canvas.width;
469
+ }
470
+ }
471
+ else {
472
+ xstart = 0;
473
+ }
474
+ }
475
+ if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) {
476
+ if (this.varyBarColor && !this._stack) {
477
+ if (this.useNegativeColors) {
478
+ opts.fillStyle = negativeColors.next();
479
+ }
480
+ else {
481
+ opts.fillStyle = positiveColors.next();
482
+ }
483
+ }
484
+ }
485
+ else {
486
+ if (this.varyBarColor && !this._stack) {
487
+ opts.fillStyle = positiveColors.next();
488
+ }
489
+ else {
490
+ opts.fillStyle = positiveColor;
491
+ }
492
+ }
493
+
494
+
495
+ if (!this.fillToZero || this._plotData[i][0] >= 0) {
496
+ points.push([xstart, base + this.barWidth / 2]);
497
+ points.push([xstart, base - this.barWidth / 2]);
498
+ points.push([gridData[i][0], base - this.barWidth / 2]);
499
+ points.push([gridData[i][0], base + this.barWidth / 2]);
500
+ }
501
+ else {
502
+ points.push([gridData[i][0], base + this.barWidth / 2]);
503
+ points.push([gridData[i][0], base - this.barWidth / 2]);
504
+ points.push([xstart, base - this.barWidth / 2]);
505
+ points.push([xstart, base + this.barWidth / 2]);
506
+ }
507
+
508
+ this._barPoints.push(points);
509
+ // now draw the shadows if not stacked.
510
+ // for stacked plots, they are predrawn by drawShadow
511
+ if (shadow && !this._stack) {
512
+ var sopts = $.extend(true, {}, opts);
513
+ delete sopts.fillStyle;
514
+ this.renderer.shadowRenderer.draw(ctx, points, sopts);
515
+ }
516
+ var clr = opts.fillStyle || this.color;
517
+ this._dataColors.push(clr);
518
+ this.renderer.shapeRenderer.draw(ctx, points, opts);
519
+ }
520
+ }
521
+ }
522
+
523
+ if (this.highlightColors.length == 0) {
524
+ this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors);
525
+ }
526
+
527
+ else if (typeof(this.highlightColors) == 'string') {
528
+ var temp = this.highlightColors;
529
+ this.highlightColors = [];
530
+ for (var i=0; i<this._dataColors.length; i++) {
531
+ this.highlightColors.push(temp);
532
+ }
533
+ }
534
+
535
+ };
536
+
537
+
538
+ // for stacked plots, shadows will be pre drawn by drawShadow.
539
+ $.jqplot.BarRenderer.prototype.drawShadow = function(ctx, gridData, options) {
540
+ var i;
541
+ var opts = (options != undefined) ? options : {};
542
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
543
+ var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
544
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
545
+ var xaxis = this.xaxis;
546
+ var yaxis = this.yaxis;
547
+ var xp = this._xaxis.series_u2p;
548
+ var yp = this._yaxis.series_u2p;
549
+ var pointx, points, pointy, nvals, nseries, pos;
550
+
551
+ if (this._stack && this.shadow) {
552
+ if (this.barWidth == null) {
553
+ this.renderer.setBarWidth.call(this);
554
+ }
555
+
556
+ var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
557
+ nvals = temp[0];
558
+ nseries = temp[1];
559
+ pos = temp[2];
560
+
561
+ if (this._stack) {
562
+ this._barNudge = 0;
563
+ }
564
+ else {
565
+ this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding);
566
+ }
567
+ if (showLine) {
568
+
569
+ if (this.barDirection == 'vertical') {
570
+ for (var i=0; i<gridData.length; i++) {
571
+ if (this.data[i][1] == null) {
572
+ continue;
573
+ }
574
+ points = [];
575
+ var base = gridData[i][0] + this._barNudge;
576
+ var ystart;
577
+
578
+ if (this._stack && this._prevGridData.length) {
579
+ ystart = this._prevGridData[i][1];
580
+ }
581
+ else {
582
+ if (this.fillToZero) {
583
+ ystart = this._yaxis.series_u2p(0);
584
+ }
585
+ else {
586
+ ystart = ctx.canvas.height;
587
+ }
588
+ }
589
+
590
+ points.push([base-this.barWidth/2, ystart]);
591
+ points.push([base-this.barWidth/2, gridData[i][1]]);
592
+ points.push([base+this.barWidth/2, gridData[i][1]]);
593
+ points.push([base+this.barWidth/2, ystart]);
594
+ this.renderer.shadowRenderer.draw(ctx, points, opts);
595
+ }
596
+ }
597
+
598
+ else if (this.barDirection == 'horizontal'){
599
+ for (var i=0; i<gridData.length; i++) {
600
+ if (this.data[i][0] == null) {
601
+ continue;
602
+ }
603
+ points = [];
604
+ var base = gridData[i][1] - this._barNudge;
605
+ var xstart;
606
+
607
+ if (this._stack && this._prevGridData.length) {
608
+ xstart = this._prevGridData[i][0];
609
+ }
610
+ else {
611
+ xstart = 0;
612
+ }
613
+
614
+ points.push([xstart, base+this.barWidth/2]);
615
+ points.push([gridData[i][0], base+this.barWidth/2]);
616
+ points.push([gridData[i][0], base-this.barWidth/2]);
617
+ points.push([xstart, base-this.barWidth/2]);
618
+ this.renderer.shadowRenderer.draw(ctx, points, opts);
619
+ }
620
+ }
621
+ }
622
+
623
+ }
624
+ };
625
+
626
+ function postInit(target, data, options) {
627
+ for (var i=0; i<this.series.length; i++) {
628
+ if (this.series[i].renderer.constructor == $.jqplot.BarRenderer) {
629
+ // don't allow mouseover and mousedown at same time.
630
+ if (this.series[i].highlightMouseOver) {
631
+ this.series[i].highlightMouseDown = false;
632
+ }
633
+ }
634
+ }
635
+ }
636
+
637
+ // called within context of plot
638
+ // create a canvas which we can draw on.
639
+ // insert it before the eventCanvas, so eventCanvas will still capture events.
640
+ function postPlotDraw() {
641
+ // Memory Leaks patch
642
+ if (this.plugins.barRenderer && this.plugins.barRenderer.highlightCanvas) {
643
+
644
+ this.plugins.barRenderer.highlightCanvas.resetCanvas();
645
+ this.plugins.barRenderer.highlightCanvas = null;
646
+ }
647
+
648
+ this.plugins.barRenderer = {highlightedSeriesIndex:null};
649
+ this.plugins.barRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
650
+
651
+ this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-barRenderer-highlight-canvas', this._plotDimensions, this));
652
+ this.plugins.barRenderer.highlightCanvas.setContext();
653
+ this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
654
+ }
655
+
656
+ function highlight (plot, sidx, pidx, points) {
657
+ var s = plot.series[sidx];
658
+ var canvas = plot.plugins.barRenderer.highlightCanvas;
659
+ canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
660
+ s._highlightedPoint = pidx;
661
+ plot.plugins.barRenderer.highlightedSeriesIndex = sidx;
662
+ var opts = {fillStyle: s.highlightColors[pidx]};
663
+ s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
664
+ canvas = null;
665
+ }
666
+
667
+ function unhighlight (plot) {
668
+ var canvas = plot.plugins.barRenderer.highlightCanvas;
669
+ canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
670
+ for (var i=0; i<plot.series.length; i++) {
671
+ plot.series[i]._highlightedPoint = null;
672
+ }
673
+ plot.plugins.barRenderer.highlightedSeriesIndex = null;
674
+ plot.target.trigger('jqplotDataUnhighlight');
675
+ canvas = null;
676
+ }
677
+
678
+
679
+ function handleMove(ev, gridpos, datapos, neighbor, plot) {
680
+ if (neighbor) {
681
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
682
+ var evt1 = jQuery.Event('jqplotDataMouseOver');
683
+ evt1.pageX = ev.pageX;
684
+ evt1.pageY = ev.pageY;
685
+ plot.target.trigger(evt1, ins);
686
+ if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
687
+ var evt = jQuery.Event('jqplotDataHighlight');
688
+ evt.pageX = ev.pageX;
689
+ evt.pageY = ev.pageY;
690
+ plot.target.trigger(evt, ins);
691
+ highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
692
+ }
693
+ }
694
+ else if (neighbor == null) {
695
+ unhighlight (plot);
696
+ }
697
+ }
698
+
699
+ function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
700
+ if (neighbor) {
701
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
702
+ if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
703
+ var evt = jQuery.Event('jqplotDataHighlight');
704
+ evt.pageX = ev.pageX;
705
+ evt.pageY = ev.pageY;
706
+ plot.target.trigger(evt, ins);
707
+ highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
708
+ }
709
+ }
710
+ else if (neighbor == null) {
711
+ unhighlight (plot);
712
+ }
713
+ }
714
+
715
+ function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
716
+ var idx = plot.plugins.barRenderer.highlightedSeriesIndex;
717
+ if (idx != null && plot.series[idx].highlightMouseDown) {
718
+ unhighlight(plot);
719
+ }
720
+ }
721
+
722
+ function handleClick(ev, gridpos, datapos, neighbor, plot) {
723
+ if (neighbor) {
724
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
725
+ var evt = jQuery.Event('jqplotDataClick');
726
+ evt.pageX = ev.pageX;
727
+ evt.pageY = ev.pageY;
728
+ plot.target.trigger(evt, ins);
729
+ }
730
+ }
731
+
732
+ function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
733
+ if (neighbor) {
734
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
735
+ var idx = plot.plugins.barRenderer.highlightedSeriesIndex;
736
+ if (idx != null && plot.series[idx].highlightMouseDown) {
737
+ unhighlight(plot);
738
+ }
739
+ var evt = jQuery.Event('jqplotDataRightClick');
740
+ evt.pageX = ev.pageX;
741
+ evt.pageY = ev.pageY;
742
+ plot.target.trigger(evt, ins);
743
+ }
744
+ }
745
+
746
+
747
+ })(jQuery);