acts_as_dashboard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +54 -0
  5. data/Rakefile +23 -0
  6. data/VERSION +1 -0
  7. data/acts_as_dashboard.gemspec +166 -0
  8. data/generators/dashboard/USAGE +23 -0
  9. data/generators/dashboard/dashboard_generator.rb +105 -0
  10. data/generators/dashboard/templates/controller.erb +39 -0
  11. data/generators/dashboard/templates/dashboard.css +66 -0
  12. data/generators/dashboard/templates/dashboard.js +305 -0
  13. data/generators/dashboard/templates/jqplot-0.9.7/jquery.jqplot.min.js +14 -0
  14. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.barRenderer.js +404 -0
  15. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.barRenderer.min.js +14 -0
  16. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisLabelRenderer.js +200 -0
  17. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisLabelRenderer.min.js +14 -0
  18. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisTickRenderer.js +232 -0
  19. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasAxisTickRenderer.min.js +14 -0
  20. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasTextRenderer.js +408 -0
  21. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.canvasTextRenderer.min.js +14 -0
  22. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.categoryAxisRenderer.js +238 -0
  23. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.categoryAxisRenderer.min.js +14 -0
  24. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.cursor.js +812 -0
  25. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.cursor.min.js +14 -0
  26. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dateAxisRenderer.js +313 -0
  27. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dateAxisRenderer.min.js +14 -0
  28. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dragable.js +203 -0
  29. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.dragable.min.js +14 -0
  30. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.highlighter.js +359 -0
  31. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.highlighter.min.js +14 -0
  32. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.logAxisRenderer.js +434 -0
  33. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.logAxisRenderer.min.js +14 -0
  34. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoAxisRenderer.js +595 -0
  35. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoAxisRenderer.min.js +14 -0
  36. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoRenderer.js +308 -0
  37. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.mekkoRenderer.min.js +14 -0
  38. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.ohlcRenderer.js +343 -0
  39. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.ohlcRenderer.min.js +14 -0
  40. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pieRenderer.js +333 -0
  41. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pieRenderer.min.js +14 -0
  42. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.js +307 -0
  43. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.js.orig +273 -0
  44. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.pointLabels.min.js +14 -0
  45. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.trendline.js +208 -0
  46. data/generators/dashboard/templates/jqplot-0.9.7/plugins/jqplot.trendline.min.js +14 -0
  47. data/generators/dashboard/templates/jquery.jqplot.min.css +1 -0
  48. data/generators/dashboard/templates/js.class-2.1.4/CHANGELOG +269 -0
  49. data/generators/dashboard/templates/js.class-2.1.4/MIT-LICENSE +30 -0
  50. data/generators/dashboard/templates/js.class-2.1.4/README +30 -0
  51. data/generators/dashboard/templates/js.class-2.1.4/min/command.js +1 -0
  52. data/generators/dashboard/templates/js.class-2.1.4/min/comparable.js +1 -0
  53. data/generators/dashboard/templates/js.class-2.1.4/min/constant_scope.js +1 -0
  54. data/generators/dashboard/templates/js.class-2.1.4/min/core.js +1 -0
  55. data/generators/dashboard/templates/js.class-2.1.4/min/decorator.js +1 -0
  56. data/generators/dashboard/templates/js.class-2.1.4/min/enumerable.js +1 -0
  57. data/generators/dashboard/templates/js.class-2.1.4/min/forwardable.js +1 -0
  58. data/generators/dashboard/templates/js.class-2.1.4/min/hash.js +1 -0
  59. data/generators/dashboard/templates/js.class-2.1.4/min/linked_list.js +1 -0
  60. data/generators/dashboard/templates/js.class-2.1.4/min/loader.js +1 -0
  61. data/generators/dashboard/templates/js.class-2.1.4/min/method_chain.js +1 -0
  62. data/generators/dashboard/templates/js.class-2.1.4/min/observable.js +1 -0
  63. data/generators/dashboard/templates/js.class-2.1.4/min/package.js +1 -0
  64. data/generators/dashboard/templates/js.class-2.1.4/min/proxy.js +1 -0
  65. data/generators/dashboard/templates/js.class-2.1.4/min/ruby.js +1 -0
  66. data/generators/dashboard/templates/js.class-2.1.4/min/set.js +1 -0
  67. data/generators/dashboard/templates/js.class-2.1.4/min/stack_trace.js +1 -0
  68. data/generators/dashboard/templates/js.class-2.1.4/min/state.js +1 -0
  69. data/generators/dashboard/templates/js.class-2.1.4/min/stdlib.js +16 -0
  70. data/generators/dashboard/templates/js.class-2.1.4/src/command.js +93 -0
  71. data/generators/dashboard/templates/js.class-2.1.4/src/comparable.js +37 -0
  72. data/generators/dashboard/templates/js.class-2.1.4/src/constant_scope.js +48 -0
  73. data/generators/dashboard/templates/js.class-2.1.4/src/core.js +1060 -0
  74. data/generators/dashboard/templates/js.class-2.1.4/src/decorator.js +50 -0
  75. data/generators/dashboard/templates/js.class-2.1.4/src/enumerable.js +505 -0
  76. data/generators/dashboard/templates/js.class-2.1.4/src/forwardable.js +22 -0
  77. data/generators/dashboard/templates/js.class-2.1.4/src/hash.js +334 -0
  78. data/generators/dashboard/templates/js.class-2.1.4/src/linked_list.js +114 -0
  79. data/generators/dashboard/templates/js.class-2.1.4/src/loader.js +458 -0
  80. data/generators/dashboard/templates/js.class-2.1.4/src/method_chain.js +172 -0
  81. data/generators/dashboard/templates/js.class-2.1.4/src/observable.js +55 -0
  82. data/generators/dashboard/templates/js.class-2.1.4/src/package.js +377 -0
  83. data/generators/dashboard/templates/js.class-2.1.4/src/proxy.js +58 -0
  84. data/generators/dashboard/templates/js.class-2.1.4/src/ruby.js +44 -0
  85. data/generators/dashboard/templates/js.class-2.1.4/src/set.js +332 -0
  86. data/generators/dashboard/templates/js.class-2.1.4/src/stack_trace.js +151 -0
  87. data/generators/dashboard/templates/js.class-2.1.4/src/state.js +95 -0
  88. data/generators/dashboard/templates/js.class-2.1.4/src/stdlib.js +2517 -0
  89. data/generators/dashboard/templates/show.html.erb +67 -0
  90. data/lib/acts_as_dashboard/app/views/dashboards/show.html.erb +67 -0
  91. data/lib/acts_as_dashboard/class_methods.rb +58 -0
  92. data/lib/acts_as_dashboard/config.rb +25 -0
  93. data/lib/acts_as_dashboard/instance_methods.rb +32 -0
  94. data/lib/acts_as_dashboard/line_graph_widget.rb +68 -0
  95. data/lib/acts_as_dashboard/public/javascripts/dashboard.js +305 -0
  96. data/lib/acts_as_dashboard/public/stylesheets/dashboard.css +66 -0
  97. data/lib/acts_as_dashboard/short_messages_widget.rb +25 -0
  98. data/lib/acts_as_dashboard/widget.rb +55 -0
  99. data/lib/acts_as_dashboard.rb +17 -0
  100. data/spec/acts_as_dashboard/class_method_specs.rb +188 -0
  101. data/spec/acts_as_dashboard/config_spec.rb +57 -0
  102. data/spec/acts_as_dashboard/instance_methods_spec.rb +134 -0
  103. data/spec/acts_as_dashboard/line_graph_widget_spec.rb +165 -0
  104. data/spec/acts_as_dashboard/short_messages_widget_spec.rb +69 -0
  105. data/spec/acts_as_dashboard/widget_spec.rb +6 -0
  106. data/spec/acts_as_dashboard_spec.rb +15 -0
  107. data/spec/shared/widget_behaviours.rb +171 -0
  108. data/spec/spec.opts +1 -0
  109. data/spec/spec_helper.rb +10 -0
  110. data/tasks/install.rake +8 -0
  111. data/tasks/install_javascript.rake +7 -0
  112. data/tasks/install_stylesheets.rake +7 -0
  113. metadata +209 -0
