jqplot-rails 0.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/lib/jqplot-rails.rb +6 -4
  2. data/lib/jqplot-rails/railtie.rb +9 -0
  3. data/lib/jqplot-rails/view_helpers.rb +11 -0
  4. data/vendor/assets/javascripts/jqplot/excanvas.js +1438 -0
  5. data/vendor/assets/javascripts/jqplot/index.js +66 -0
  6. data/vendor/assets/javascripts/{jqplot.1.0.0b2_r792.js → jqplot/jquery.jqplot.js} +3458 -793
  7. data/vendor/assets/javascripts/jqplot/plugins/BezierCurveRenderer.js +313 -0
  8. data/vendor/assets/javascripts/jqplot/plugins/barRenderer.js +797 -0
  9. data/vendor/assets/javascripts/jqplot/plugins/blockRenderer.js +235 -0
  10. data/vendor/assets/javascripts/jqplot/plugins/bubbleRenderer.js +759 -0
  11. data/vendor/assets/javascripts/jqplot/plugins/canvasAxisLabelRenderer.js +203 -0
  12. data/vendor/assets/javascripts/jqplot/plugins/canvasAxisTickRenderer.js +243 -0
  13. data/vendor/assets/javascripts/jqplot/plugins/canvasOverlay.js +865 -0
  14. data/vendor/assets/javascripts/jqplot/plugins/canvasTextRenderer.js +449 -0
  15. data/vendor/assets/javascripts/jqplot/plugins/categoryAxisRenderer.js +673 -0
  16. data/vendor/assets/javascripts/jqplot/plugins/ciParser.js +116 -0
  17. data/vendor/assets/javascripts/jqplot/plugins/cursor.js +1108 -0
  18. data/vendor/assets/javascripts/jqplot/plugins/dateAxisRenderer.js +737 -0
  19. data/vendor/assets/javascripts/jqplot/plugins/donutRenderer.js +805 -0
  20. data/vendor/assets/javascripts/jqplot/plugins/dragable.js +225 -0
  21. data/vendor/assets/javascripts/jqplot/plugins/enhancedLegendRenderer.js +305 -0
  22. data/vendor/assets/javascripts/jqplot/plugins/funnelRenderer.js +943 -0
  23. data/vendor/assets/javascripts/jqplot/plugins/highlighter.js +465 -0
  24. data/vendor/assets/javascripts/jqplot/plugins/json2.js +475 -0
  25. data/vendor/assets/javascripts/jqplot/plugins/logAxisRenderer.js +529 -0
  26. data/vendor/assets/javascripts/jqplot/plugins/mekkoAxisRenderer.js +611 -0
  27. data/vendor/assets/javascripts/jqplot/plugins/mekkoRenderer.js +437 -0
  28. data/vendor/assets/javascripts/jqplot/plugins/meterGaugeRenderer.js +1030 -0
  29. data/vendor/assets/javascripts/jqplot/plugins/mobile.js +45 -0
  30. data/vendor/assets/javascripts/jqplot/plugins/ohlcRenderer.js +373 -0
  31. data/vendor/assets/javascripts/jqplot/plugins/pieRenderer.js +904 -0
  32. data/vendor/assets/javascripts/jqplot/plugins/pointLabels.js +379 -0
  33. data/vendor/assets/javascripts/jqplot/plugins/pyramidAxisRenderer.js +728 -0
  34. data/vendor/assets/javascripts/jqplot/plugins/pyramidGridRenderer.js +429 -0
  35. data/vendor/assets/javascripts/jqplot/plugins/pyramidRenderer.js +514 -0
  36. data/vendor/assets/javascripts/jqplot/plugins/trendline.js +223 -0
  37. data/vendor/assets/stylesheets/{jqplot.1.0.0b2_r792.css → jqplot.css} +48 -15
  38. metadata +64 -25
