acts_as_dashboard 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +54 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/acts_as_dashboard.gemspec +166 -0
- data/generators/dashboard/USAGE +23 -0
- data/generators/dashboard/dashboard_generator.rb +105 -0
- data/generators/dashboard/templates/controller.erb +39 -0
- data/generators/dashboard/templates/dashboard.css +66 -0
- data/generators/dashboard/templates/dashboard.js +305 -0
- data/generators/dashboard/templates/jqplot-0.9.7/jquery.jqplot.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.barRenderer.js +404 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.barRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisLabelRenderer.js +200 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisLabelRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisTickRenderer.js +232 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisTickRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasTextRenderer.js +408 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasTextRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.categoryAxisRenderer.js +238 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.categoryAxisRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.cursor.js +812 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.cursor.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dateAxisRenderer.js +313 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dateAxisRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dragable.js +203 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dragable.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.highlighter.js +359 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.highlighter.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.logAxisRenderer.js +434 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.logAxisRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoAxisRenderer.js +595 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoAxisRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoRenderer.js +308 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.ohlcRenderer.js +343 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.ohlcRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pieRenderer.js +333 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pieRenderer.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.js +307 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.js.orig +273 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.min.js +14 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.trendline.js +208 -0
- data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.trendline.min.js +14 -0
- data/generators/dashboard/templates/jquery.jqplot.min.css +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/CHANGELOG +269 -0
- data/generators/dashboard/templates/js.class-2.1.4/MIT-LICENSE +30 -0
- data/generators/dashboard/templates/js.class-2.1.4/README +30 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/command.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/comparable.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/constant_scope.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/core.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/decorator.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/enumerable.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/forwardable.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/hash.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/linked_list.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/loader.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/method_chain.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/observable.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/package.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/proxy.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/ruby.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/set.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/stack_trace.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/state.js +1 -0
- data/generators/dashboard/templates/js.class-2.1.4/min/stdlib.js +16 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/command.js +93 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/comparable.js +37 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/constant_scope.js +48 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/core.js +1060 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/decorator.js +50 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/enumerable.js +505 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/forwardable.js +22 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/hash.js +334 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/linked_list.js +114 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/loader.js +458 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/method_chain.js +172 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/observable.js +55 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/package.js +377 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/proxy.js +58 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/ruby.js +44 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/set.js +332 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/stack_trace.js +151 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/state.js +95 -0
- data/generators/dashboard/templates/js.class-2.1.4/src/stdlib.js +2517 -0
- data/generators/dashboard/templates/show.html.erb +67 -0
- data/lib/acts_as_dashboard/app/views/dashboards/show.html.erb +67 -0
- data/lib/acts_as_dashboard/class_methods.rb +58 -0
- data/lib/acts_as_dashboard/config.rb +25 -0
- data/lib/acts_as_dashboard/instance_methods.rb +32 -0
- data/lib/acts_as_dashboard/line_graph_widget.rb +68 -0
- data/lib/acts_as_dashboard/public/javascripts/dashboard.js +305 -0
- data/lib/acts_as_dashboard/public/stylesheets/dashboard.css +66 -0
- data/lib/acts_as_dashboard/short_messages_widget.rb +25 -0
- data/lib/acts_as_dashboard/widget.rb +55 -0
- data/lib/acts_as_dashboard.rb +17 -0
- data/spec/acts_as_dashboard/class_method_specs.rb +188 -0
- data/spec/acts_as_dashboard/config_spec.rb +57 -0
- data/spec/acts_as_dashboard/instance_methods_spec.rb +134 -0
- data/spec/acts_as_dashboard/line_graph_widget_spec.rb +165 -0
- data/spec/acts_as_dashboard/short_messages_widget_spec.rb +69 -0
- data/spec/acts_as_dashboard/widget_spec.rb +6 -0
- data/spec/acts_as_dashboard_spec.rb +15 -0
- data/spec/shared/widget_behaviours.rb +171 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/install.rake +8 -0
- data/tasks/install_javascript.rake +7 -0
- data/tasks/install_stylesheets.rake +7 -0
- metadata +209 -0
@@ -0,0 +1,232 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 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 dot leonello at gmail
|
9
|
+
* dot com 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: fontFamily
|
76
|
+
// css spec for the font-family css attribute.
|
77
|
+
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
78
|
+
// prop: fontSize
|
79
|
+
// CSS spec for font size.
|
80
|
+
this.fontSize = '11px';
|
81
|
+
// prop: fontWeight
|
82
|
+
// CSS spec for fontWeight
|
83
|
+
this.fontWeight = 'normal';
|
84
|
+
// prop: fontStretch
|
85
|
+
// Multiplier to condense or expand font width.
|
86
|
+
// Applies only to browsers which don't support canvas native font rendering.
|
87
|
+
this.fontStretch = 1.0;
|
88
|
+
// prop: textColor
|
89
|
+
// css spec for the color attribute.
|
90
|
+
this.textColor = '#666666';
|
91
|
+
// prop: enableFontSupport
|
92
|
+
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
93
|
+
// If true, tick label will be drawn with canvas tag native support for fonts.
|
94
|
+
// If false, tick label will be drawn with Hershey font metrics.
|
95
|
+
this.enableFontSupport = false;
|
96
|
+
// prop: pt2px
|
97
|
+
// Point to pixel scaling factor, used for computing height of bounding box
|
98
|
+
// around a label. The labels text renderer has a default setting of 1.4, which
|
99
|
+
// should be suitable for most fonts. Leave as null to use default. If tops of
|
100
|
+
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
101
|
+
// This is an issue only with the native font renderering capabilities of Mozilla
|
102
|
+
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
103
|
+
this.pt2px = null;
|
104
|
+
|
105
|
+
this._elem;
|
106
|
+
this._ctx;
|
107
|
+
this._plotWidth;
|
108
|
+
this._plotHeight;
|
109
|
+
this._plotDimensions = {height:null, width:null};
|
110
|
+
|
111
|
+
$.extend(true, this, options);
|
112
|
+
|
113
|
+
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
114
|
+
if (this.pt2px) {
|
115
|
+
ropts.pt2px = this.pt2px;
|
116
|
+
}
|
117
|
+
|
118
|
+
if (this.enableFontSupport) {
|
119
|
+
if ($.browser.safari) {
|
120
|
+
var p = $.browser.version.split('.');
|
121
|
+
for (var i=0; i<p.length; i++) { p[i] = Number(p[i]); }
|
122
|
+
if (p[0] > 528 || (p[0] == 528 && p[1] >= 16)) {
|
123
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
else if ($.browser.mozilla) {
|
127
|
+
var p = $.browser.version.split(".");
|
128
|
+
if (p[0] > 1 || (p[0] == 1 && p[1] >= 9 && p[2] > 0) ) {
|
129
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
130
|
+
}
|
131
|
+
else {
|
132
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
// TODO: test and enable this
|
137
|
+
// else if ($.browser.msie) {
|
138
|
+
// this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
139
|
+
// }
|
140
|
+
|
141
|
+
else {
|
142
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
else {
|
146
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
147
|
+
}
|
148
|
+
};
|
149
|
+
|
150
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
|
151
|
+
$.extend(true, this, options);
|
152
|
+
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
153
|
+
};
|
154
|
+
|
155
|
+
// return width along the x axis
|
156
|
+
// will check first to see if an element exists.
|
157
|
+
// if not, will return the computed text box width.
|
158
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
|
159
|
+
if (this._elem) {
|
160
|
+
return this._elem.outerWidth(true);
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
var tr = this._textRenderer;
|
164
|
+
var l = tr.getWidth(ctx);
|
165
|
+
var h = tr.getHeight(ctx);
|
166
|
+
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
167
|
+
return w;
|
168
|
+
}
|
169
|
+
};
|
170
|
+
|
171
|
+
// return height along the y axis.
|
172
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
|
173
|
+
if (this._elem) {
|
174
|
+
return this._elem.outerHeight(true);
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
var tr = this._textRenderer;
|
178
|
+
var l = tr.getWidth(ctx);
|
179
|
+
var h = tr.getHeight(ctx);
|
180
|
+
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
181
|
+
return w;
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
|
186
|
+
var a = this.angle * Math.PI/180;
|
187
|
+
return a;
|
188
|
+
};
|
189
|
+
|
190
|
+
|
191
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
|
192
|
+
this.value = value;
|
193
|
+
if (isMinor) {
|
194
|
+
this.isMinorTick = true;
|
195
|
+
}
|
196
|
+
return this;
|
197
|
+
};
|
198
|
+
|
199
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx) {
|
200
|
+
if (!this.label) {
|
201
|
+
this.label = this.formatter(this.formatString, this.value);
|
202
|
+
}
|
203
|
+
// create a canvas here, but can't draw on it untill it is appended
|
204
|
+
// to dom for IE compatability.
|
205
|
+
var domelem = document.createElement('canvas');
|
206
|
+
this._textRenderer.setText(this.label, ctx);
|
207
|
+
var w = this.getWidth(ctx);
|
208
|
+
var h = this.getHeight(ctx);
|
209
|
+
domelem.width = w;
|
210
|
+
domelem.height = h;
|
211
|
+
domelem.style.width = w;
|
212
|
+
domelem.style.height = h;
|
213
|
+
domelem.style.textAlign = 'left';
|
214
|
+
domelem.style.position = 'absolute';
|
215
|
+
this._domelem = domelem;
|
216
|
+
this._elem = $(domelem);
|
217
|
+
this._elem.css(this._styles);
|
218
|
+
this._elem.addClass('jqplot-'+this.axis+'-tick');
|
219
|
+
|
220
|
+
return this._elem;
|
221
|
+
};
|
222
|
+
|
223
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
|
224
|
+
if ($.browser.msie) {
|
225
|
+
window.G_vmlCanvasManager.init_(document);
|
226
|
+
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
227
|
+
}
|
228
|
+
var ctx = this._elem.get(0).getContext("2d");
|
229
|
+
this._textRenderer.draw(ctx, this.label);
|
230
|
+
};
|
231
|
+
|
232
|
+
})(jQuery);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 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
|
+
* Although not required, the author would appreciate an email letting him
|
8
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
9
|
+
* chris dot leonello at gmail dot com or see http://www.jqplot.com/info.php .
|
10
|
+
*
|
11
|
+
* If you are feeling kind and generous, consider supporting the project by
|
12
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
13
|
+
*/
|
14
|
+
(function(a){a.jqplot.CanvasAxisTickRenderer=function(b){this.mark="outside";this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.angle=0;this.markSize=4;this.show=true;this.showLabel=true;this.labelPosition="auto";this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.formatString="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="11px";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=false;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);var e={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){e.pt2px=this.pt2px}if(this.enableFontSupport){if(a.browser.safari){var d=a.browser.version.split(".");for(var c=0;c<d.length;c++){d[c]=Number(d[c])}if(d[0]>528||(d[0]==528&&d[1]>=16)){this._textRenderer=new a.jqplot.CanvasFontRenderer(e)}}else{if(a.browser.mozilla){var d=a.browser.version.split(".");if(d[0]>1||(d[0]==1&&d[1]>=9&&d[2]>0)){this._textRenderer=new a.jqplot.CanvasFontRenderer(e)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(e)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(e)}}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(e)}};a.jqplot.CanvasAxisTickRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisTickRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;if(c){this.isMinorTick=true}return this};a.jqplot.CanvasAxisTickRenderer.prototype.draw=function(c){if(!this.label){this.label=this.formatter(this.formatString,this.value)}var e=document.createElement("canvas");this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.textAlign="left";e.style.position="absolute";this._domelem=e;this._elem=a(e);this._elem.css(this._styles);this._elem.addClass("jqplot-"+this.axis+"-tick");return this._elem};a.jqplot.CanvasAxisTickRenderer.prototype.pack=function(){if(a.browser.msie){window.G_vmlCanvasManager.init_(document);this._domelem=window.G_vmlCanvasManager.initElement(this._domelem)}var b=this._elem.get(0).getContext("2d");this._textRenderer.draw(b,this.label)}})(jQuery);
|
@@ -0,0 +1,408 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 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 dot leonello at gmail
|
9
|
+
* dot com 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);
|