@@ -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.OHLCRenderer=function(){a.jqplot.LineRenderer.call(this);this.candleStick=false;this.tickLength="auto";this.bodyWidth="auto";this.openColor=null;this.closeColor=null;this.wickColor=null;this.fillUpBody=false;this.fillDownBody=true;this.upBodyColor=null;this.downBodyColor=null;this.hlc=false;this._tickLength;this._bodyWidth};a.jqplot.OHLCRenderer.prototype=new a.jqplot.LineRenderer();a.jqplot.OHLCRenderer.prototype.constructor=a.jqplot.OHLCRenderer;a.jqplot.OHLCRenderer.prototype.init=function(e){this.lineWidth=1.5;a.jqplot.LineRenderer.prototype.init.call(this,e);var b=this._yaxis._dataBounds;var f=this._plotData;if(f[0].length<5){this.renderer.hlc=true;for(var c=0;c<f.length;c++){if(f[c][2]<b.min||b.min==null){b.min=f[c][2]}if(f[c][1]>b.max||b.max==null){b.max=f[c][1]}}}else{for(var c=0;c<f.length;c++){if(f[c][3]<b.min||b.min==null){b.min=f[c][3]}if(f[c][2]>b.max||b.max==null){b.max=f[c][2]}}}};a.jqplot.OHLCRenderer.prototype.draw=function(z,J,g){var G=this.data;var u=this._xaxis.min;var y=this._xaxis.max;var k=0;var H=G.length;var n=this._xaxis.series_u2p;var F=this._yaxis.series_u2p;var C,D,e,I,E,m,K,B;var v;var t=this.renderer;var q=(g!=undefined)?g:{};var j=(q.shadow!=undefined)?q.shadow:this.shadow;var A=(q.fill!=undefined)?q.fill:this.fill;var c=(q.fillAndStroke!=undefined)?q.fillAndStroke:this.fillAndStroke;t.bodyWidth=(q.bodyWidth!=undefined)?q.bodyWidth:t.bodyWidth;t.tickLength=(q.tickLength!=undefined)?q.tickLength:t.tickLength;z.save();if(this.show){var l,p,f,L,s;for(var C=0;C<G.length;C++){if(G[C][0]<u){k=C}else{if(G[C][0]<y){H=C+1}}}if(t.candleStick){if(typeof(t.bodyWidth)=="number"){t._bodyWidth=t.bodyWidth}else{t._bodyWidth=Math.min(20,z.canvas.width/(H-k)/2)}}else{if(typeof(t.tickLength)=="number"){t._tickLength=t.tickLength}else{t._tickLength=Math.min(10,z.canvas.width/(H-k)/4)}}for(var C=k;C<H;C++){l=n(G[C][0]);if(t.hlc){p=null;f=F(G[C][1]);L=F(G[C][2]);s=F(G[C][3])}else{p=F(G[C][1]);f=F(G[C][2]);L=F(G[C][3]);s=F(G[C][4])}v={};if(t.candleStick&&!t.hlc){m=t._bodyWidth;K=l-m/2;if(s<p){if(t.wickColor){v.color=t.wickColor}else{if(t.downBodyColor){v.color=t.upBodyColor}}e=a.extend(true,{},q,v);t.shapeRenderer.draw(z,[[l,f],[l,s]],e);t.shapeRenderer.draw(z,[[l,p],[l,L]],e);v={};I=s;E=p-s;if(t.fillUpBody){v.fillRect=true}else{v.strokeRect=true;m=m-this.lineWidth;K=l-m/2}if(t.upBodyColor){v.color=t.upBodyColor;v.fillStyle=t.upBodyColor}B=[K,I,m,E]}else{if(s>p){if(t.wickColor){v.color=t.wickColor}else{if(t.downBodyColor){v.color=t.downBodyColor}}e=a.extend(true,{},q,v);t.shapeRenderer.draw(z,[[l,f],[l,p]],e);t.shapeRenderer.draw(z,[[l,s],[l,L]],e);v={};I=p;E=s-p;if(t.fillDownBody){v.fillRect=true}else{v.strokeRect=true;m=m-this.lineWidth;K=l-m/2}if(t.downBodyColor){v.color=t.downBodyColor;v.fillStyle=t.downBodyColor}B=[K,I,m,E]}else{if(t.wickColor){v.color=t.wickColor}e=a.extend(true,{},q,v);t.shapeRenderer.draw(z,[[l,f],[l,L]],e);v={};v.fillRect=false;v.strokeRect=false;K=[l-m/2,p];I=[l+m/2,s];m=null;E=null;B=[K,I]}}e=a.extend(true,{},q,v);t.shapeRenderer.draw(z,B,e)}else{D=q.color;if(t.openColor){q.color=t.openColor}if(!t.hlc){t.shapeRenderer.draw(z,[[l-t._tickLength,p],[l,p]],q)}q.color=D;if(t.wickColor){q.color=t.wickColor}t.shapeRenderer.draw(z,[[l,f],[l,L]],q);q.color=D;if(t.closeColor){q.color=t.closeColor}t.shapeRenderer.draw(z,[[l,s],[l+t._tickLength,s]],q);q.color=D}}}z.restore()};a.jqplot.OHLCRenderer.prototype.drawShadow=function(b,d,c){};a.jqplot.OHLCRenderer.checkOptions=function(d,c,b){if(!b.highlighter){b.highlighter={showMarker:false,tooltipAxes:"y",yvalues:4,formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>'}}}})(jQuery);
@@ -0,0 +1,333 @@
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.PieRenderer
21
+ * Plugin renderer to draw a pie chart.
22
+ * Pie charts will draw only the first series. Other series are ignored.
23
+ * x values, if present, will be used as slice labels.
24
+ * y values give slice size.
25
+ */
26
+ $.jqplot.PieRenderer = function(){
27
+ $.jqplot.LineRenderer.call(this);
28
+ };
29
+
30
+ $.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer();
31
+ $.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer;
32
+
33
+ // called with scope of a series
34
+ $.jqplot.PieRenderer.prototype.init = function(options) {
35
+ // Group: Properties
36
+ //
37
+ // prop: diameter
38
+ // diameter of the pie, auto computed by default
39
+ this.diameter = null;
40
+ // prop: padding
41
+ // padding between the pie and plot edges, legend, etc.
42
+ this.padding = 20;
43
+ // prop: sliceMargin
44
+ // pixels spacing between pie slices.
45
+ this.sliceMargin = 0;
46
+ // prop: fill
47
+ // true or false, wether to fil the slices.
48
+ this.fill = true;
49
+ // prop: shadowOffset
50
+ // offset of the shadow from the slice and offset of
51
+ // each succesive stroke of the shadow from the last.
52
+ this.shadowOffset = 2;
53
+ // prop: shadowAlpha
54
+ // transparency of the shadow (0 = transparent, 1 = opaque)
55
+ this.shadowAlpha = 0.07;
56
+ // prop: shadowDepth
57
+ // number of strokes to apply to the shadow,
58
+ // each stroke offset shadowOffset from the last.
59
+ this.shadowDepth = 5;
60
+ this.tickRenderer = $.jqplot.PieTickRenderer;
61
+ $.extend(true, this, options);
62
+ if (this.diameter != null) {
63
+ this.diameter = this.diameter - this.sliceMargin;
64
+ }
65
+ this._diameter = null;
66
+ };
67
+
68
+ $.jqplot.PieRenderer.prototype.setGridData = function(plot) {
69
+ // this is a no-op
70
+ };
71
+
72
+ $.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) {
73
+ var stack = [];
74
+ var td = [];
75
+ for (var i=0; i<data.length; i++){
76
+ stack.push(data[i][1]);
77
+ td.push([data[i][0]]);
78
+ if (i>0) {
79
+ stack[i] += stack[i-1];
80
+ }
81
+ }
82
+ var fact = Math.PI*2/stack[stack.length - 1];
83
+
84
+ for (var i=0; i<stack.length; i++) {
85
+ td[i][1] = stack[i] * fact;
86
+ }
87
+ return td;
88
+ };
89
+
90
+ $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
91
+ var r = this._diameter / 2;
92
+ var fill = this.fill;
93
+ var lineWidth = this.lineWidth;
94
+ ctx.save();
95
+ ctx.translate(this.sliceMargin*Math.cos((ang1+ang2)/2), this.sliceMargin*Math.sin((ang1+ang2)/2));
96
+
97
+ if (isShadow) {
98
+ for (var i=0; i<this.shadowDepth; i++) {
99
+ ctx.save();
100
+ ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
101
+ doDraw();
102
+ }
103
+ }
104
+
105
+ else {
106
+ doDraw();
107
+ }
108
+
109
+ function doDraw () {
110
+ // Fix for IE and Chrome that can't seem to draw circles correctly.
111
+ // ang2 should always be <= 2 pi since that is the way the data is converted.
112
+ if (ang2 > 6.282) {
113
+ ang2 = 6.282;
114
+ if (ang1 > ang2) {
115
+ ang1 = 6.281;
116
+ }
117
+ }
118
+ ctx.beginPath();
119
+ ctx.moveTo(0, 0);
120
+ ctx.fillStyle = color;
121
+ ctx.strokeStyle = color;
122
+ ctx.lineWidth = lineWidth;
123
+ ctx.arc(0, 0, r, ang1, ang2, false);
124
+ ctx.closePath();
125
+ if (fill) {
126
+ ctx.fill();
127
+ }
128
+ else {
129
+ ctx.stroke();
130
+ }
131
+ }
132
+
133
+ if (isShadow) {
134
+ for (var i=0; i<this.shadowDepth; i++) {
135
+ ctx.restore();
136
+ }
137
+ }
138
+
139
+ ctx.restore();
140
+ };
141
+
142
+ // called with scope of series
143
+ $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options) {
144
+ var i;
145
+ var opts = (options != undefined) ? options : {};
146
+ // offset and direction of offset due to legend placement
147
+ var offx = 0;
148
+ var offy = 0;
149
+ var trans = 1;
150
+ var colorGenerator = new this.colorGenerator(this.seriesColors);
151
+ if (options.legendInfo) {
152
+ var li = options.legendInfo;
153
+ switch (li.location) {
154
+ case 'nw':
155
+ offx = li.width + li.xoffset;
156
+ break;
157
+ case 'w':
158
+ offx = li.width + li.xoffset;
159
+ break;
160
+ case 'sw':
161
+ offx = li.width + li.xoffset;
162
+ break;
163
+ case 'ne':
164
+ offx = li.width + li.xoffset;
165
+ trans = -1;
166
+ break;
167
+ case 'e':
168
+ offx = li.width + li.xoffset;
169
+ trans = -1;
170
+ break;
171
+ case 'se':
172
+ offx = li.width + li.xoffset;
173
+ trans = -1;
174
+ break;
175
+ case 'n':
176
+ offy = li.height + li.yoffset;
177
+ break;
178
+ case 's':
179
+ offy = li.height + li.yoffset;
180
+ trans = -1;
181
+ break;
182
+ default:
183
+ break;
184
+ }
185
+ }
186
+
187
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
188
+ var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
189
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
190
+ var cw = ctx.canvas.width;
191
+ var ch = ctx.canvas.height;
192
+ var w = cw - offx - 2 * this.padding;
193
+ var h = ch - offy - 2 * this.padding;
194
+ var d = Math.min(w,h);
195
+ this._diameter = this.diameter || d - this.sliceMargin;
196
+ // this.diameter -= this.sliceMargin;
197
+ var r = this._diameter/2;
198
+ ctx.save();
199
+ ctx.translate((cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy);
200
+
201
+ if (this.shadow) {
202
+ var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
203
+ for (var i=0; i<gd.length; i++) {
204
+ var ang1 = (i == 0) ? 0 : gd[i-1][1];
205
+ this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1], shadowColor, true);
206
+ }
207
+
208
+ }
209
+ for (var i=0; i<gd.length; i++) {
210
+ var ang1 = (i == 0) ? 0 : gd[i-1][1];
211
+ this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1], colorGenerator.next());
212
+ }
213
+
214
+ ctx.restore();
215
+ };
216
+
217
+ $.jqplot.PieAxisRenderer = function() {
218
+ $.jqplot.LinearAxisRenderer.call(this);
219
+ };
220
+
221
+ $.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
222
+ $.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer;
223
+
224
+
225
+ // There are no traditional axes on a pie chart. We just need to provide
226
+ // dummy objects with properties so the plot will render.
227
+ // called with scope of axis object.
228
+ $.jqplot.PieAxisRenderer.prototype.init = function(options){
229
+ //
230
+ this.tickRenderer = $.jqplot.PieTickRenderer;
231
+ $.extend(true, this, options);
232
+ // I don't think I'm going to need _dataBounds here.
233
+ // have to go Axis scaling in a way to fit chart onto plot area
234
+ // and provide u2p and p2u functionality for mouse cursor, etc.
235
+ // for convienence set _dataBounds to 0 and 100 and
236
+ // set min/max to 0 and 100.
237
+ this._dataBounds = {min:0, max:100};
238
+ this.min = 0;
239
+ this.max = 100;
240
+ this.showTicks = false;
241
+ this.ticks = [];
242
+ this.showMark = false;
243
+ this.show = false;
244
+ };
245
+
246
+ $.jqplot.PieLegendRenderer = function() {
247
+ $.jqplot.TableLegendRenderer.call(this);
248
+ };
249
+
250
+ $.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
251
+ $.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer;
252
+
253
+ // called with context of legend
254
+ $.jqplot.PieLegendRenderer.prototype.draw = function() {
255
+ var legend = this;
256
+ if (this.show) {
257
+ var series = this._series;
258
+ // make a table. one line label per row.
259
+ var ss = 'position:absolute;';
260
+ ss += (this.background) ? 'background:'+this.background+';' : '';
261
+ ss += (this.border) ? 'border:'+this.border+';' : '';
262
+ ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
263
+ ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
264
+ ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
265
+ this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
266
+
267
+ var pad = false;
268
+ var s = series[0];
269
+ var colorGenerator = new s.colorGenerator(s.seriesColors);
270
+ if (s.show) {
271
+ var pd = s.data;
272
+ for (var i=0; i<pd.length; i++){
273
+ var lt = pd[i][0].toString();
274
+ if (lt) {
275
+ this.renderer.addrow.call(this, lt, colorGenerator.next(), pad);
276
+ pad = true;
277
+ }
278
+ }
279
+ }
280
+ }
281
+ return this._elem;
282
+ };
283
+
284
+ // setup default renderers for axes and legend so user doesn't have to
285
+ // called with scope of plot
286
+ function preInit(target, data, options) {
287
+ options = options || {};
288
+ options.axesDefaults = options.axesDefaults || {};
289
+ options.legend = options.legend || {};
290
+ options.seriesDefaults = options.seriesDefaults || {};
291
+ // only set these if there is a pie series
292
+ var setopts = false;
293
+ if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) {
294
+ setopts = true;
295
+ }
296
+ else if (options.series) {
297
+ for (var i=0; i < options.series.length; i++) {
298
+ if (options.series[i].renderer == $.jqplot.PieRenderer) {
299
+ setopts = true;
300
+ }
301
+ }
302
+ }
303
+
304
+ if (setopts) {
305
+ options.axesDefaults.renderer = $.jqplot.PieAxisRenderer;
306
+ options.legend.renderer = $.jqplot.PieLegendRenderer;
307
+ options.legend.preDraw = true;
308
+ // options.seriesDefaults.colorGenerator = this.colorGenerator;
309
+ // options.seriesDefaults.seriesColors = this.seriesColors;
310
+ }
311
+ }
312
+
313
+ // called with scope of plot
314
+ function postParseOptions(options) {
315
+ for (var i=0; i<this.series.length; i++) {
316
+ this.series[i].seriesColors = this.seriesColors;
317
+ this.series[i].colorGenerator = this.colorGenerator;
318
+ }
319
+ }
320
+
321
+ $.jqplot.preInitHooks.push(preInit);
322
+ $.jqplot.postParseOptionsHooks.push(postParseOptions);
323
+
324
+ $.jqplot.PieTickRenderer = function() {
325
+ $.jqplot.AxisTickRenderer.call(this);
326
+ };
327
+
328
+ $.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
329
+ $.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer;
330
+
331
+ })(jQuery);
332
+
333
+
@@ -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(b){b.jqplot.PieRenderer=function(){b.jqplot.LineRenderer.call(this)};b.jqplot.PieRenderer.prototype=new b.jqplot.LineRenderer();b.jqplot.PieRenderer.prototype.constructor=b.jqplot.PieRenderer;b.jqplot.PieRenderer.prototype.init=function(d){this.diameter=null;this.padding=20;this.sliceMargin=0;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.tickRenderer=b.jqplot.PieTickRenderer;b.extend(true,this,d);if(this.diameter!=null){this.diameter=this.diameter-this.sliceMargin}this._diameter=null};b.jqplot.PieRenderer.prototype.setGridData=function(d){};b.jqplot.PieRenderer.prototype.makeGridData=function(g,h){var d=[];var j=[];for(var f=0;f<g.length;f++){d.push(g[f][1]);j.push([g[f][0]]);if(f>0){d[f]+=d[f-1]}}var e=Math.PI*2/d[d.length-1];for(var f=0;f<d.length;f++){j[f][1]=d[f]*e}return j};b.jqplot.PieRenderer.prototype.drawSlice=function(n,l,k,f,h){var d=this._diameter/2;var m=this.fill;var j=this.lineWidth;n.save();n.translate(this.sliceMargin*Math.cos((l+k)/2),this.sliceMargin*Math.sin((l+k)/2));if(h){for(var g=0;g<this.shadowDepth;g++){n.save();n.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));e()}}else{e()}function e(){if(k>6.282){k=6.282;if(l>k){l=6.281}}n.beginPath();n.moveTo(0,0);n.fillStyle=f;n.strokeStyle=f;n.lineWidth=j;n.arc(0,0,d,l,k,false);n.closePath();if(m){n.fill()}else{n.stroke()}}if(h){for(var g=0;g<this.shadowDepth;g++){n.restore()}}n.restore()};b.jqplot.PieRenderer.prototype.draw=function(v,B,k){var y;var s=(k!=undefined)?k:{};var g=0;var f=0;var l=1;var e=new this.colorGenerator(this.seriesColors);if(k.legendInfo){var q=k.legendInfo;switch(q.location){case"nw":g=q.width+q.xoffset;break;case"w":g=q.width+q.xoffset;break;case"sw":g=q.width+q.xoffset;break;case"ne":g=q.width+q.xoffset;l=-1;break;case"e":g=q.width+q.xoffset;l=-1;break;case"se":g=q.width+q.xoffset;l=-1;break;case"n":f=q.height+q.yoffset;break;case"s":f=q.height+q.yoffset;l=-1;break;default:break}}var n=(s.shadow!=undefined)?s.shadow:this.shadow;var C=(s.showLine!=undefined)?s.showLine:this.showLine;var x=(s.fill!=undefined)?s.fill:this.fill;var j=v.canvas.width;var p=v.canvas.height;var o=j-g-2*this.padding;var z=p-f-2*this.padding;var A=Math.min(o,z);this._diameter=this.diameter||A-this.sliceMargin;var t=this._diameter/2;v.save();v.translate((j-l*g)/2+l*g,(p-l*f)/2+l*f);if(this.shadow){var u="rgba(0,0,0,"+this.shadowAlpha+")";for(var y=0;y<B.length;y++){var m=(y==0)?0:B[y-1][1];this.renderer.drawSlice.call(this,v,m,B[y][1],u,true)}}for(var y=0;y<B.length;y++){var m=(y==0)?0:B[y-1][1];this.renderer.drawSlice.call(this,v,m,B[y][1],e.next())}v.restore()};b.jqplot.PieAxisRenderer=function(){b.jqplot.LinearAxisRenderer.call(this)};b.jqplot.PieAxisRenderer.prototype=new b.jqplot.LinearAxisRenderer();b.jqplot.PieAxisRenderer.prototype.constructor=b.jqplot.PieAxisRenderer;b.jqplot.PieAxisRenderer.prototype.init=function(d){this.tickRenderer=b.jqplot.PieTickRenderer;b.extend(true,this,d);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};b.jqplot.PieLegendRenderer=function(){b.jqplot.TableLegendRenderer.call(this)};b.jqplot.PieLegendRenderer.prototype=new b.jqplot.TableLegendRenderer();b.jqplot.PieLegendRenderer.prototype.constructor=b.jqplot.PieLegendRenderer;b.jqplot.PieLegendRenderer.prototype.draw=function(){var k=this;if(this.show){var f=this._series;var m="position:absolute;";m+=(this.background)?"background:"+this.background+";":"";m+=(this.border)?"border:"+this.border+";":"";m+=(this.fontSize)?"font-size:"+this.fontSize+";":"";m+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";m+=(this.textColor)?"color:"+this.textColor+";":"";this._elem=b('<table class="jqplot-table-legend" style="'+m+'"></table>');var d=false;var l=f[0];var h=new l.colorGenerator(l.seriesColors);if(l.show){var j=l.data;for(var g=0;g<j.length;g++){var e=j[g][0].toString();if(e){this.renderer.addrow.call(this,e,h.next(),d);d=true}}}}return this._elem};function a(h,g,e){e=e||{};e.axesDefaults=e.axesDefaults||{};e.legend=e.legend||{};e.seriesDefaults=e.seriesDefaults||{};var d=false;if(e.seriesDefaults.renderer==b.jqplot.PieRenderer){d=true}else{if(e.series){for(var f=0;f<e.series.length;f++){if(e.series[f].renderer==b.jqplot.PieRenderer){d=true}}}}if(d){e.axesDefaults.renderer=b.jqplot.PieAxisRenderer;e.legend.renderer=b.jqplot.PieLegendRenderer;e.legend.preDraw=true}}function c(d){for(var e=0;e<this.series.length;e++){this.series[e].seriesColors=this.seriesColors;this.series[e].colorGenerator=this.colorGenerator}}b.jqplot.preInitHooks.push(a);b.jqplot.postParseOptionsHooks.push(c);b.jqplot.PieTickRenderer=function(){b.jqplot.AxisTickRenderer.call(this)};b.jqplot.PieTickRenderer.prototype=new b.jqplot.AxisTickRenderer();b.jqplot.PieTickRenderer.prototype.constructor=b.jqplot.PieTickRenderer})(jQuery);
@@ -0,0 +1,307 @@
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
+ /**
21
+ * Class: $.jqplot.PointLabels
22
+ * Plugin for putting labels at the data points.
23
+ *
24
+ * To use this plugin, include the js
25
+ * file in your source:
26
+ *
27
+ * > <script type="text/javascript" src="plugins/jqplot.pointLabels.js"></script>
28
+ *
29
+ * By default, the last value in the data ponit array in the data series is used
30
+ * for the label. For most series renderers, extra data can be added to the
31
+ * data point arrays and the last value will be used as the label.
32
+ *
33
+ * For instance,
34
+ * this series:
35
+ *
36
+ * > [[1,4], [3,5], [7,2]]
37
+ *
38
+ * Would, by default, use the y values in the labels.
39
+ * Extra data can be added to the series like so:
40
+ *
41
+ * > [[1,4,'mid'], [3 5,'hi'], [7,2,'low']]
42
+ *
43
+ * And now the point labels would be 'mid', 'low', and 'hi'.
44
+ *
45
+ * Options to the point labels and a custom labels array can be passed into the
46
+ * "pointLabels" option on the series option like so:
47
+ *
48
+ * > series:[{pointLabels:{
49
+ * > labels:['mid', 'hi', 'low'],
50
+ * > location:'se',
51
+ * > ypadding: 12
52
+ * > }
53
+ * > }]
54
+ *
55
+ * A custom labels array in the options takes precendence over any labels
56
+ * in the series data. If you have a custom labels array in the options,
57
+ * but still want to use values from the series array as labels, set the
58
+ * "labelsFromSeries" option to true.
59
+ *
60
+ * By default, html entities (<, >, etc.) are escaped in point labels.
61
+ * If you want to include actual html markup in the labels,
62
+ * set the "escapeHTML" option to false.
63
+ *
64
+ */
65
+ $.jqplot.PointLabels = function(options) {
66
+ // Group: Properties
67
+ //
68
+ // prop: show
69
+ // show the labels or not.
70
+ this.show = $.jqplot.config.enablePlugins;
71
+ // prop: location
72
+ // compass location where to position the label around the point.
73
+ // 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
74
+ this.location = 'n';
75
+ // prop: labelsFromSeries
76
+ // true to use labels within data point arrays.
77
+ this.labelsFromSeries = false;
78
+ // prop: seriesLabelIndex
79
+ // array index for location of labels within data point arrays.
80
+ // if null, will use the last element of teh data point array.
81
+ this.seriesLabelIndex = null;
82
+ // prop: labels
83
+ // array of arrays of labels, one array for each series.
84
+ this.labels = [];
85
+ // prop: stackedValue
86
+ // true to display value as stacked in a stacked plot.
87
+ // no effect if labels is specified.
88
+ this.stackedValue = false;
89
+ // prop: ypadding
90
+ // vertical padding in pixels between point and label
91
+ this.ypadding = 6;
92
+ // prop: xpadding
93
+ // horizontal padding in pixels between point and label
94
+ this.xpadding = 6;
95
+ // prop: escapeHTML
96
+ // true to escape html entities in the labels.
97
+ // If you want to include markup in the labels, set to false.
98
+ this.escapeHTML = true;
99
+ // prop: edgeTolerance
100
+ // Number of pixels that the label must be away from an axis
101
+ // boundary in order to be drawn. Negative values will allow overlap
102
+ // with the grid boundaries.
103
+ this.edgeTolerance = 0;
104
+ // prop: hideZeros
105
+ // true to not show a label for a value which is 0.
106
+ this.hideZeros = false;
107
+
108
+ $.extend(true, this, options);
109
+ };
110
+
111
+ var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
112
+ var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
113
+ var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
114
+
115
+ // called with scope of a series
116
+ $.jqplot.PointLabels.init = function (target, data, seriesDefaults, opts){
117
+ var options = $.extend(true, {}, seriesDefaults, opts);
118
+ // add a pointLabels attribute to the series plugins
119
+ this.plugins.pointLabels = new $.jqplot.PointLabels(options.pointLabels);
120
+ var p = this.plugins.pointLabels;
121
+ if (p.labels.length == 0 || p.labelsFromSeries) {
122
+ if (p.stackedValue) {
123
+ if (this._plotData.length && this._plotData[0].length){
124
+ var idx = p.seriesLabelIndex || this._plotData[0].length -1;
125
+ for (var i=0; i<this._plotData.length; i++) {
126
+ p.labels.push(this._plotData[i][idx]);
127
+ }
128
+ }
129
+ }
130
+ else {
131
+ var d = this.data;
132
+ if (this.renderer.constructor == $.jqplot.BarRenderer && this.waterfall) {
133
+ d = this._data;
134
+ }
135
+ if (d.length && d[0].length) {
136
+ var idx = p.seriesLabelIndex || d[0].length -1;
137
+ for (var i=0; i<d.length; i++) {
138
+ p.labels.push(d[i][idx]);
139
+ }
140
+ }
141
+ }
142
+ }
143
+ };
144
+
145
+ $.jqplot.PointLabels.prototype.xOffset = function(elem, location, padding) {
146
+ location = location || this.location;
147
+ padding = padding || this.xpadding;
148
+ var offset;
149
+
150
+ switch (location) {
151
+ case 'nw':
152
+ offset = -elem.outerWidth(true) - this.xpadding;
153
+ break;
154
+ case 'n':
155
+ offset = -elem.outerWidth(true)/2;
156
+ break;
157
+ case 'ne':
158
+ offset = this.xpadding;
159
+ break;
160
+ case 'e':
161
+ offset = this.xpadding;
162
+ break;
163
+ case 'se':
164
+ offset = this.xpadding;
165
+ break;
166
+ case 's':
167
+ offset = -elem.outerWidth(true)/2;
168
+ break;
169
+ case 'sw':
170
+ offset = -elem.outerWidth(true) - this.xpadding;
171
+ break;
172
+ case 'w':
173
+ offset = -elem.outerWidth(true) - this.xpadding;
174
+ break;
175
+ default: // same as 'nw'
176
+ offset = -elem.outerWidth(true) - this.xpadding;
177
+ break;
178
+ }
179
+ return offset;
180
+ };
181
+
182
+ $.jqplot.PointLabels.prototype.yOffset = function(elem, location, padding) {
183
+ location = location || this.location;
184
+ padding = padding || this.xpadding;
185
+ var offset;
186
+
187
+ switch (location) {
188
+ case 'nw':
189
+ offset = -elem.outerHeight(true) - this.ypadding;
190
+ break;
191
+ case 'n':
192
+ offset = -elem.outerHeight(true) - this.ypadding;
193
+ break;
194
+ case 'ne':
195
+ offset = -elem.outerHeight(true) - this.ypadding;
196
+ break;
197
+ case 'e':
198
+ offset = -elem.outerHeight(true)/2;
199
+ break;
200
+ case 'se':
201
+ offset = this.ypadding;
202
+ break;
203
+ case 's':
204
+ offset = this.ypadding;
205
+ break;
206
+ case 'sw':
207
+ offset = this.ypadding;
208
+ break;
209
+ case 'w':
210
+ offset = -elem.outerHeight(true)/2;
211
+ break;
212
+ default: // same as 'nw'
213
+ offset = -elem.outerHeight(true) - this.ypadding;
214
+ break;
215
+ }
216
+ return offset;
217
+ };
218
+
219
+ // called with scope of series
220
+ $.jqplot.PointLabels.draw = function (sctx, options) {
221
+ var p = this.plugins.pointLabels;
222
+ if (p.show) {
223
+ // var xoffset, yoffset;
224
+ //
225
+ // switch (p.location) {
226
+ // case 'nw':
227
+ // xoffset = function(elem) { return -elem.outerWidth(true) - p.xpadding; };
228
+ // yoffset = function(elem) { return -elem.outerHeight(true) - p.ypadding; };
229
+ // break;
230
+ // case 'n':
231
+ // xoffset = function(elem) { return -elem.outerWidth(true)/2; };
232
+ // yoffset = function(elem) { return -elem.outerHeight(true) - p.ypadding; };
233
+ // break;
234
+ // case 'ne':
235
+ // xoffset = function(elem) { return p.xpadding; };
236
+ // yoffset = function(elem) { return -elem.outerHeight(true) - p.ypadding; };
237
+ // break;
238
+ // case 'e':
239
+ // xoffset = function(elem) { return p.xpadding; };
240
+ // yoffset = function(elem) { return -elem.outerHeight(true)/2; };
241
+ // break;
242
+ // case 'se':
243
+ // xoffset = function(elem) { return p.xpadding; };
244
+ // yoffset = function(elem) { return p.ypadding; };
245
+ // break;
246
+ // case 's':
247
+ // xoffset = function(elem) { return -elem.outerWidth(true)/2; };
248
+ // yoffset = function(elem) { return p.ypadding; };
249
+ // break;
250
+ // case 'sw':
251
+ // xoffset = function(elem) { return -elem.outerWidth(true) - p.xpadding; };
252
+ // yoffset = function(elem) { return p.ypadding; };
253
+ // break;
254
+ // case 'w':
255
+ // xoffset = function(elem) { return -elem.outerWidth(true) - p.xpadding; };
256
+ // yoffset = function(elem) { return -elem.outerHeight(true)/2; };
257
+ // break;
258
+ // default: // same as 'nw'
259
+ // xoffset = function(elem) { return -elem.outerWidth(true) - p.xpadding; };
260
+ // yoffset = function(elem) { return -elem.outerHeight(true) - p.ypadding; };
261
+ // break;
262
+ // }
263
+
264
+ for (var i=0; i<p.labels.length; i++) {
265
+ var pd = this._plotData;
266
+ var xax = this._xaxis;
267
+ var yax = this._yaxis;
268
+ var label = p.labels[i];
269
+
270
+ if (p.hideZeros && parseInt(p.labels[i], 10) == 0) {
271
+ label = '';
272
+ }
273
+
274
+ var elem = $('<div class="jqplot-point-label" style="position:absolute"></div>');
275
+ elem.insertAfter(sctx.canvas);
276
+ if (p.escapeHTML) {
277
+ elem.text(label);
278
+ }
279
+ else {
280
+ elem.html(label);
281
+ }
282
+ var location = p.location;
283
+ if (this.waterfall && parseInt(label, 10) < 0) {
284
+ location = oppositeLocations[locationIndicies[location]];
285
+ }
286
+ var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location);
287
+ var elt = yax.u2p(pd[i][1]) + p.yOffset(elem, location);
288
+ elem.css('left', ell);
289
+ elem.css('top', elt);
290
+ var elr = ell + $(elem).width();
291
+ var elb = elt + $(elem).height();
292
+ var et = p.edgeTolerance;
293
+ var scl = $(sctx.canvas).position().left;
294
+ var sct = $(sctx.canvas).position().top;
295
+ var scr = sctx.canvas.width + scl;
296
+ var scb = sctx.canvas.height + sct;
297
+ // if label is outside of allowed area, remove it
298
+ if (ell - et < scl || elt - et < sct || elr + et > scr || elb + et > scb) {
299
+ $(elem).remove();
300
+ }
301
+ }
302
+ }
303
+ };
304
+
305
+ $.jqplot.postSeriesInitHooks.push($.jqplot.PointLabels.init);
306
+ $.jqplot.postDrawSeriesHooks.push($.jqplot.PointLabels.draw);
307
+ })(jQuery);