@@ -0,0 +1,449 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.5
6
+ * Revision: 1122+
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ * included jsDate library by Chris Leonello:
31
+ *
32
+ * Copyright (c) 2010-2013 Chris Leonello
33
+ *
34
+ * jsDate is currently available for use in all personal or commercial projects
35
+ * under both the MIT and GPL version 2.0 licenses. This means that you can
36
+ * choose the license that best suits your project and use it accordingly.
37
+ *
38
+ * jsDate borrows many concepts and ideas from the Date Instance
39
+ * Methods by Ken Snyder along with some parts of Ken's actual code.
40
+ *
41
+ * Ken's origianl Date Instance Methods and copyright notice:
42
+ *
43
+ * Ken Snyder (ken d snyder at gmail dot com)
44
+ * 2008-09-10
45
+ * version 2.0.2 (http://kendsnyder.com/sandbox/date/)
46
+ * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
47
+ *
48
+ * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
49
+ * Larry has generously given permission to adapt his code for inclusion
50
+ * into jqPlot.
51
+ *
52
+ * Larry's original code can be found here:
53
+ *
54
+ * https://github.com/lsiden/export-jqplot-to-png
55
+ *
56
+ *
57
+ */
58
+
59
+ (function($) {
60
+ // This code is a modified version of the canvastext.js code, copyright below:
61
+ //
62
+ // This code is released to the public domain by Jim Studt, 2007.
63
+ // He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/
64
+ //
65
+ $.jqplot.CanvasTextRenderer = function(options){
66
+ this.fontStyle = 'normal'; // normal, italic, oblique [not implemented]
67
+ this.fontVariant = 'normal'; // normal, small caps [not implemented]
68
+ this.fontWeight = 'normal'; // normal, bold, bolder, lighter, 100 - 900
69
+ this.fontSize = '10px';
70
+ this.fontFamily = 'sans-serif';
71
+ this.fontStretch = 1.0;
72
+ this.fillStyle = '#666666';
73
+ this.angle = 0;
74
+ this.textAlign = 'start';
75
+ this.textBaseline = 'alphabetic';
76
+ this.text;
77
+ this.width;
78
+ this.height;
79
+ this.pt2px = 1.28;
80
+
81
+ $.extend(true, this, options);
82
+ this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
83
+ this.setHeight();
84
+ };
85
+
86
+ $.jqplot.CanvasTextRenderer.prototype.init = function(options) {
87
+ $.extend(true, this, options);
88
+ this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
89
+ this.setHeight();
90
+ };
91
+
92
+ // convert css spec into point size
93
+ // returns float
94
+ $.jqplot.CanvasTextRenderer.prototype.normalizeFontSize = function(sz) {
95
+ sz = String(sz);
96
+ var n = parseFloat(sz);
97
+ if (sz.indexOf('px') > -1) {
98
+ return n/this.pt2px;
99
+ }
100
+ else if (sz.indexOf('pt') > -1) {
101
+ return n;
102
+ }
103
+ else if (sz.indexOf('em') > -1) {
104
+ return n*12;
105
+ }
106
+ else if (sz.indexOf('%') > -1) {
107
+ return n*12/100;
108
+ }
109
+ // default to pixels;
110
+ else {
111
+ return n/this.pt2px;
112
+ }
113
+ };
114
+
115
+
116
+ $.jqplot.CanvasTextRenderer.prototype.fontWeight2Float = function(w) {
117
+ // w = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
118
+ // return values adjusted for Hershey font.
119
+ if (Number(w)) {
120
+ return w/400;
121
+ }
122
+ else {
123
+ switch (w) {
124
+ case 'normal':
125
+ return 1;
126
+ break;
127
+ case 'bold':
128
+ return 1.75;
129
+ break;
130
+ case 'bolder':
131
+ return 2.25;
132
+ break;
133
+ case 'lighter':
134
+ return 0.75;
135
+ break;
136
+ default:
137
+ return 1;
138
+ break;
139
+ }
140
+ }
141
+ };
142
+
143
+ $.jqplot.CanvasTextRenderer.prototype.getText = function() {
144
+ return this.text;
145
+ };
146
+
147
+ $.jqplot.CanvasTextRenderer.prototype.setText = function(t, ctx) {
148
+ this.text = t;
149
+ this.setWidth(ctx);
150
+ return this;
151
+ };
152
+
153
+ $.jqplot.CanvasTextRenderer.prototype.getWidth = function(ctx) {
154
+ return this.width;
155
+ };
156
+
157
+ $.jqplot.CanvasTextRenderer.prototype.setWidth = function(ctx, w) {
158
+ if (!w) {
159
+ this.width = this.measure(ctx, this.text);
160
+ }
161
+ else {
162
+ this.width = w;
163
+ }
164
+ return this;
165
+ };
166
+
167
+ // return height in pixels.
168
+ $.jqplot.CanvasTextRenderer.prototype.getHeight = function(ctx) {
169
+ return this.height;
170
+ };
171
+
172
+ // w - height in pt
173
+ // set heigh in px
174
+ $.jqplot.CanvasTextRenderer.prototype.setHeight = function(w) {
175
+ if (!w) {
176
+ //height = this.fontSize /0.75;
177
+ this.height = this.normalizedFontSize * this.pt2px;
178
+ }
179
+ else {
180
+ this.height = w;
181
+ }
182
+ return this;
183
+ };
184
+
185
+ $.jqplot.CanvasTextRenderer.prototype.letter = function (ch)
186
+ {
187
+ return this.letters[ch];
188
+ };
189
+
190
+ $.jqplot.CanvasTextRenderer.prototype.ascent = function()
191
+ {
192
+ return this.normalizedFontSize;
193
+ };
194
+
195
+ $.jqplot.CanvasTextRenderer.prototype.descent = function()
196
+ {
197
+ return 7.0*this.normalizedFontSize/25.0;
198
+ };
199
+
200
+ $.jqplot.CanvasTextRenderer.prototype.measure = function(ctx, str)
201
+ {
202
+ var total = 0;
203
+ var len = str.length;
204
+
205
+ for (var i = 0; i < len; i++) {
206
+ var c = this.letter(str.charAt(i));
207
+ if (c) {
208
+ total += c.width * this.normalizedFontSize / 25.0 * this.fontStretch;
209
+ }
210
+ }
211
+ return total;
212
+ };
213
+
214
+ $.jqplot.CanvasTextRenderer.prototype.draw = function(ctx,str)
215
+ {
216
+ var x = 0;
217
+ // leave room at bottom for descenders.
218
+ var y = this.height*0.72;
219
+ var total = 0;
220
+ var len = str.length;
221
+ var mag = this.normalizedFontSize / 25.0;
222
+
223
+ ctx.save();
224
+ var tx, ty;
225
+
226
+ // 1st quadrant
227
+ if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
228
+ tx = 0;
229
+ ty = -Math.sin(this.angle) * this.width;
230
+ }
231
+ // 4th quadrant
232
+ else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
233
+ tx = Math.sin(this.angle) * this.height;
234
+ ty = 0;
235
+ }
236
+ // 2nd quadrant
237
+ else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
238
+ tx = -Math.cos(this.angle) * this.width;
239
+ ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
240
+ }
241
+ // 3rd quadrant
242
+ else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
243
+ tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
244
+ ty = -Math.cos(this.angle) * this.height;
245
+ }
246
+
247
+ ctx.strokeStyle = this.fillStyle;
248
+ ctx.fillStyle = this.fillStyle;
249
+ ctx.translate(tx, ty);
250
+ ctx.rotate(this.angle);
251
+ ctx.lineCap = "round";
252
+ // multiplier was 2.0
253
+ var fact = (this.normalizedFontSize > 30) ? 2.0 : 2 + (30 - this.normalizedFontSize)/20;
254
+ ctx.lineWidth = fact * mag * this.fontWeight2Float(this.fontWeight);
255
+
256
+ for ( var i = 0; i < len; i++) {
257
+ var c = this.letter( str.charAt(i));
258
+ if ( !c) {
259
+ continue;
260
+ }
261
+
262
+ ctx.beginPath();
263
+
264
+ var penUp = 1;
265
+ var needStroke = 0;
266
+ for ( var j = 0; j < c.points.length; j++) {
267
+ var a = c.points[j];
268
+ if ( a[0] == -1 && a[1] == -1) {
269
+ penUp = 1;
270
+ continue;
271
+ }
272
+ if ( penUp) {
273
+ ctx.moveTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
274
+ penUp = false;
275
+ } else {
276
+ ctx.lineTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
277
+ }
278
+ }
279
+ ctx.stroke();
280
+ x += c.width*mag*this.fontStretch;
281
+ }
282
+ ctx.restore();
283
+ return total;
284
+ };
285
+
286
+ $.jqplot.CanvasTextRenderer.prototype.letters = {
287
+ ' ': { width: 16, points: [] },
288
+ '!': { width: 10, points: [[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
289
+ '"': { width: 16, points: [[4,21],[4,14],[-1,-1],[12,21],[12,14]] },
290
+ '#': { width: 21, points: [[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]] },
291
+ '$': { width: 20, points: [[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
292
+ '%': { width: 24, points: [[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]] },
293
+ '&': { width: 26, points: [[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]] },
294
+ '\'': { width: 10, points: [[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]] },
295
+ '(': { width: 14, points: [[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]] },
296
+ ')': { width: 14, points: [[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]] },
297
+ '*': { width: 16, points: [[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]] },
298
+ '+': { width: 26, points: [[13,18],[13,0],[-1,-1],[4,9],[22,9]] },
299
+ ',': { width: 10, points: [[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
300
+ '-': { width: 18, points: [[6,9],[12,9]] },
301
+ '.': { width: 10, points: [[5,2],[4,1],[5,0],[6,1],[5,2]] },
302
+ '/': { width: 22, points: [[20,25],[2,-7]] },
303
+ '0': { width: 20, points: [[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]] },
304
+ '1': { width: 20, points: [[6,17],[8,18],[11,21],[11,0]] },
305
+ '2': { width: 20, points: [[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]] },
306
+ '3': { width: 20, points: [[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
307
+ '4': { width: 20, points: [[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]] },
308
+ '5': { width: 20, points: [[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
309
+ '6': { width: 20, points: [[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]] },
310
+ '7': { width: 20, points: [[17,21],[7,0],[-1,-1],[3,21],[17,21]] },
311
+ '8': { width: 20, points: [[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]] },
312
+ '9': { width: 20, points: [[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]] },
313
+ ':': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
314
+ ';': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
315
+ '<': { width: 24, points: [[20,18],[4,9],[20,0]] },
316
+ '=': { width: 26, points: [[4,12],[22,12],[-1,-1],[4,6],[22,6]] },
317
+ '>': { width: 24, points: [[4,18],[20,9],[4,0]] },
318
+ '?': { width: 18, points: [[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]] },
319
+ '@': { width: 27, points: [[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]] },
320
+ 'A': { width: 18, points: [[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]] },
321
+ 'B': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]] },
322
+ 'C': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]] },
323
+ 'D': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]] },
324
+ 'E': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]] },
325
+ 'F': { width: 18, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]] },
326
+ 'G': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]] },
327
+ 'H': { width: 22, points: [[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]] },
328
+ 'I': { width: 8, points: [[4,21],[4,0]] },
329
+ 'J': { width: 16, points: [[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]] },
330
+ 'K': { width: 21, points: [[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]] },
331
+ 'L': { width: 17, points: [[4,21],[4,0],[-1,-1],[4,0],[16,0]] },
332
+ 'M': { width: 24, points: [[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]] },
333
+ 'N': { width: 22, points: [[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]] },
334
+ 'O': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]] },
335
+ 'P': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]] },
336
+ 'Q': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]] },
337
+ 'R': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]] },
338
+ 'S': { width: 20, points: [[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
339
+ 'T': { width: 16, points: [[8,21],[8,0],[-1,-1],[1,21],[15,21]] },
340
+ 'U': { width: 22, points: [[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]] },
341
+ 'V': { width: 18, points: [[1,21],[9,0],[-1,-1],[17,21],[9,0]] },
342
+ 'W': { width: 24, points: [[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]] },
343
+ 'X': { width: 20, points: [[3,21],[17,0],[-1,-1],[17,21],[3,0]] },
344
+ 'Y': { width: 18, points: [[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]] },
345
+ 'Z': { width: 20, points: [[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]] },
346
+ '[': { width: 14, points: [[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]] },
347
+ '\\': { width: 14, points: [[0,21],[14,-3]] },
348
+ ']': { width: 14, points: [[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]] },
349
+ '^': { width: 16, points: [[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]] },
350
+ '_': { width: 16, points: [[0,-2],[16,-2]] },
351
+ '`': { width: 10, points: [[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]] },
352
+ 'a': { width: 19, points: [[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
353
+ 'b': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
354
+ 'c': { width: 18, points: [[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
355
+ 'd': { width: 19, points: [[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
356
+ 'e': { width: 18, points: [[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
357
+ 'f': { width: 12, points: [[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]] },
358
+ 'g': { width: 19, points: [[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
359
+ 'h': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
360
+ 'i': { width: 8, points: [[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]] },
361
+ 'j': { width: 10, points: [[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]] },
362
+ 'k': { width: 17, points: [[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]] },
363
+ 'l': { width: 8, points: [[4,21],[4,0]] },
364
+ 'm': { width: 30, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]] },
365
+ 'n': { width: 19, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
366
+ 'o': { width: 19, points: [[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]] },
367
+ 'p': { width: 19, points: [[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
368
+ 'q': { width: 19, points: [[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
369
+ 'r': { width: 13, points: [[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]] },
370
+ 's': { width: 17, points: [[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]] },
371
+ 't': { width: 12, points: [[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]] },
372
+ 'u': { width: 19, points: [[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]] },
373
+ 'v': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0]] },
374
+ 'w': { width: 22, points: [[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]] },
375
+ 'x': { width: 17, points: [[3,14],[14,0],[-1,-1],[14,14],[3,0]] },
376
+ 'y': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]] },
377
+ 'z': { width: 17, points: [[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]] },
378
+ '{': { width: 14, points: [[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]] },
379
+ '|': { width: 8, points: [[4,25],[4,-7]] },
380
+ '}': { width: 14, points: [[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]] },
381
+ '~': { width: 24, points: [[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]] }
382
+ };
383
+
384
+ $.jqplot.CanvasFontRenderer = function(options) {
385
+ options = options || {};
386
+ if (!options.pt2px) {
387
+ options.pt2px = 1.5;
388
+ }
389
+ $.jqplot.CanvasTextRenderer.call(this, options);
390
+ };
391
+
392
+ $.jqplot.CanvasFontRenderer.prototype = new $.jqplot.CanvasTextRenderer({});
393
+ $.jqplot.CanvasFontRenderer.prototype.constructor = $.jqplot.CanvasFontRenderer;
394
+
395
+ $.jqplot.CanvasFontRenderer.prototype.measure = function(ctx, str)
396
+ {
397
+ // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
398
+ var fstyle = this.fontSize+' '+this.fontFamily;
399
+ ctx.save();
400
+ ctx.font = fstyle;
401
+ var w = ctx.measureText(str).width;
402
+ ctx.restore();
403
+ return w;
404
+ };
405
+
406
+ $.jqplot.CanvasFontRenderer.prototype.draw = function(ctx, str)
407
+ {
408
+ var x = 0;
409
+ // leave room at bottom for descenders.
410
+ var y = this.height*0.72;
411
+ //var y = 12;
412
+
413
+ ctx.save();
414
+ var tx, ty;
415
+
416
+ // 1st quadrant
417
+ if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
418
+ tx = 0;
419
+ ty = -Math.sin(this.angle) * this.width;
420
+ }
421
+ // 4th quadrant
422
+ else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
423
+ tx = Math.sin(this.angle) * this.height;
424
+ ty = 0;
425
+ }
426
+ // 2nd quadrant
427
+ else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
428
+ tx = -Math.cos(this.angle) * this.width;
429
+ ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
430
+ }
431
+ // 3rd quadrant
432
+ else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
433
+ tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
434
+ ty = -Math.cos(this.angle) * this.height;
435
+ }
436
+ ctx.strokeStyle = this.fillStyle;
437
+ ctx.fillStyle = this.fillStyle;
438
+ // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
439
+ var fstyle = this.fontSize+' '+this.fontFamily;
440
+ ctx.font = fstyle;
441
+ ctx.translate(tx, ty);
442
+ ctx.rotate(this.angle);
443
+ ctx.fillText(str, x, y);
444
+ // ctx.strokeText(str, x, y);
445
+
446
+ ctx.restore();
447
+ };
448
+
449
+ })(jQuery);
@@ -0,0 +1,673 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.5
6
+ * Revision: 1122+
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ */
31
+ (function($) {
32
+ /**
33
+ * class: $.jqplot.CategoryAxisRenderer
34
+ * A plugin for jqPlot to render a category style axis, with equal pixel spacing between y data values of a series.
35
+ *
36
+ * To use this renderer, include the plugin in your source
37
+ * > <script type="text/javascript" language="javascript" src="plugins/jqplot.categoryAxisRenderer.js"></script>
38
+ *
39
+ * and supply the appropriate options to your plot
40
+ *
41
+ * > {axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer}}}
42
+ **/
43
+ $.jqplot.CategoryAxisRenderer = function(options) {
44
+ $.jqplot.LinearAxisRenderer.call(this);
45
+ // prop: sortMergedLabels
46
+ // True to sort tick labels when labels are created by merging
47
+ // x axis values from multiple series. That is, say you have
48
+ // two series like:
49
+ // > line1 = [[2006, 4], [2008, 9], [2009, 16]];
50
+ // > line2 = [[2006, 3], [2007, 7], [2008, 6]];
51
+ // If no label array is specified, tick labels will be collected
52
+ // from the x values of the series. With sortMergedLabels
53
+ // set to true, tick labels will be:
54
+ // > [2006, 2007, 2008, 2009]
55
+ // With sortMergedLabels set to false, tick labels will be:
56
+ // > [2006, 2008, 2009, 2007]
57
+ //
58
+ // Note, this property is specified on the renderOptions for the
59
+ // axes when creating a plot:
60
+ // > axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, rendererOptions:{sortMergedLabels:true}}}
61
+ this.sortMergedLabels = false;
62
+ };
63
+
64
+ $.jqplot.CategoryAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
65
+ $.jqplot.CategoryAxisRenderer.prototype.constructor = $.jqplot.CategoryAxisRenderer;
66
+
67
+ $.jqplot.CategoryAxisRenderer.prototype.init = function(options){
68
+ this.groups = 1;
69
+ this.groupLabels = [];
70
+ this._groupLabels = [];
71
+ this._grouped = false;
72
+ this._barsPerGroup = null;
73
+ this.reverse = false;
74
+ // prop: tickRenderer
75
+ // A class of a rendering engine for creating the ticks labels displayed on the plot,
76
+ // See <$.jqplot.AxisTickRenderer>.
77
+ // this.tickRenderer = $.jqplot.AxisTickRenderer;
78
+ // this.labelRenderer = $.jqplot.AxisLabelRenderer;
79
+ $.extend(true, this, {tickOptions:{formatString:'%d'}}, options);
80
+ var db = this._dataBounds;
81
+ // Go through all the series attached to this axis and find
82
+ // the min/max bounds for this axis.
83
+ for (var i=0; i<this._series.length; i++) {
84
+ var s = this._series[i];
85
+ if (s.groups) {
86
+ this.groups = s.groups;
87
+ }
88
+ var d = s.data;
89
+
90
+ for (var j=0; j<d.length; j++) {
91
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
92
+ if (d[j][0] < db.min || db.min == null) {
93
+ db.min = d[j][0];
94
+ }
95
+ if (d[j][0] > db.max || db.max == null) {
96
+ db.max = d[j][0];
97
+ }
98
+ }
99
+ else {
100
+ if (d[j][1] < db.min || db.min == null) {
101
+ db.min = d[j][1];
102
+ }
103
+ if (d[j][1] > db.max || db.max == null) {
104
+ db.max = d[j][1];
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ if (this.groupLabels.length) {
111
+ this.groups = this.groupLabels.length;
112
+ }
113
+ };
114
+
115
+
116
+ $.jqplot.CategoryAxisRenderer.prototype.createTicks = function() {
117
+ // we're are operating on an axis here
118
+ var ticks = this._ticks;
119
+ var userTicks = this.ticks;
120
+ var name = this.name;
121
+ // databounds were set on axis initialization.
122
+ var db = this._dataBounds;
123
+ var dim, interval;
124
+ var min, max;
125
+ var pos1, pos2;
126
+ var tt, i;
127
+
128
+ // if we already have ticks, use them.
129
+ if (userTicks.length) {
130
+ // adjust with blanks if we have groups
131
+ if (this.groups > 1 && !this._grouped) {
132
+ var l = userTicks.length;
133
+ var skip = parseInt(l/this.groups, 10);
134
+ var count = 0;
135
+ for (var i=skip; i<l; i+=skip) {
136
+ userTicks.splice(i+count, 0, ' ');
137
+ count++;
138
+ }
139
+ this._grouped = true;
140
+ }
141
+ this.min = 0.5;
142
+ this.max = userTicks.length + 0.5;
143
+ var range = this.max - this.min;
144
+ this.numberTicks = 2*userTicks.length + 1;
145
+ for (i=0; i<userTicks.length; i++){
146
+ tt = this.min + 2 * i * range / (this.numberTicks-1);
147
+ // need a marker before and after the tick
148
+ var t = new this.tickRenderer(this.tickOptions);
149
+ t.showLabel = false;
150
+ // t.showMark = true;
151
+ t.setTick(tt, this.name);
152
+ this._ticks.push(t);
153
+ var t = new this.tickRenderer(this.tickOptions);
154
+ t.label = userTicks[i];
155
+ // t.showLabel = true;
156
+ t.showMark = false;
157
+ t.showGridline = false;
158
+ t.setTick(tt+0.5, this.name);
159
+ this._ticks.push(t);
160
+ }
161
+ // now add the last tick at the end
162
+ var t = new this.tickRenderer(this.tickOptions);
163
+ t.showLabel = false;
164
+ // t.showMark = true;
165
+ t.setTick(tt+1, this.name);
166
+ this._ticks.push(t);
167
+ }
168
+
169
+ // we don't have any ticks yet, let's make some!
170
+ else {
171
+ if (name == 'xaxis' || name == 'x2axis') {
172
+ dim = this._plotDimensions.width;
173
+ }
174
+ else {
175
+ dim = this._plotDimensions.height;
176
+ }
177
+
178
+ // if min, max and number of ticks specified, user can't specify interval.
179
+ if (this.min != null && this.max != null && this.numberTicks != null) {
180
+ this.tickInterval = null;
181
+ }
182
+
183
+ // if max, min, and interval specified and interval won't fit, ignore interval.
184
+ if (this.min != null && this.max != null && this.tickInterval != null) {
185
+ if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) {
186
+ this.tickInterval = null;
187
+ }
188
+ }
189
+
190
+ // find out how many categories are in the lines and collect labels
191
+ var labels = [];
192
+ var numcats = 0;
193
+ var min = 0.5;
194
+ var max, val;
195
+ var isMerged = false;
196
+ for (var i=0; i<this._series.length; i++) {
197
+ var s = this._series[i];
198
+ for (var j=0; j<s.data.length; j++) {
199
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
200
+ val = s.data[j][0];
201
+ }
202
+ else {
203
+ val = s.data[j][1];
204
+ }
205
+ if ($.inArray(val, labels) == -1) {
206
+ isMerged = true;
207
+ numcats += 1;
208
+ labels.push(val);
209
+ }
210
+ }
211
+ }
212
+
213
+ if (isMerged && this.sortMergedLabels) {
214
+ labels.sort(function(a,b) { return a - b; });
215
+ }
216
+
217
+ // keep a reference to these tick labels to use for redrawing plot (see bug #57)
218
+ this.ticks = labels;
219
+
220
+ // now bin the data values to the right lables.
221
+ for (var i=0; i<this._series.length; i++) {
222
+ var s = this._series[i];
223
+ for (var j=0; j<s.data.length; j++) {
224
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
225
+ val = s.data[j][0];
226
+ }
227
+ else {
228
+ val = s.data[j][1];
229
+ }
230
+ // for category axis, force the values into category bins.
231
+ // we should have the value in the label array now.
232
+ var idx = $.inArray(val, labels)+1;
233
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
234
+ s.data[j][0] = idx;
235
+ }
236
+ else {
237
+ s.data[j][1] = idx;
238
+ }
239
+ }
240
+ }
241
+
242
+ // adjust with blanks if we have groups
243
+ if (this.groups > 1 && !this._grouped) {
244
+ var l = labels.length;
245
+ var skip = parseInt(l/this.groups, 10);
246
+ var count = 0;
247
+ for (var i=skip; i<l; i+=skip+1) {
248
+ labels[i] = ' ';
249
+ }
250
+ this._grouped = true;
251
+ }
252
+
253
+ max = numcats + 0.5;
254
+ if (this.numberTicks == null) {
255
+ this.numberTicks = 2*numcats + 1;
256
+ }
257
+
258
+ var range = max - min;
259
+ this.min = min;
260
+ this.max = max;
261
+ var track = 0;
262
+
263
+ // todo: adjust this so more ticks displayed.
264
+ var maxVisibleTicks = parseInt(3+dim/10, 10);
265
+ var skip = parseInt(numcats/maxVisibleTicks, 10);
266
+
267
+ if (this.tickInterval == null) {
268
+
269
+ this.tickInterval = range / (this.numberTicks-1);
270
+
271
+ }
272
+ // if tickInterval is specified, we will ignore any computed maximum.
273
+ for (var i=0; i<this.numberTicks; i++){
274
+ tt = this.min + i * this.tickInterval;
275
+ var t = new this.tickRenderer(this.tickOptions);
276
+ // if even tick, it isn't a category, it's a divider
277
+ if (i/2 == parseInt(i/2, 10)) {
278
+ t.showLabel = false;
279
+ t.showMark = true;
280
+ }
281
+ else {
282
+ if (skip>0 && track<skip) {
283
+ t.showLabel = false;
284
+ track += 1;
285
+ }
286
+ else {
287
+ t.showLabel = true;
288
+ track = 0;
289
+ }
290
+ t.label = t.formatter(t.formatString, labels[(i-1)/2]);
291
+ t.showMark = false;
292
+ t.showGridline = false;
293
+ }
294
+ t.setTick(tt, this.name);
295
+ this._ticks.push(t);
296
+ }
297
+ }
298
+
299
+ };
300
+
301
+ // called with scope of axis
302
+ $.jqplot.CategoryAxisRenderer.prototype.draw = function(ctx, plot) {
303
+ if (this.show) {
304
+ // populate the axis label and value properties.
305
+ // createTicks is a method on the renderer, but
306
+ // call it within the scope of the axis.
307
+ this.renderer.createTicks.call(this);
308
+ // fill a div with axes labels in the right direction.
309
+ // Need to pregenerate each axis to get it's bounds and
310
+ // position it and the labels correctly on the plot.
311
+ var dim=0;
312
+ var temp;
313
+ // Added for theming.
314
+ if (this._elem) {
315
+ // this._elem.empty();
316
+ // Memory Leaks patch
317
+ this._elem.emptyForce();
318
+ }
319
+
320
+ this._elem = this._elem || $('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');
321
+
322
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
323
+ this._elem.width(this._plotDimensions.width);
324
+ }
325
+ else {
326
+ this._elem.height(this._plotDimensions.height);
327
+ }
328
+
329
+ // create a _label object.
330
+ this.labelOptions.axis = this.name;
331
+ this._label = new this.labelRenderer(this.labelOptions);
332
+ if (this._label.show) {
333
+ var elem = this._label.draw(ctx, plot);
334
+ elem.appendTo(this._elem);
335
+ }
336
+
337
+ var t = this._ticks;
338
+ for (var i=0; i<t.length; i++) {
339
+ var tick = t[i];
340
+ if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
341
+ var elem = tick.draw(ctx, plot);
342
+ elem.appendTo(this._elem);
343
+ }
344
+ }
345
+
346
+ this._groupLabels = [];
347
+ // now make group labels
348
+ for (var i=0; i<this.groupLabels.length; i++)
349
+ {
350
+ var elem = $('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>');
351
+ elem.html(this.groupLabels[i]);
352
+ this._groupLabels.push(elem);
353
+ elem.appendTo(this._elem);
354
+ }
355
+ }
356
+ return this._elem;
357
+ };
358
+
359
+ // called with scope of axis
360
+ $.jqplot.CategoryAxisRenderer.prototype.set = function() {
361
+ var dim = 0;
362
+ var temp;
363
+ var w = 0;
364
+ var h = 0;
365
+ var lshow = (this._label == null) ? false : this._label.show;
366
+ if (this.show) {
367
+ var t = this._ticks;
368
+ for (var i=0; i<t.length; i++) {
369
+ var tick = t[i];
370
+ if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
371
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
372
+ temp = tick._elem.outerHeight(true);
373
+ }
374
+ else {
375
+ temp = tick._elem.outerWidth(true);
376
+ }
377
+ if (temp > dim) {
378
+ dim = temp;
379
+ }
380
+ }
381
+ }
382
+
383
+ var dim2 = 0;
384
+ for (var i=0; i<this._groupLabels.length; i++) {
385
+ var l = this._groupLabels[i];
386
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
387
+ temp = l.outerHeight(true);
388
+ }
389
+ else {
390
+ temp = l.outerWidth(true);
391
+ }
392
+ if (temp > dim2) {
393
+ dim2 = temp;
394
+ }
395
+ }
396
+
397
+ if (lshow) {
398
+ w = this._label._elem.outerWidth(true);
399
+ h = this._label._elem.outerHeight(true);
400
+ }
401
+ if (this.name == 'xaxis') {
402
+ dim += dim2 + h;
403
+ this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
404
+ }
405
+ else if (this.name == 'x2axis') {
406
+ dim += dim2 + h;
407
+ this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
408
+ }
409
+ else if (this.name == 'yaxis') {
410
+ dim += dim2 + w;
411
+ this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
412
+ if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
413
+ this._label._elem.css('width', w+'px');
414
+ }
415
+ }
416
+ else {
417
+ dim += dim2 + w;
418
+ this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
419
+ if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
420
+ this._label._elem.css('width', w+'px');
421
+ }
422
+ }
423
+ }
424
+ };
425
+
426
+ // called with scope of axis
427
+ $.jqplot.CategoryAxisRenderer.prototype.pack = function(pos, offsets) {
428
+ var ticks = this._ticks;
429
+ var max = this.max;
430
+ var min = this.min;
431
+ var offmax = offsets.max;
432
+ var offmin = offsets.min;
433
+ var lshow = (this._label == null) ? false : this._label.show;
434
+ var i;
435
+
436
+ for (var p in pos) {
437
+ this._elem.css(p, pos[p]);
438
+ }
439
+
440
+ this._offsets = offsets;
441
+ // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
442
+ var pixellength = offmax - offmin;
443
+ var unitlength = max - min;
444
+
445
+ if (!this.reverse) {
446
+ // point to unit and unit to point conversions references to Plot DOM element top left corner.
447
+
448
+ this.u2p = function(u){
449
+ return (u - min) * pixellength / unitlength + offmin;
450
+ };
451
+
452
+ this.p2u = function(p){
453
+ return (p - offmin) * unitlength / pixellength + min;
454
+ };
455
+
456
+ if (this.name == 'xaxis' || this.name == 'x2axis'){
457
+ this.series_u2p = function(u){
458
+ return (u - min) * pixellength / unitlength;
459
+ };
460
+ this.series_p2u = function(p){
461
+ return p * unitlength / pixellength + min;
462
+ };
463
+ }
464
+
465
+ else {
466
+ this.series_u2p = function(u){
467
+ return (u - max) * pixellength / unitlength;
468
+ };
469
+ this.series_p2u = function(p){
470
+ return p * unitlength / pixellength + max;
471
+ };
472
+ }
473
+ }
474
+
475
+ else {
476
+ // point to unit and unit to point conversions references to Plot DOM element top left corner.
477
+
478
+ this.u2p = function(u){
479
+ return offmin + (max - u) * pixellength / unitlength;
480
+ };
481
+
482
+ this.p2u = function(p){
483
+ return min + (p - offmin) * unitlength / pixellength;
484
+ };
485
+
486
+ if (this.name == 'xaxis' || this.name == 'x2axis'){
487
+ this.series_u2p = function(u){
488
+ return (max - u) * pixellength / unitlength;
489
+ };
490
+ this.series_p2u = function(p){
491
+ return p * unitlength / pixellength + max;
492
+ };
493
+ }
494
+
495
+ else {
496
+ this.series_u2p = function(u){
497
+ return (min - u) * pixellength / unitlength;
498
+ };
499
+ this.series_p2u = function(p){
500
+ return p * unitlength / pixellength + min;
501
+ };
502
+ }
503
+
504
+ }
505
+
506
+
507
+ if (this.show) {
508
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
509
+ for (i=0; i<ticks.length; i++) {
510
+ var t = ticks[i];
511
+ if (t.show && t.showLabel) {
512
+ var shim;
513
+
514
+ if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
515
+ // will need to adjust auto positioning based on which axis this is.
516
+ var temp = (this.name == 'xaxis') ? 1 : -1;
517
+ switch (t.labelPosition) {
518
+ case 'auto':
519
+ // position at end
520
+ if (temp * t.angle < 0) {
521
+ shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
522
+ }
523
+ // position at start
524
+ else {
525
+ shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
526
+ }
527
+ break;
528
+ case 'end':
529
+ shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
530
+ break;
531
+ case 'start':
532
+ shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
533
+ break;
534
+ case 'middle':
535
+ shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
536
+ break;
537
+ default:
538
+ shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
539
+ break;
540
+ }
541
+ }
542
+ else {
543
+ shim = -t.getWidth()/2;
544
+ }
545
+ var val = this.u2p(t.value) + shim + 'px';
546
+ t._elem.css('left', val);
547
+ t.pack();
548
+ }
549
+ }
550
+
551
+ var labeledge=['bottom', 0];
552
+ if (lshow) {
553
+ var w = this._label._elem.outerWidth(true);
554
+ this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
555
+ if (this.name == 'xaxis') {
556
+ this._label._elem.css('bottom', '0px');
557
+ labeledge = ['bottom', this._label._elem.outerHeight(true)];
558
+ }
559
+ else {
560
+ this._label._elem.css('top', '0px');
561
+ labeledge = ['top', this._label._elem.outerHeight(true)];
562
+ }
563
+ this._label.pack();
564
+ }
565
+
566
+ // draw the group labels
567
+ var step = parseInt(this._ticks.length/this.groups, 10);
568
+ for (i=0; i<this._groupLabels.length; i++) {
569
+ var mid = 0;
570
+ var count = 0;
571
+ for (var j=i*step; j<=(i+1)*step; j++) {
572
+ if (this._ticks[j]._elem && this._ticks[j].label != " ") {
573
+ var t = this._ticks[j]._elem;
574
+ var p = t.position();
575
+ mid += p.left + t.outerWidth(true)/2;
576
+ count++;
577
+ }
578
+ }
579
+ mid = mid/count;
580
+ this._groupLabels[i].css({'left':(mid - this._groupLabels[i].outerWidth(true)/2)});
581
+ this._groupLabels[i].css(labeledge[0], labeledge[1]);
582
+ }
583
+ }
584
+ else {
585
+ for (i=0; i<ticks.length; i++) {
586
+ var t = ticks[i];
587
+ if (t.show && t.showLabel) {
588
+ var shim;
589
+ if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
590
+ // will need to adjust auto positioning based on which axis this is.
591
+ var temp = (this.name == 'yaxis') ? 1 : -1;
592
+ switch (t.labelPosition) {
593
+ case 'auto':
594
+ // position at end
595
+ case 'end':
596
+ if (temp * t.angle < 0) {
597
+ shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
598
+ }
599
+ else {
600
+ shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
601
+ }
602
+ break;
603
+ case 'start':
604
+ if (t.angle > 0) {
605
+ shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
606
+ }
607
+ else {
608
+ shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
609
+ }
610
+ break;
611
+ case 'middle':
612
+ // if (t.angle > 0) {
613
+ // shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
614
+ // }
615
+ // else {
616
+ // shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
617
+ // }
618
+ shim = -t.getHeight()/2;
619
+ break;
620
+ default:
621
+ shim = -t.getHeight()/2;
622
+ break;
623
+ }
624
+ }
625
+ else {
626
+ shim = -t.getHeight()/2;
627
+ }
628
+
629
+ var val = this.u2p(t.value) + shim + 'px';
630
+ t._elem.css('top', val);
631
+ t.pack();
632
+ }
633
+ }
634
+
635
+ var labeledge=['left', 0];
636
+ if (lshow) {
637
+ var h = this._label._elem.outerHeight(true);
638
+ this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
639
+ if (this.name == 'yaxis') {
640
+ this._label._elem.css('left', '0px');
641
+ labeledge = ['left', this._label._elem.outerWidth(true)];
642
+ }
643
+ else {
644
+ this._label._elem.css('right', '0px');
645
+ labeledge = ['right', this._label._elem.outerWidth(true)];
646
+ }
647
+ this._label.pack();
648
+ }
649
+
650
+ // draw the group labels, position top here, do left after label position.
651
+ var step = parseInt(this._ticks.length/this.groups, 10);
652
+ for (i=0; i<this._groupLabels.length; i++) {
653
+ var mid = 0;
654
+ var count = 0;
655
+ for (var j=i*step; j<=(i+1)*step; j++) {
656
+ if (this._ticks[j]._elem && this._ticks[j].label != " ") {
657
+ var t = this._ticks[j]._elem;
658
+ var p = t.position();
659
+ mid += p.top + t.outerHeight()/2;
660
+ count++;
661
+ }
662
+ }
663
+ mid = mid/count;
664
+ this._groupLabels[i].css({'top':mid - this._groupLabels[i].outerHeight()/2});
665
+ this._groupLabels[i].css(labeledge[0], labeledge[1]);
666
+
667
+ }
668
+ }
669
+ }
670
+ };
671
+
672
+
673
+ })(jQuery);