jquery_cheats 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/{jqueryCheats.js → jquery_cheats/jquery_cheats.js} +0 -0
- data/jquery_cheats.gemspec +1 -1
- data/lib/jquery_cheats/engine.rb +6 -0
- data/lib/{railtie.rb → jquery_cheats/railtie.rb} +0 -0
- data/lib/jquery_cheats.rb +2 -2
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/excanvas.js +1438 -1438
- data/vendor/assets/javascripts/jquery_cheats/jqplot/index.js +1 -0
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/jquery.jqplot.js +10901 -10901
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.BezierCurveRenderer.js +311 -311
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.BezierCurveRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.barRenderer.js +746 -746
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.barRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.blockRenderer.js +233 -233
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.blockRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.bubbleRenderer.js +753 -753
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.bubbleRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasAxisLabelRenderer.js +201 -201
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasAxisLabelRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasAxisTickRenderer.js +241 -241
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasAxisTickRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasOverlay.js +863 -863
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasOverlay.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasTextRenderer.js +447 -447
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.canvasTextRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.categoryAxisRenderer.js +635 -635
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.categoryAxisRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.ciParser.js +114 -114
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.ciParser.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.cursor.js +1092 -1092
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.cursor.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.dateAxisRenderer.js +702 -702
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.dateAxisRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.donutRenderer.js +799 -799
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.donutRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.dragable.js +223 -223
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.dragable.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.enhancedLegendRenderer.js +240 -240
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.enhancedLegendRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.funnelRenderer.js +937 -937
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.funnelRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.highlighter.js +453 -453
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.highlighter.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.json2.js +475 -475
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.json2.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.logAxisRenderer.js +527 -527
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.logAxisRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.mekkoAxisRenderer.js +610 -610
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.mekkoAxisRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.mekkoRenderer.js +435 -435
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.mekkoRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.meterGaugeRenderer.js +1028 -1028
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.meterGaugeRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.ohlcRenderer.js +371 -371
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.ohlcRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pieRenderer.js +898 -898
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pieRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pointLabels.js +361 -361
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pointLabels.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidAxisRenderer.js +729 -729
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidAxisRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidGridRenderer.js +422 -422
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidGridRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidRenderer.js +489 -489
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.pyramidRenderer.min.js +56 -56
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.trendline.js +221 -221
- data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.trendline.min.js +56 -56
- data/vendor/assets/stylesheets/{jquery.jqplot.css → jquery_cheats/jquery.jqplot.css} +259 -259
- metadata +68 -67
- data/lib/engine.rb +0 -7
data/vendor/assets/javascripts/{jqplot → jquery_cheats/jqplot}/plugins/jqplot.bubbleRenderer.min.js
RENAMED
@@ -1,57 +1,57 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b2_r1012
|
6
|
-
*
|
7
|
-
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
-
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
-
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
-
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
-
* choose the license that best suits your project and use it accordingly.
|
12
|
-
*
|
13
|
-
* Although not required, the author would appreciate an email letting him
|
14
|
-
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
-
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
-
*
|
17
|
-
* If you are feeling kind and generous, consider supporting the project by
|
18
|
-
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
-
*
|
20
|
-
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
-
*
|
22
|
-
* version 2007.04.27
|
23
|
-
* author Ash Searle
|
24
|
-
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
-
* http://hexmen.com/js/sprintf.js
|
26
|
-
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
-
* "This code is unrestricted: you are free to use it however you like."
|
28
|
-
*
|
29
|
-
* included jsDate library by Chris Leonello:
|
30
|
-
*
|
31
|
-
* Copyright (c) 2010-2011 Chris Leonello
|
32
|
-
*
|
33
|
-
* jsDate is currently available for use in all personal or commercial projects
|
34
|
-
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
35
|
-
* choose the license that best suits your project and use it accordingly.
|
36
|
-
*
|
37
|
-
* jsDate borrows many concepts and ideas from the Date Instance
|
38
|
-
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
39
|
-
*
|
40
|
-
* Ken's origianl Date Instance Methods and copyright notice:
|
41
|
-
*
|
42
|
-
* Ken Snyder (ken d snyder at gmail dot com)
|
43
|
-
* 2008-09-10
|
44
|
-
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
45
|
-
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
46
|
-
*
|
47
|
-
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
48
|
-
* Larry has generously given permission to adapt his code for inclusion
|
49
|
-
* into jqPlot.
|
50
|
-
*
|
51
|
-
* Larry's original code can be found here:
|
52
|
-
*
|
53
|
-
* https://github.com/lsiden/export-jqplot-to-png
|
54
|
-
*
|
55
|
-
*
|
56
|
-
*/
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
* included jsDate library by Chris Leonello:
|
30
|
+
*
|
31
|
+
* Copyright (c) 2010-2011 Chris Leonello
|
32
|
+
*
|
33
|
+
* jsDate is currently available for use in all personal or commercial projects
|
34
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
35
|
+
* choose the license that best suits your project and use it accordingly.
|
36
|
+
*
|
37
|
+
* jsDate borrows many concepts and ideas from the Date Instance
|
38
|
+
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
39
|
+
*
|
40
|
+
* Ken's origianl Date Instance Methods and copyright notice:
|
41
|
+
*
|
42
|
+
* Ken Snyder (ken d snyder at gmail dot com)
|
43
|
+
* 2008-09-10
|
44
|
+
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
45
|
+
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
46
|
+
*
|
47
|
+
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
48
|
+
* Larry has generously given permission to adapt his code for inclusion
|
49
|
+
* into jqPlot.
|
50
|
+
*
|
51
|
+
* Larry's original code can be found here:
|
52
|
+
*
|
53
|
+
* https://github.com/lsiden/export-jqplot-to-png
|
54
|
+
*
|
55
|
+
*
|
56
|
+
*/
|
57
57
|
(function(f){var d=function(m){return Math.max.apply(Math,m)};var j=function(m){return Math.min.apply(Math,m)};f.jqplot.BubbleRenderer=function(){f.jqplot.LineRenderer.call(this)};f.jqplot.BubbleRenderer.prototype=new f.jqplot.LineRenderer();f.jqplot.BubbleRenderer.prototype.constructor=f.jqplot.BubbleRenderer;f.jqplot.BubbleRenderer.prototype.init=function(w,t){this.varyBubbleColors=true;this.autoscaleBubbles=true;this.autoscaleMultiplier=1;this.autoscalePointsFactor=-0.07;this.escapeHtml=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.bubbleAlpha=1;this.highlightAlpha=null;this.bubbleGradients=false;this.showLabels=true;this.radii=[];this.maxRadius=0;this._highlightedPoint=null;this.labels=[];this.bubbleCanvases=[];this._type="bubble";if(w.highlightMouseDown&&w.highlightMouseOver==null){w.highlightMouseOver=false}f.extend(true,this,w);if(this.highlightAlpha==null){this.highlightAlpha=this.bubbleAlpha;if(this.bubbleGradients){this.highlightAlpha=0.35}}this.autoscaleMultiplier=this.autoscaleMultiplier*Math.pow(this.data.length,this.autoscalePointsFactor);this._highlightedPoint=null;var n;for(var r=0;r<this.data.length;r++){var p=null;var v=this.data[r];this.maxRadius=Math.max(this.maxRadius,v[2]);if(v[3]){if(typeof(v[3])=="object"){p=v[3]["color"]}}if(p==null){if(this.seriesColors[r]!=null){p=this.seriesColors[r]}}if(p&&this.bubbleAlpha<1){n=f.jqplot.getColorComponents(p);p="rgba("+n[0]+", "+n[1]+", "+n[2]+", "+this.bubbleAlpha+")"}if(p){this.seriesColors[r]=p}}if(!this.varyBubbleColors){this.seriesColors=[this.color]}this.colorGenerator=new f.jqplot.ColorGenerator(this.seriesColors);if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var o=f.jqplot.getColorComponents(this.seriesColors[r]);var u=[o[0],o[1],o[2]];var s=u[0]+u[1]+u[2];for(var q=0;q<3;q++){u[q]=(s>570)?u[q]*0.8:u[q]+0.3*(255-u[q]);u[q]=parseInt(u[q],10)}this.highlightColors.push("rgba("+u[0]+","+u[1]+","+u[2]+", "+this.highlightAlpha+")")}}this.highlightColorGenerator=new f.jqplot.ColorGenerator(this.highlightColors);var m={fill:true,isarc:true,angle:this.shadowAngle,alpha:this.shadowAlpha,closePath:true};this.renderer.shadowRenderer.init(m);this.canvas=new f.jqplot.DivCanvas();this.canvas._plotDimensions=this._plotDimensions;t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",k);t.eventListenerHooks.addOnce("jqplotClick",g);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};f.jqplot.BubbleRenderer.prototype.setGridData=function(w){var q=this._xaxis.series_u2p;var m=this._yaxis.series_u2p;var t=this._plotData;this.gridData=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<this.data.length;u++){if(t[u]!=null){this.gridData.push([q.call(this._xaxis,t[u][0]),m.call(this._yaxis,t[u][1]),t[u][2]]);this.radii.push([u,t[u][2]]);s.push(t[u][2])}}var n,o,x=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/x;n=this.autoscaleMultiplier*v/6;this.gridData[u][2]=n*o}}this.radii.sort(function(y,r){return r[1]-y[1]})};f.jqplot.BubbleRenderer.prototype.makeGridData=function(t,w){var q=this._xaxis.series_u2p;var n=this._yaxis.series_u2p;var x=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<t.length;u++){if(t[u]!=null){x.push([q.call(this._xaxis,t[u][0]),n.call(this._yaxis,t[u][1]),t[u][2]]);s.push(t[u][2]);this.radii.push([u,t[u][2]])}}var m,o,y=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/y;m=this.autoscaleMultiplier*v/6;x[u][2]=m*o}}this.radii.sort(function(z,r){return r[1]-z[1]});return x};f.jqplot.BubbleRenderer.prototype.draw=function(D,J,n){if(this.plugins.pointLabels){this.plugins.pointLabels.show=false}var A=(n!=undefined)?n:{};var r=(A.shadow!=undefined)?A.shadow:this.shadow;this.canvas._elem.empty();for(var G=0;G<this.radii.length;G++){var C=this.radii[G][0];var z=null;var F=null;var m=null;var p=null;var I=this.data[C];var J=this.gridData[C];if(I[3]){if(typeof(I[3])=="object"){z=I[3]["label"]}else{if(typeof(I[3])=="string"){z=I[3]}}}F=this.colorGenerator.get(C);var E=J[2];var q,K;if(this.shadow){q=(0.7+J[2]/40).toFixed(1);K=1+Math.ceil(J[2]/15);E+=q*K}this.bubbleCanvases[C]=new f.jqplot.BubbleCanvas();this.canvas._elem.append(this.bubbleCanvases[C].createElement(J[0],J[1],E));this.bubbleCanvases[C].setContext();var D=this.bubbleCanvases[C]._ctx;var u=D.canvas.width/2;var s=D.canvas.height/2;if(this.shadow){this.renderer.shadowRenderer.draw(D,[u,s,J[2],0,2*Math.PI],{offset:q,depth:K})}this.bubbleCanvases[C].draw(J[2],F,this.bubbleGradients,this.shadowAngle/180*Math.PI);if(z&&this.showLabels){p=f('<div style="position:absolute;" class="jqplot-bubble-label"></div>');if(this.escapeHtml){p.text(z)}else{p.html(z)}this.canvas._elem.append(p);var H=f(p).outerHeight();var v=f(p).outerWidth();var B=J[1]-0.5*H;var o=J[0]-0.5*v;p.css({top:B,left:o});this.labels[C]=f(p)}}};f.jqplot.DivCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.DivCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.DivCanvas.prototype.constructor=f.jqplot.DivCanvas;f.jqplot.DivCanvas.prototype.createElement=function(s,p,n){this._offsets=s;var m="jqplot-DivCanvas";if(p!=undefined){m=p}var r;if(this._elem){r=this._elem.get(0)}else{r=document.createElement("div")}if(n!=undefined){this._plotDimensions=n}var o=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var q=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=f(r);this._elem.css({position:"absolute",width:o,height:q,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(m);return this._elem};f.jqplot.DivCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx};f.jqplot.BubbleCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.BubbleCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.BubbleCanvas.prototype.constructor=f.jqplot.BubbleCanvas;f.jqplot.BubbleCanvas.prototype.createElement=function(n,u,s){var m="jqplot-bubble-point";var q;if(this._elem){q=this._elem.get(0)}else{q=document.createElement("canvas")}q.width=(s!=null)?2*s:q.width;q.height=(s!=null)?2*s:q.height;this._elem=f(q);var o=(n!=null&&s!=null)?n-s:this._elem.css("left");var p=(u!=null&&s!=null)?u-s:this._elem.css("top");this._elem.css({position:"absolute",left:o,top:p});this._elem.addClass(m);if(f.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);q=window.G_vmlCanvasManager.initElement(q)}return this._elem};f.jqplot.BubbleCanvas.prototype.draw=function(m,s,v,p){var D=this._ctx;var B=D.canvas.width/2;var z=D.canvas.height/2;D.save();if(v&&!f.jqplot.use_excanvas){m=m*1.04;var o=f.jqplot.getColorComponents(s);var u="rgba("+Math.round(o[0]+0.8*(255-o[0]))+", "+Math.round(o[1]+0.8*(255-o[1]))+", "+Math.round(o[2]+0.8*(255-o[2]))+", "+o[3]+")";var t="rgba("+o[0]+", "+o[1]+", "+o[2]+", 0)";var C=0.35*m;var A=B-Math.cos(p)*0.33*m;var n=z-Math.sin(p)*0.33*m;var w=D.createRadialGradient(A,n,C,B,z,m);w.addColorStop(0,u);w.addColorStop(0.93,s);w.addColorStop(0.96,t);w.addColorStop(1,t);D.fillStyle=w;D.fillRect(0,0,D.canvas.width,D.canvas.height)}else{D.fillStyle=s;D.strokeStyle=s;D.lineWidth=1;D.beginPath();var q=2*Math.PI;D.arc(B,z,m,0,q,0);D.closePath();D.fill()}D.restore()};f.jqplot.BubbleCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};f.jqplot.BubbleAxisRenderer=function(){f.jqplot.LinearAxisRenderer.call(this)};f.jqplot.BubbleAxisRenderer.prototype=new f.jqplot.LinearAxisRenderer();f.jqplot.BubbleAxisRenderer.prototype.constructor=f.jqplot.BubbleAxisRenderer;f.jqplot.BubbleAxisRenderer.prototype.init=function(n){f.extend(true,this,n);var I=this._dataBounds;var H=0,v=0,m=0,y=0,q=0,r=0,D=0,t=0,F=0,z=0;for(var E=0;E<this._series.length;E++){var x=this._series[E];var G=x._plotData;for(var B=0;B<G.length;B++){if(this.name=="xaxis"||this.name=="x2axis"){if(G[B][0]<I.min||I.min==null){I.min=G[B][0];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][0]>I.max||I.max==null){I.max=G[B][0];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}else{if(G[B][1]<I.min||I.min==null){I.min=G[B][1];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][1]>I.max||I.max==null){I.max=G[B][1];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}}}var o=r/D;var w=q/t;var C=I.max-I.min;var A=Math.min(this._plotDimensions.width,this._plotDimensions.height);var p=o*z/3*C;var u=w*F/3*C;I.max+=u;I.min-=p};function e(p,v,q){p.plugins.bubbleRenderer.highlightLabelCanvas.empty();var z=p.series[v];var n=p.plugins.bubbleRenderer.highlightCanvas;var w=n._ctx;w.clearRect(0,0,w.canvas.width,w.canvas.height);z._highlightedPoint=q;p.plugins.bubbleRenderer.highlightedSeriesIndex=v;var o=z.highlightColorGenerator.get(q);var u=z.gridData[q][0],t=z.gridData[q][1],m=z.gridData[q][2];w.save();w.fillStyle=o;w.strokeStyle=o;w.lineWidth=1;w.beginPath();w.arc(u,t,m,0,2*Math.PI,0);w.closePath();w.fill();w.restore();if(z.labels[q]){p.plugins.bubbleRenderer.highlightLabel=z.labels[q].clone();p.plugins.bubbleRenderer.highlightLabel.appendTo(p.plugins.bubbleRenderer.highlightLabelCanvas);p.plugins.bubbleRenderer.highlightLabel.addClass("jqplot-bubble-label-highlight")}}function i(p){var m=p.plugins.bubbleRenderer.highlightCanvas;var o=p.plugins.bubbleRenderer.highlightedSeriesIndex;p.plugins.bubbleRenderer.highlightLabelCanvas.empty();m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<p.series.length;n++){p.series[n]._highlightedPoint=null}p.plugins.bubbleRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function a(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataMouseOver");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);if(r.series[q[0]].highlightMouseOver&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var u=jQuery.Event("jqplotDataHighlight");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q);e(r,q[0],q[1])}}else{if(v==null){i(r)}}}function b(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];if(r.series[q[0]].highlightMouseDown&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var t=jQuery.Event("jqplotDataHighlight");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);e(r,q[0],q[1])}}else{if(u==null){i(r)}}}function k(o,n,r,q,p){var m=p.plugins.bubbleRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function g(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataClick");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q)}}function l(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=r.plugins.bubbleRenderer.highlightedSeriesIndex;if(t!=null&&r.series[t].highlightMouseDown){i(r)}var u=jQuery.Event("jqplotDataRightClick");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q)}}function h(){if(this.plugins.bubbleRenderer&&this.plugins.bubbleRenderer.highlightCanvas){this.plugins.bubbleRenderer.highlightCanvas.resetCanvas();this.plugins.bubbleRenderer.highlightCanvas=null}this.plugins.bubbleRenderer={highlightedSeriesIndex:null};this.plugins.bubbleRenderer.highlightCanvas=new f.jqplot.GenericCanvas();this.plugins.bubbleRenderer.highlightLabel=null;this.plugins.bubbleRenderer.highlightLabelCanvas=f('<div style="position:absolute;"></div>');var q=this._gridPadding.top;var p=this._gridPadding.left;var n=this._plotDimensions.width-this._gridPadding.left-this._gridPadding.right;var m=this._plotDimensions.height-this._gridPadding.top-this._gridPadding.bottom;this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:q,left:p,width:n+"px",height:m+"px"});this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-bubbleRenderer-highlight-canvas",this._plotDimensions,this));this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas);var o=this.plugins.bubbleRenderer.highlightCanvas.setContext()}function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==f.jqplot.BubbleRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==f.jqplot.BubbleRenderer){m=true}}}}if(m){n.axesDefaults.renderer=f.jqplot.BubbleAxisRenderer;n.sortData=false}}f.jqplot.preInitHooks.push(c)})(jQuery);
|
@@ -1,202 +1,202 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b2_r1012
|
6
|
-
*
|
7
|
-
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
-
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
-
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
-
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
-
* choose the license that best suits your project and use it accordingly.
|
12
|
-
*
|
13
|
-
* Although not required, the author would appreciate an email letting him
|
14
|
-
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
-
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
-
*
|
17
|
-
* If you are feeling kind and generous, consider supporting the project by
|
18
|
-
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
-
*
|
20
|
-
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
-
*
|
22
|
-
* version 2007.04.27
|
23
|
-
* author Ash Searle
|
24
|
-
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
-
* http://hexmen.com/js/sprintf.js
|
26
|
-
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
-
* "This code is unrestricted: you are free to use it however you like."
|
28
|
-
*
|
29
|
-
*/
|
30
|
-
(function($) {
|
31
|
-
/**
|
32
|
-
* Class: $.jqplot.CanvasAxisLabelRenderer
|
33
|
-
* Renderer to draw axis labels with a canvas element to support advanced
|
34
|
-
* featrues such as rotated text. This renderer uses a separate rendering engine
|
35
|
-
* to draw the text on the canvas. Two modes of rendering the text are available.
|
36
|
-
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
37
|
-
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
38
|
-
* You do so by setting the "enableFontSupport" option to true.
|
39
|
-
*
|
40
|
-
* Browsers lacking native font support will have the text drawn on the canvas
|
41
|
-
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
42
|
-
* non-supporting browsers will still render with the Hershey font.
|
43
|
-
*
|
44
|
-
*/
|
45
|
-
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
46
|
-
// Group: Properties
|
47
|
-
|
48
|
-
// prop: angle
|
49
|
-
// angle of text, measured clockwise from x axis.
|
50
|
-
this.angle = 0;
|
51
|
-
// name of the axis associated with this tick
|
52
|
-
this.axis;
|
53
|
-
// prop: show
|
54
|
-
// wether or not to show the tick (mark and label).
|
55
|
-
this.show = true;
|
56
|
-
// prop: showLabel
|
57
|
-
// wether or not to show the label.
|
58
|
-
this.showLabel = true;
|
59
|
-
// prop: label
|
60
|
-
// label for the axis.
|
61
|
-
this.label = '';
|
62
|
-
// prop: fontFamily
|
63
|
-
// CSS spec for the font-family css attribute.
|
64
|
-
// Applies only to browsers supporting native font rendering in the
|
65
|
-
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
66
|
-
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
67
|
-
// prop: fontSize
|
68
|
-
// CSS spec for font size.
|
69
|
-
this.fontSize = '11pt';
|
70
|
-
// prop: fontWeight
|
71
|
-
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
72
|
-
this.fontWeight = 'normal';
|
73
|
-
// prop: fontStretch
|
74
|
-
// Multiplier to condense or expand font width.
|
75
|
-
// Applies only to browsers which don't support canvas native font rendering.
|
76
|
-
this.fontStretch = 1.0;
|
77
|
-
// prop: textColor
|
78
|
-
// css spec for the color attribute.
|
79
|
-
this.textColor = '#666666';
|
80
|
-
// prop: enableFontSupport
|
81
|
-
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
82
|
-
// If true, label will be drawn with canvas tag native support for fonts.
|
83
|
-
// If false, label will be drawn with Hershey font metrics.
|
84
|
-
this.enableFontSupport = true;
|
85
|
-
// prop: pt2px
|
86
|
-
// Point to pixel scaling factor, used for computing height of bounding box
|
87
|
-
// around a label. The labels text renderer has a default setting of 1.4, which
|
88
|
-
// should be suitable for most fonts. Leave as null to use default. If tops of
|
89
|
-
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
90
|
-
// This is an issue only with the native font renderering capabilities of Mozilla
|
91
|
-
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
92
|
-
this.pt2px = null;
|
93
|
-
|
94
|
-
this._elem;
|
95
|
-
this._ctx;
|
96
|
-
this._plotWidth;
|
97
|
-
this._plotHeight;
|
98
|
-
this._plotDimensions = {height:null, width:null};
|
99
|
-
|
100
|
-
$.extend(true, this, options);
|
101
|
-
|
102
|
-
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
103
|
-
this.angle = -90;
|
104
|
-
}
|
105
|
-
|
106
|
-
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
107
|
-
if (this.pt2px) {
|
108
|
-
ropts.pt2px = this.pt2px;
|
109
|
-
}
|
110
|
-
|
111
|
-
if (this.enableFontSupport) {
|
112
|
-
if ($.jqplot.support_canvas_text()) {
|
113
|
-
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
114
|
-
}
|
115
|
-
|
116
|
-
else {
|
117
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
118
|
-
}
|
119
|
-
}
|
120
|
-
else {
|
121
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
122
|
-
}
|
123
|
-
};
|
124
|
-
|
125
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
126
|
-
$.extend(true, this, options);
|
127
|
-
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
128
|
-
};
|
129
|
-
|
130
|
-
// return width along the x axis
|
131
|
-
// will check first to see if an element exists.
|
132
|
-
// if not, will return the computed text box width.
|
133
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
134
|
-
if (this._elem) {
|
135
|
-
return this._elem.outerWidth(true);
|
136
|
-
}
|
137
|
-
else {
|
138
|
-
var tr = this._textRenderer;
|
139
|
-
var l = tr.getWidth(ctx);
|
140
|
-
var h = tr.getHeight(ctx);
|
141
|
-
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
142
|
-
return w;
|
143
|
-
}
|
144
|
-
};
|
145
|
-
|
146
|
-
// return height along the y axis.
|
147
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
148
|
-
if (this._elem) {
|
149
|
-
return this._elem.outerHeight(true);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
var tr = this._textRenderer;
|
153
|
-
var l = tr.getWidth(ctx);
|
154
|
-
var h = tr.getHeight(ctx);
|
155
|
-
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
156
|
-
return w;
|
157
|
-
}
|
158
|
-
};
|
159
|
-
|
160
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
161
|
-
var a = this.angle * Math.PI/180;
|
162
|
-
return a;
|
163
|
-
};
|
164
|
-
|
165
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx, plot) {
|
166
|
-
// Memory Leaks patch
|
167
|
-
if (this._elem) {
|
168
|
-
if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
|
169
|
-
window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
|
170
|
-
}
|
171
|
-
|
172
|
-
this._elem.emptyForce();
|
173
|
-
this._elem = null;
|
174
|
-
}
|
175
|
-
|
176
|
-
// create a canvas here, but can't draw on it untill it is appended
|
177
|
-
// to dom for IE compatability.
|
178
|
-
var elem = plot.canvasManager.getCanvas();
|
179
|
-
|
180
|
-
this._textRenderer.setText(this.label, ctx);
|
181
|
-
var w = this.getWidth(ctx);
|
182
|
-
var h = this.getHeight(ctx);
|
183
|
-
elem.width = w;
|
184
|
-
elem.height = h;
|
185
|
-
elem.style.width = w;
|
186
|
-
elem.style.height = h;
|
187
|
-
|
188
|
-
elem = plot.canvasManager.initCanvas(elem);
|
189
|
-
|
190
|
-
this._elem = $(elem);
|
191
|
-
this._elem.css({ position: 'absolute'});
|
192
|
-
this._elem.addClass('jqplot-'+this.axis+'-label');
|
193
|
-
|
194
|
-
elem = null;
|
195
|
-
return this._elem;
|
196
|
-
};
|
197
|
-
|
198
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
199
|
-
this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
|
200
|
-
};
|
201
|
-
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
(function($) {
|
31
|
+
/**
|
32
|
+
* Class: $.jqplot.CanvasAxisLabelRenderer
|
33
|
+
* Renderer to draw axis labels with a canvas element to support advanced
|
34
|
+
* featrues such as rotated text. This renderer uses a separate rendering engine
|
35
|
+
* to draw the text on the canvas. Two modes of rendering the text are available.
|
36
|
+
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
37
|
+
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
38
|
+
* You do so by setting the "enableFontSupport" option to true.
|
39
|
+
*
|
40
|
+
* Browsers lacking native font support will have the text drawn on the canvas
|
41
|
+
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
42
|
+
* non-supporting browsers will still render with the Hershey font.
|
43
|
+
*
|
44
|
+
*/
|
45
|
+
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
46
|
+
// Group: Properties
|
47
|
+
|
48
|
+
// prop: angle
|
49
|
+
// angle of text, measured clockwise from x axis.
|
50
|
+
this.angle = 0;
|
51
|
+
// name of the axis associated with this tick
|
52
|
+
this.axis;
|
53
|
+
// prop: show
|
54
|
+
// wether or not to show the tick (mark and label).
|
55
|
+
this.show = true;
|
56
|
+
// prop: showLabel
|
57
|
+
// wether or not to show the label.
|
58
|
+
this.showLabel = true;
|
59
|
+
// prop: label
|
60
|
+
// label for the axis.
|
61
|
+
this.label = '';
|
62
|
+
// prop: fontFamily
|
63
|
+
// CSS spec for the font-family css attribute.
|
64
|
+
// Applies only to browsers supporting native font rendering in the
|
65
|
+
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
66
|
+
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
67
|
+
// prop: fontSize
|
68
|
+
// CSS spec for font size.
|
69
|
+
this.fontSize = '11pt';
|
70
|
+
// prop: fontWeight
|
71
|
+
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
72
|
+
this.fontWeight = 'normal';
|
73
|
+
// prop: fontStretch
|
74
|
+
// Multiplier to condense or expand font width.
|
75
|
+
// Applies only to browsers which don't support canvas native font rendering.
|
76
|
+
this.fontStretch = 1.0;
|
77
|
+
// prop: textColor
|
78
|
+
// css spec for the color attribute.
|
79
|
+
this.textColor = '#666666';
|
80
|
+
// prop: enableFontSupport
|
81
|
+
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
82
|
+
// If true, label will be drawn with canvas tag native support for fonts.
|
83
|
+
// If false, label will be drawn with Hershey font metrics.
|
84
|
+
this.enableFontSupport = true;
|
85
|
+
// prop: pt2px
|
86
|
+
// Point to pixel scaling factor, used for computing height of bounding box
|
87
|
+
// around a label. The labels text renderer has a default setting of 1.4, which
|
88
|
+
// should be suitable for most fonts. Leave as null to use default. If tops of
|
89
|
+
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
90
|
+
// This is an issue only with the native font renderering capabilities of Mozilla
|
91
|
+
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
92
|
+
this.pt2px = null;
|
93
|
+
|
94
|
+
this._elem;
|
95
|
+
this._ctx;
|
96
|
+
this._plotWidth;
|
97
|
+
this._plotHeight;
|
98
|
+
this._plotDimensions = {height:null, width:null};
|
99
|
+
|
100
|
+
$.extend(true, this, options);
|
101
|
+
|
102
|
+
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
103
|
+
this.angle = -90;
|
104
|
+
}
|
105
|
+
|
106
|
+
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
107
|
+
if (this.pt2px) {
|
108
|
+
ropts.pt2px = this.pt2px;
|
109
|
+
}
|
110
|
+
|
111
|
+
if (this.enableFontSupport) {
|
112
|
+
if ($.jqplot.support_canvas_text()) {
|
113
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
114
|
+
}
|
115
|
+
|
116
|
+
else {
|
117
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
126
|
+
$.extend(true, this, options);
|
127
|
+
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
128
|
+
};
|
129
|
+
|
130
|
+
// return width along the x axis
|
131
|
+
// will check first to see if an element exists.
|
132
|
+
// if not, will return the computed text box width.
|
133
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
134
|
+
if (this._elem) {
|
135
|
+
return this._elem.outerWidth(true);
|
136
|
+
}
|
137
|
+
else {
|
138
|
+
var tr = this._textRenderer;
|
139
|
+
var l = tr.getWidth(ctx);
|
140
|
+
var h = tr.getHeight(ctx);
|
141
|
+
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
142
|
+
return w;
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
// return height along the y axis.
|
147
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
148
|
+
if (this._elem) {
|
149
|
+
return this._elem.outerHeight(true);
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
var tr = this._textRenderer;
|
153
|
+
var l = tr.getWidth(ctx);
|
154
|
+
var h = tr.getHeight(ctx);
|
155
|
+
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
156
|
+
return w;
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
161
|
+
var a = this.angle * Math.PI/180;
|
162
|
+
return a;
|
163
|
+
};
|
164
|
+
|
165
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx, plot) {
|
166
|
+
// Memory Leaks patch
|
167
|
+
if (this._elem) {
|
168
|
+
if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
|
169
|
+
window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
|
170
|
+
}
|
171
|
+
|
172
|
+
this._elem.emptyForce();
|
173
|
+
this._elem = null;
|
174
|
+
}
|
175
|
+
|
176
|
+
// create a canvas here, but can't draw on it untill it is appended
|
177
|
+
// to dom for IE compatability.
|
178
|
+
var elem = plot.canvasManager.getCanvas();
|
179
|
+
|
180
|
+
this._textRenderer.setText(this.label, ctx);
|
181
|
+
var w = this.getWidth(ctx);
|
182
|
+
var h = this.getHeight(ctx);
|
183
|
+
elem.width = w;
|
184
|
+
elem.height = h;
|
185
|
+
elem.style.width = w;
|
186
|
+
elem.style.height = h;
|
187
|
+
|
188
|
+
elem = plot.canvasManager.initCanvas(elem);
|
189
|
+
|
190
|
+
this._elem = $(elem);
|
191
|
+
this._elem.css({ position: 'absolute'});
|
192
|
+
this._elem.addClass('jqplot-'+this.axis+'-label');
|
193
|
+
|
194
|
+
elem = null;
|
195
|
+
return this._elem;
|
196
|
+
};
|
197
|
+
|
198
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
199
|
+
this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
|
200
|
+
};
|
201
|
+
|
202
202
|
})(jQuery);
|