rhosync 2.0.9 → 2.1.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/CHANGELOG +9 -0
  2. data/Rakefile +1 -1
  3. data/bench/benchapp/sources/mock_adapter.rb +2 -2
  4. data/bench/benchapp/tmp/restart.txt +0 -0
  5. data/bench/spec/mock_adapter_spec.rb +1 -1
  6. data/lib/rhosync/api/stats.rb +21 -0
  7. data/lib/rhosync/bulk_data/bulk_data.rb +1 -1
  8. data/lib/rhosync/client.rb +10 -0
  9. data/lib/rhosync/console/app/public/home.css +9 -4
  10. data/lib/rhosync/console/app/public/images/foot_logo_rhosync.png +0 -0
  11. data/lib/rhosync/console/app/public/images/landing_header.jpg +0 -0
  12. data/lib/rhosync/console/app/public/jqplot/excanvas.min.js +35 -0
  13. data/lib/rhosync/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
  14. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
  15. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
  16. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
  17. data/lib/rhosync/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
  18. data/lib/rhosync/console/app/public/jqplot/jqplot.cursor.js +952 -0
  19. data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
  20. data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
  21. data/lib/rhosync/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
  22. data/lib/rhosync/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
  23. data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
  24. data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
  25. data/lib/rhosync/console/app/routes/timing.rb +223 -7
  26. data/lib/rhosync/console/app/views/content.erb +1 -1
  27. data/lib/rhosync/console/app/views/headermenu.erb +4 -4
  28. data/lib/rhosync/console/app/views/jqplot.erb +52 -0
  29. data/lib/rhosync/console/app/views/layout.erb +86 -11
  30. data/lib/rhosync/console/rhosync_api.rb +19 -0
  31. data/lib/rhosync/jobs/bulk_data_job.rb +2 -2
  32. data/lib/rhosync/stats/middleware.rb +4 -6
  33. data/lib/rhosync/stats/record.rb +51 -26
  34. data/lib/rhosync/store.rb +12 -1
  35. data/lib/rhosync/tasks.rb +4 -2
  36. data/lib/rhosync/user.rb +11 -1
  37. data/lib/rhosync/version.rb +2 -2
  38. data/lib/rhosync.rb +3 -3
  39. data/spec/api/rhosync_api_spec.rb +26 -0
  40. data/spec/api/stats_spec.rb +66 -0
  41. data/spec/client_spec.rb +40 -0
  42. data/spec/client_sync_spec.rb +14 -0
  43. data/spec/stats/middleware_spec.rb +11 -5
  44. data/spec/stats/record_spec.rb +30 -11
  45. data/spec/store_spec.rb +15 -1
  46. data/spec/user_spec.rb +44 -0
  47. metadata +32 -14
  48. data/doc/protocol.html +0 -2291
  49. data/doc/public/css/print.css +0 -29
  50. data/doc/public/css/screen.css +0 -257
  51. data/doc/public/css/style.css +0 -20
  52. data/lib/rhosync/console/app/public/images/header_halo copy.jpg +0 -0
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Copyright (c) 2009 - 2010 Chris Leonello
3
+ * jqPlot is currently available for use in all personal or commercial projects
4
+ * under both the MIT and GPL version 2.0 licenses. This means that you can
5
+ * choose the license that best suits your project and use it accordingly.
6
+ *
7
+ * The author would appreciate an email letting him know of any substantial
8
+ * use of jqPlot. You can reach the author at: chris at jqplot dot com
9
+ * or see http://www.jqplot.com/info.php . This is, of course,
10
+ * not required.
11
+ *
12
+ * If you are feeling kind and generous, consider supporting the project by
13
+ * making a donation at: http://www.jqplot.com/donate.php .
14
+ *
15
+ * Thanks for using jqPlot!
16
+ *
17
+ */
18
+ (function($) {
19
+ /**
20
+ * Class: $.jqplot.CanvasAxisTickRenderer
21
+ * Renderer to draw axis ticks with a canvas element to support advanced
22
+ * featrues such as rotated text. This renderer uses a separate rendering engine
23
+ * to draw the text on the canvas. Two modes of rendering the text are available.
24
+ * If the browser has native font support for canvas fonts (currently Mozila 3.5
25
+ * and Safari 4), you can enable text rendering with the canvas fillText method.
26
+ * You do so by setting the "enableFontSupport" option to true.
27
+ *
28
+ * Browsers lacking native font support will have the text drawn on the canvas
29
+ * using the Hershey font metrics. Even if the "enableFontSupport" option is true
30
+ * non-supporting browsers will still render with the Hershey font.
31
+ */
32
+ $.jqplot.CanvasAxisTickRenderer = function(options) {
33
+ // Group: Properties
34
+
35
+ // prop: mark
36
+ // tick mark on the axis. One of 'inside', 'outside', 'cross', '' or null.
37
+ this.mark = 'outside';
38
+ // prop: showMark
39
+ // wether or not to show the mark on the axis.
40
+ this.showMark = true;
41
+ // prop: showGridline
42
+ // wether or not to draw the gridline on the grid at this tick.
43
+ this.showGridline = true;
44
+ // prop: isMinorTick
45
+ // if this is a minor tick.
46
+ this.isMinorTick = false;
47
+ // prop: angle
48
+ // angle of text, measured clockwise from x axis.
49
+ this.angle = 0;
50
+ // prop: markSize
51
+ // Length of the tick marks in pixels. For 'cross' style, length
52
+ // will be stoked above and below axis, so total length will be twice this.
53
+ this.markSize = 4;
54
+ // prop: show
55
+ // wether or not to show the tick (mark and label).
56
+ this.show = true;
57
+ // prop: showLabel
58
+ // wether or not to show the label.
59
+ this.showLabel = true;
60
+ // prop: labelPosition
61
+ // 'auto', 'start', 'middle' or 'end'.
62
+ // Whether tick label should be positioned so the start, middle, or end
63
+ // of the tick mark.
64
+ this.labelPosition = 'auto';
65
+ this.label = '';
66
+ this.value = null;
67
+ this._styles = {};
68
+ // prop: formatter
69
+ // A class of a formatter for the tick text.
70
+ // The default $.jqplot.DefaultTickFormatter uses sprintf.
71
+ this.formatter = $.jqplot.DefaultTickFormatter;
72
+ // prop: formatString
73
+ // string passed to the formatter.
74
+ this.formatString = '';
75
+ // prop: prefix
76
+ // string appended to the tick label if no formatString is specified.
77
+ this.prefix = '';
78
+ // prop: fontFamily
79
+ // css spec for the font-family css attribute.
80
+ this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
81
+ // prop: fontSize
82
+ // CSS spec for font size.
83
+ this.fontSize = '10pt';
84
+ // prop: fontWeight
85
+ // CSS spec for fontWeight
86
+ this.fontWeight = 'normal';
87
+ // prop: fontStretch
88
+ // Multiplier to condense or expand font width.
89
+ // Applies only to browsers which don't support canvas native font rendering.
90
+ this.fontStretch = 1.0;
91
+ // prop: textColor
92
+ // css spec for the color attribute.
93
+ this.textColor = '#666666';
94
+ // prop: enableFontSupport
95
+ // true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
96
+ // If true, tick label will be drawn with canvas tag native support for fonts.
97
+ // If false, tick label will be drawn with Hershey font metrics.
98
+ this.enableFontSupport = true;
99
+ // prop: pt2px
100
+ // Point to pixel scaling factor, used for computing height of bounding box
101
+ // around a label. The labels text renderer has a default setting of 1.4, which
102
+ // should be suitable for most fonts. Leave as null to use default. If tops of
103
+ // letters appear clipped, increase this. If bounding box seems too big, decrease.
104
+ // This is an issue only with the native font renderering capabilities of Mozilla
105
+ // 3.5 and Safari 4 since they do not provide a method to determine the font height.
106
+ this.pt2px = null;
107
+
108
+ this._elem;
109
+ this._ctx;
110
+ this._plotWidth;
111
+ this._plotHeight;
112
+ this._plotDimensions = {height:null, width:null};
113
+
114
+ $.extend(true, this, options);
115
+
116
+ var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
117
+ if (this.pt2px) {
118
+ ropts.pt2px = this.pt2px;
119
+ }
120
+
121
+ if (this.enableFontSupport) {
122
+
123
+ function support_canvas_text() {
124
+ return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
125
+ }
126
+
127
+ if (support_canvas_text()) {
128
+ this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
129
+ }
130
+
131
+ else {
132
+ this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
133
+ }
134
+ }
135
+ else {
136
+ this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
137
+ }
138
+ };
139
+
140
+ $.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
141
+ $.extend(true, this, options);
142
+ this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
143
+ };
144
+
145
+ // return width along the x axis
146
+ // will check first to see if an element exists.
147
+ // if not, will return the computed text box width.
148
+ $.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
149
+ if (this._elem) {
150
+ return this._elem.outerWidth(true);
151
+ }
152
+ else {
153
+ var tr = this._textRenderer;
154
+ var l = tr.getWidth(ctx);
155
+ var h = tr.getHeight(ctx);
156
+ var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
157
+ return w;
158
+ }
159
+ };
160
+
161
+ // return height along the y axis.
162
+ $.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
163
+ if (this._elem) {
164
+ return this._elem.outerHeight(true);
165
+ }
166
+ else {
167
+ var tr = this._textRenderer;
168
+ var l = tr.getWidth(ctx);
169
+ var h = tr.getHeight(ctx);
170
+ var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
171
+ return w;
172
+ }
173
+ };
174
+
175
+ $.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
176
+ var a = this.angle * Math.PI/180;
177
+ return a;
178
+ };
179
+
180
+
181
+ $.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
182
+ this.value = value;
183
+ if (isMinor) {
184
+ this.isMinorTick = true;
185
+ }
186
+ return this;
187
+ };
188
+
189
+ $.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx) {
190
+ if (!this.label) {
191
+ this.label = this.formatter(this.formatString, this.value);
192
+ }
193
+ // add prefix if needed
194
+ if (this.prefix && !this.formatString) {
195
+ this.label = this.prefix + this.label;
196
+ }
197
+ // create a canvas here, but can't draw on it untill it is appended
198
+ // to dom for IE compatability.
199
+ var domelem = document.createElement('canvas');
200
+ this._textRenderer.setText(this.label, ctx);
201
+ var w = this.getWidth(ctx);
202
+ var h = this.getHeight(ctx);
203
+ domelem.width = w;
204
+ domelem.height = h;
205
+ domelem.style.width = w;
206
+ domelem.style.height = h;
207
+ domelem.style.textAlign = 'left';
208
+ domelem.style.position = 'absolute';
209
+ this._domelem = domelem;
210
+ this._elem = $(domelem);
211
+ this._elem.css(this._styles);
212
+ this._elem.addClass('jqplot-'+this.axis+'-tick');
213
+
214
+ return this._elem;
215
+ };
216
+
217
+ $.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
218
+ if ($.browser.msie) {
219
+ window.G_vmlCanvasManager.init_(document);
220
+ this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
221
+ }
222
+ var ctx = this._elem.get(0).getContext("2d");
223
+ this._textRenderer.draw(ctx, this.label);
224
+ };
225
+
226
+ })(jQuery);
@@ -0,0 +1,408 @@
1
+ /**
2
+ * Copyright (c) 2009 - 2010 Chris Leonello
3
+ * jqPlot is currently available for use in all personal or commercial projects
4
+ * under both the MIT and GPL version 2.0 licenses. This means that you can
5
+ * choose the license that best suits your project and use it accordingly.
6
+ *
7
+ * The author would appreciate an email letting him know of any substantial
8
+ * use of jqPlot. You can reach the author at: chris at jqplot dot com
9
+ * or see http://www.jqplot.com/info.php . This is, of course,
10
+ * not required.
11
+ *
12
+ * If you are feeling kind and generous, consider supporting the project by
13
+ * making a donation at: http://www.jqplot.com/donate.php .
14
+ *
15
+ * Thanks for using jqPlot!
16
+ *
17
+ */
18
+ (function($) {
19
+ // This code is a modified version of the canvastext.js code, copyright below:
20
+ //
21
+ // This code is released to the public domain by Jim Studt, 2007.
22
+ // He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/
23
+ //
24
+ $.jqplot.CanvasTextRenderer = function(options){
25
+ this.fontStyle = 'normal'; // normal, italic, oblique [not implemented]
26
+ this.fontVariant = 'normal'; // normal, small caps [not implemented]
27
+ this.fontWeight = 'normal'; // normal, bold, bolder, lighter, 100 - 900
28
+ this.fontSize = '10px';
29
+ this.fontFamily = 'sans-serif';
30
+ this.fontStretch = 1.0;
31
+ this.fillStyle = '#666666';
32
+ this.angle = 0;
33
+ this.textAlign = 'start';
34
+ this.textBaseline = 'alphabetic';
35
+ this.text;
36
+ this.width;
37
+ this.height;
38
+ this.pt2px = 1.28;
39
+
40
+ $.extend(true, this, options);
41
+ this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
42
+ this.setHeight();
43
+ };
44
+
45
+ $.jqplot.CanvasTextRenderer.prototype.init = function(options) {
46
+ $.extend(true, this, options);
47
+ this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
48
+ this.setHeight();
49
+ };
50
+
51
+ // convert css spec into point size
52
+ // returns float
53
+ $.jqplot.CanvasTextRenderer.prototype.normalizeFontSize = function(sz) {
54
+ sz = String(sz);
55
+ n = parseFloat(sz);
56
+ if (sz.indexOf('px') > -1) {
57
+ return n/this.pt2px;
58
+ }
59
+ else if (sz.indexOf('pt') > -1) {
60
+ return n;
61
+ }
62
+ else if (sz.indexOf('em') > -1) {
63
+ return n*12;
64
+ }
65
+ else if (sz.indexOf('%') > -1) {
66
+ return n*12/100;
67
+ }
68
+ // default to pixels;
69
+ else {
70
+ return n/this.pt2px;
71
+ }
72
+ };
73
+
74
+
75
+ $.jqplot.CanvasTextRenderer.prototype.fontWeight2Float = function(w) {
76
+ // w = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
77
+ // return values adjusted for Hershey font.
78
+ if (Number(w)) {
79
+ return w/400;
80
+ }
81
+ else {
82
+ switch (w) {
83
+ case 'normal':
84
+ return 1;
85
+ break;
86
+ case 'bold':
87
+ return 1.75;
88
+ break;
89
+ case 'bolder':
90
+ return 2.25;
91
+ break;
92
+ case 'lighter':
93
+ return 0.75;
94
+ break;
95
+ default:
96
+ return 1;
97
+ break;
98
+ }
99
+ }
100
+ };
101
+
102
+ $.jqplot.CanvasTextRenderer.prototype.getText = function() {
103
+ return this.text;
104
+ };
105
+
106
+ $.jqplot.CanvasTextRenderer.prototype.setText = function(t, ctx) {
107
+ this.text = t;
108
+ this.setWidth(ctx);
109
+ return this;
110
+ };
111
+
112
+ $.jqplot.CanvasTextRenderer.prototype.getWidth = function(ctx) {
113
+ return this.width;
114
+ };
115
+
116
+ $.jqplot.CanvasTextRenderer.prototype.setWidth = function(ctx, w) {
117
+ if (!w) {
118
+ this.width = this.measure(ctx, this.text);
119
+ }
120
+ else {
121
+ this.width = w;
122
+ }
123
+ return this;
124
+ };
125
+
126
+ // return height in pixels.
127
+ $.jqplot.CanvasTextRenderer.prototype.getHeight = function(ctx) {
128
+ return this.height;
129
+ };
130
+
131
+ // w - height in pt
132
+ // set heigh in px
133
+ $.jqplot.CanvasTextRenderer.prototype.setHeight = function(w) {
134
+ if (!w) {
135
+ //height = this.fontSize /0.75;
136
+ this.height = this.normalizedFontSize * this.pt2px;
137
+ }
138
+ else {
139
+ this.height = w;
140
+ }
141
+ return this;
142
+ };
143
+
144
+ $.jqplot.CanvasTextRenderer.prototype.letter = function (ch)
145
+ {
146
+ return this.letters[ch];
147
+ };
148
+
149
+ $.jqplot.CanvasTextRenderer.prototype.ascent = function()
150
+ {
151
+ return this.normalizedFontSize;
152
+ };
153
+
154
+ $.jqplot.CanvasTextRenderer.prototype.descent = function()
155
+ {
156
+ return 7.0*this.normalizedFontSize/25.0;
157
+ };
158
+
159
+ $.jqplot.CanvasTextRenderer.prototype.measure = function(ctx, str)
160
+ {
161
+ var total = 0;
162
+ var len = str.length;
163
+
164
+ for ( i = 0; i < len; i++) {
165
+ var c = this.letter(str.charAt(i));
166
+ if (c) {
167
+ total += c.width * this.normalizedFontSize / 25.0 * this.fontStretch;
168
+ }
169
+ }
170
+ return total;
171
+ };
172
+
173
+ $.jqplot.CanvasTextRenderer.prototype.draw = function(ctx,str)
174
+ {
175
+ var x = 0;
176
+ // leave room at bottom for descenders.
177
+ var y = this.height*0.72;
178
+ var total = 0;
179
+ var len = str.length;
180
+ var mag = this.normalizedFontSize / 25.0;
181
+
182
+ ctx.save();
183
+ var tx, ty;
184
+
185
+ // 1st quadrant
186
+ if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
187
+ tx = 0;
188
+ ty = -Math.sin(this.angle) * this.width;
189
+ }
190
+ // 4th quadrant
191
+ else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
192
+ tx = Math.sin(this.angle) * this.height;
193
+ ty = 0;
194
+ }
195
+ // 2nd quadrant
196
+ else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
197
+ tx = -Math.cos(this.angle) * this.width;
198
+ ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
199
+ }
200
+ // 3rd quadrant
201
+ else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
202
+ tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
203
+ ty = -Math.cos(this.angle) * this.height;
204
+ }
205
+
206
+ ctx.strokeStyle = this.fillStyle;
207
+ ctx.fillStyle = this.fillStyle;
208
+ ctx.translate(tx, ty);
209
+ ctx.rotate(this.angle);
210
+ ctx.lineCap = "round";
211
+ // multiplier was 2.0
212
+ var fact = (this.normalizedFontSize > 30) ? 2.0 : 2 + (30 - this.normalizedFontSize)/20;
213
+ ctx.lineWidth = fact * mag * this.fontWeight2Float(this.fontWeight);
214
+
215
+ for ( var i = 0; i < len; i++) {
216
+ var c = this.letter( str.charAt(i));
217
+ if ( !c) {
218
+ continue;
219
+ }
220
+
221
+ ctx.beginPath();
222
+
223
+ var penUp = 1;
224
+ var needStroke = 0;
225
+ for ( var j = 0; j < c.points.length; j++) {
226
+ var a = c.points[j];
227
+ if ( a[0] == -1 && a[1] == -1) {
228
+ penUp = 1;
229
+ continue;
230
+ }
231
+ if ( penUp) {
232
+ ctx.moveTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
233
+ penUp = false;
234
+ } else {
235
+ ctx.lineTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
236
+ }
237
+ }
238
+ ctx.stroke();
239
+ x += c.width*mag*this.fontStretch;
240
+ }
241
+ ctx.restore();
242
+ return total;
243
+ };
244
+
245
+ $.jqplot.CanvasTextRenderer.prototype.letters = {
246
+ ' ': { width: 16, points: [] },
247
+ '!': { width: 10, points: [[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
248
+ '"': { width: 16, points: [[4,21],[4,14],[-1,-1],[12,21],[12,14]] },
249
+ '#': { 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]] },
250
+ '$': { 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]] },
251
+ '%': { 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]] },
252
+ '&': { 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]] },
253
+ '\'': { width: 10, points: [[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]] },
254
+ '(': { width: 14, points: [[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]] },
255
+ ')': { width: 14, points: [[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]] },
256
+ '*': { width: 16, points: [[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]] },
257
+ '+': { width: 26, points: [[13,18],[13,0],[-1,-1],[4,9],[22,9]] },
258
+ ',': { width: 10, points: [[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
259
+ '-': { width: 18, points: [[6,9],[12,9]] },
260
+ '.': { width: 10, points: [[5,2],[4,1],[5,0],[6,1],[5,2]] },
261
+ '/': { width: 22, points: [[20,25],[2,-7]] },
262
+ '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]] },
263
+ '1': { width: 20, points: [[6,17],[8,18],[11,21],[11,0]] },
264
+ '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]] },
265
+ '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]] },
266
+ '4': { width: 20, points: [[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]] },
267
+ '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]] },
268
+ '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]] },
269
+ '7': { width: 20, points: [[17,21],[7,0],[-1,-1],[3,21],[17,21]] },
270
+ '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]] },
271
+ '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]] },
272
+ ':': { 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]] },
273
+ ';': { 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]] },
274
+ '<': { width: 24, points: [[20,18],[4,9],[20,0]] },
275
+ '=': { width: 26, points: [[4,12],[22,12],[-1,-1],[4,6],[22,6]] },
276
+ '>': { width: 24, points: [[4,18],[20,9],[4,0]] },
277
+ '?': { 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]] },
278
+ '@': { 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]] },
279
+ 'A': { width: 18, points: [[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]] },
280
+ '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]] },
281
+ '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]] },
282
+ '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]] },
283
+ '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]] },
284
+ 'F': { width: 18, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]] },
285
+ '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]] },
286
+ 'H': { width: 22, points: [[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]] },
287
+ 'I': { width: 8, points: [[4,21],[4,0]] },
288
+ 'J': { width: 16, points: [[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]] },
289
+ 'K': { width: 21, points: [[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]] },
290
+ 'L': { width: 17, points: [[4,21],[4,0],[-1,-1],[4,0],[16,0]] },
291
+ '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]] },
292
+ 'N': { width: 22, points: [[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]] },
293
+ '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]] },
294
+ '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]] },
295
+ '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]] },
296
+ '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]] },
297
+ '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]] },
298
+ 'T': { width: 16, points: [[8,21],[8,0],[-1,-1],[1,21],[15,21]] },
299
+ 'U': { width: 22, points: [[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]] },
300
+ 'V': { width: 18, points: [[1,21],[9,0],[-1,-1],[17,21],[9,0]] },
301
+ '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]] },
302
+ 'X': { width: 20, points: [[3,21],[17,0],[-1,-1],[17,21],[3,0]] },
303
+ 'Y': { width: 18, points: [[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]] },
304
+ 'Z': { width: 20, points: [[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]] },
305
+ '[': { 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]] },
306
+ '\\': { width: 14, points: [[0,21],[14,-3]] },
307
+ ']': { 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]] },
308
+ '^': { width: 16, points: [[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]] },
309
+ '_': { width: 16, points: [[0,-2],[16,-2]] },
310
+ '`': { width: 10, points: [[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]] },
311
+ '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]] },
312
+ '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]] },
313
+ '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]] },
314
+ '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]] },
315
+ '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]] },
316
+ 'f': { width: 12, points: [[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]] },
317
+ '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]] },
318
+ 'h': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
319
+ 'i': { width: 8, points: [[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]] },
320
+ '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]] },
321
+ 'k': { width: 17, points: [[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]] },
322
+ 'l': { width: 8, points: [[4,21],[4,0]] },
323
+ '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]] },
324
+ 'n': { width: 19, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
325
+ '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]] },
326
+ '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]] },
327
+ '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]] },
328
+ 'r': { width: 13, points: [[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]] },
329
+ '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]] },
330
+ 't': { width: 12, points: [[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]] },
331
+ 'u': { width: 19, points: [[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]] },
332
+ 'v': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0]] },
333
+ '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]] },
334
+ 'x': { width: 17, points: [[3,14],[14,0],[-1,-1],[14,14],[3,0]] },
335
+ 'y': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]] },
336
+ 'z': { width: 17, points: [[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]] },
337
+ '{': { 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]] },
338
+ '|': { width: 8, points: [[4,25],[4,-7]] },
339
+ '}': { 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]] },
340
+ '~': { 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]] }
341
+ };
342
+
343
+ $.jqplot.CanvasFontRenderer = function(options) {
344
+ options = options || {};
345
+ if (!options.pt2px) {
346
+ options.pt2px = 1.5;
347
+ }
348
+ $.jqplot.CanvasTextRenderer.call(this, options);
349
+ };
350
+
351
+ $.jqplot.CanvasFontRenderer.prototype = new $.jqplot.CanvasTextRenderer({});
352
+ $.jqplot.CanvasFontRenderer.prototype.constructor = $.jqplot.CanvasFontRenderer;
353
+
354
+ $.jqplot.CanvasFontRenderer.prototype.measure = function(ctx, str)
355
+ {
356
+ // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
357
+ var fstyle = this.fontSize+' '+this.fontFamily;
358
+ ctx.save();
359
+ ctx.font = fstyle;
360
+ var w = ctx.measureText(str).width;
361
+ ctx.restore();
362
+ return w;
363
+ };
364
+
365
+ $.jqplot.CanvasFontRenderer.prototype.draw = function(ctx, str)
366
+ {
367
+ var x = 0;
368
+ // leave room at bottom for descenders.
369
+ var y = this.height*0.72;
370
+ //var y = 12;
371
+
372
+ ctx.save();
373
+ var tx, ty;
374
+
375
+ // 1st quadrant
376
+ if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
377
+ tx = 0;
378
+ ty = -Math.sin(this.angle) * this.width;
379
+ }
380
+ // 4th quadrant
381
+ else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
382
+ tx = Math.sin(this.angle) * this.height;
383
+ ty = 0;
384
+ }
385
+ // 2nd quadrant
386
+ else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
387
+ tx = -Math.cos(this.angle) * this.width;
388
+ ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
389
+ }
390
+ // 3rd quadrant
391
+ else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
392
+ tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
393
+ ty = -Math.cos(this.angle) * this.height;
394
+ }
395
+ ctx.strokeStyle = this.fillStyle;
396
+ ctx.fillStyle = this.fillStyle;
397
+ // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
398
+ var fstyle = this.fontSize+' '+this.fontFamily;
399
+ ctx.font = fstyle;
400
+ ctx.translate(tx, ty);
401
+ ctx.rotate(this.angle);
402
+ ctx.fillText(str, x, y);
403
+ // ctx.strokeText(str, x, y);
404
+
405
+ ctx.restore();
406
+ };
407
+
408
+ })(jQuery);