jquery_cheats 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/README.md +1 -0
  2. data/app/assets/javascripts/jquery_cheats/jquery_cheats.js +1 -1
  3. data/app/assets/javascripts/jquery_cheats/replacementContextMenu.js +62 -0
  4. data/jquery_cheats.gemspec +2 -2
  5. data/lib/jquery_cheats/jquery_cheats.rb +58 -0
  6. data/vendor/assets/javascripts/jqplot/excanvas.js +1438 -0
  7. data/vendor/assets/javascripts/jqplot/jquery.jqplot.js +10901 -0
  8. data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.js +312 -0
  9. data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.min.js +57 -0
  10. data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.js +747 -0
  11. data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.min.js +57 -0
  12. data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.js +234 -0
  13. data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.min.js +57 -0
  14. data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.js +754 -0
  15. data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.min.js +57 -0
  16. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js +202 -0
  17. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js +57 -0
  18. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.js +242 -0
  19. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js +57 -0
  20. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.js +864 -0
  21. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.min.js +57 -0
  22. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.js +448 -0
  23. data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.min.js +57 -0
  24. data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.js +636 -0
  25. data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.min.js +57 -0
  26. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.js +115 -0
  27. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.min.js +57 -0
  28. data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.js +1093 -0
  29. data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.min.js +57 -0
  30. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.js +702 -0
  31. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.min.js +57 -0
  32. data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.js +800 -0
  33. data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.min.js +57 -0
  34. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.js +224 -0
  35. data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.min.js +57 -0
  36. data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.js +241 -0
  37. data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js +57 -0
  38. data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.js +938 -0
  39. data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.min.js +57 -0
  40. data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.js +454 -0
  41. data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.min.js +57 -0
  42. data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.js +475 -0
  43. data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.min.js +57 -0
  44. data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.js +528 -0
  45. data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.min.js +57 -0
  46. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.js +610 -0
  47. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js +57 -0
  48. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.js +436 -0
  49. data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.min.js +57 -0
  50. data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.js +1029 -0
  51. data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.min.js +57 -0
  52. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.js +372 -0
  53. data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.min.js +57 -0
  54. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.js +899 -0
  55. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.min.js +57 -0
  56. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.js +362 -0
  57. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.min.js +57 -0
  58. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.js +730 -0
  59. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js +57 -0
  60. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.js +423 -0
  61. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.min.js +57 -0
  62. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.js +490 -0
  63. data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.min.js +57 -0
  64. data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.js +222 -0
  65. data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.min.js +57 -0
  66. data/vendor/assets/javascripts/jquery_cheats/spinjs/spin.min.js +1 -1
  67. data/vendor/assets/stylesheets/jquery.jqplot.css +259 -0
  68. metadata +66 -3
@@ -0,0 +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
+ */
57
+ (function(e){e.jqplot.PyramidAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PyramidAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PyramidAxisRenderer.prototype.constructor=e.jqplot.PyramidAxisRenderer;e.jqplot.PyramidAxisRenderer.prototype.init=function(f){this.position=null;this.drawBaseline=true;this.baselineWidth=null;this.baselineColor=null;this.tickSpacingFactor=25;this._type="pyramid";this._splitAxis=false;this._splitLength=null;this.category=false;this._autoFormatString="";this._overrideFormatString=false;e.extend(true,this,f);this.renderer.options=f;this.resetDataBounds=this.renderer.resetDataBounds;this.resetDataBounds()};e.jqplot.PyramidAxisRenderer.prototype.resetDataBounds=function(){var h=this._dataBounds;h.min=null;h.max=null;var g;for(var m=0;m<this._series.length;m++){var n=this._series[m];var o=n._plotData;for(var k=0,f=o.length;k<f;k++){if(this.name.charAt(0)==="x"){g=o[k][1];if((g!==null&&g<h.min)||h.min===null){h.min=g}if((g!==null&&g>h.max)||h.max===null){h.max=g}}else{g=o[k][0];if((g!==null&&g<h.min)||h.min===null){h.min=g}if((g!==null&&g>h.max)||h.max===null){h.max=g}}}}};e.jqplot.PyramidAxisRenderer.prototype.draw=function(f,n){if(this.show){this.renderer.createTicks.call(this,n);var m=0;var g;if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=e(document.createElement("div"));this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("position","absolute");if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var l=this._label.draw(f,n);l.appendTo(this._elem);l=null}var k=this._ticks;var j;for(var h=0;h<k.length;h++){j=k[h];if(j.show&&j.showLabel&&(!j.isMinorTick)){this._elem.append(j.draw(f,n))}}j=null;k=null}return this._elem};var b=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var d={};for(var c=0,a=b.length;c<a;c++){d[b[c]]=b[c]}e.jqplot.PyramidAxisRenderer.prototype.createTicks=function(D){var J=this.ticks;var M=this._dataBounds;var E;var K;var B;var G;var y;var n;var k;var h;var H;var C;var x;var L=this.min;var N=this.max;var q;var v;var m;var g;var j;var O;var A;var F;var r;var P;var z=null;var I;if(J.length){for(H=0,C=J.length;H<C;H++){q=J[H];v=new this.tickRenderer(this.tickOptions);if(e.isArray(q)){v.value=q[0];v.label=q[1];v.setTick(q[0],this.name);this._ticks.push(v)}else{if(e.isPlainObject(q)){e.extend(true,v,q);v.axis=this.name;this._ticks.push(v)}else{if(typeof q==="string"){P=H+D.defaultAxisStart}else{P=q}v.value=P;v.label=q;v.axis=this.name;this._ticks.push(v)}}}this.numberTicks=J.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1);if(this._options.tickInterval){var o=this._options.tickInterval;for(H=0;H<this.numberTicks;H++){if(H%o!==0){this._ticks[H].isMinorTick=true}}}else{E=(this.name.charAt(0)==="x")?this._plotDimensions.width:this._plotDimensions.height;r=Math.round(2+E/this.tickSpacingFactor);if(this.numberTicks>r){I=this.numberTicks-1;for(H=2;H<I;H++){if(I%H===0&&I/H<r){z=H-1;break}}if(z!==null){var p=1;for(H=1,C=this._ticks.length;H<C;H++){if(p<=z){this._ticks[H].show=false;p+=1}else{p=1}}}}}I=[];if(this.category){this._ticks[0].showGridline=false;this._ticks[0].showMark=false;for(H=this._ticks.length-1;H>0;H--){v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[H-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks[H].showGridline=false;this._ticks[H].showMark=false;this._ticks.splice(H,0,v)}v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[0].value-this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.unshift(v);v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[this._ticks.length-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.push(v);this.tickInterval=this.tickInterval/2;this.numberTicks=this._ticks.length;this.min=this._ticks[0].value;this.max=this._ticks[this._ticks.length-1].value}}else{if(this.name.charAt(0)==="x"){E=this._plotDimensions.width;var w=Math.max(M.max,Math.abs(M.min));var u=Math.min(M.min,-w);B=u;G=w;y=G-B;if(this.tickOptions==null||!this.tickOptions.formatString){this._overrideFormatString=true}m=30;g=Math.max(E,m+1);j=(g-m)/300;O=e.jqplot.LinearTickGenerator(B,G,j);console.log(B,G,j,O);console.log(O[0].toString(),O[1].toString());A=B+y*(this.padMin-1);F=G-y*(this.padMax-1);if(B<A||G>F){A=B-y*(this.padMin-1);F=G+y*(this.padMax-1);O=e.jqplot.LinearTickGenerator(A,F,j);console.log(A,F,j,O)}this.min=O[0];this.max=O[1];this.numberTicks=O[2];this._autoFormatString=O[3];this.tickInterval=O[4]}else{E=this._plotDimensions.height;B=M.min;G=M.max;x=this._series[0];this._ticks=[];y=G-B;if(d[y]){y+=1;G+=1}this.max=G;this.min=B;r=Math.round(2+E/this.tickSpacingFactor);if(y+1<=r){this.numberTicks=y+1;this.tickInterval=1}else{for(var H=r;H>1;H--){if(y/(H-1)===Math.round(y/(H-1))){this.numberTicks=H;this.tickInterval=y/(H-1);break}}}}if(this._overrideFormatString&&this._autoFormatString!=""){this.tickOptions=this.tickOptions||{};this.tickOptions.formatString=this._autoFormatString}var f;for(H=0;H<this.numberTicks;H++){this.tickOptions.axis=this.name;f=this.min+this.tickInterval*H;if(this.name.charAt(0)==="x"){f=Math.abs(f)}this.tickOptions.value=this.min+this.tickInterval*H;v=new this.tickRenderer(this.tickOptions);v.label=v.prefix+v.formatter(v.formatString,f);this._ticks.push(v);if(this.name.charAt(0)==="x"&&D.axes.yMidAxis.show&&this.tickOptions.value===0){this._splitAxis=true;this._splitLength=D.axes.yMidAxis.getWidth();v=new this.tickRenderer(this.tickOptions);this._ticks.push(v);v.value=this.max/2000}}v=null}};e.jqplot.PyramidAxisRenderer.prototype.set=function(){var o=0;var j;var g=0;var n=0;var m;var l;var k;var f=(this._label==null)?false:this._label.show;if(this.show){l=this._ticks;a=l.length;for(m=0;m<a;m++){k=l[m];if(!k._breakTick&&k.show&&k.showLabel&&!k.isMinorTick){if(this.name.charAt(0)==="x"){j=k._elem.outerHeight(true)}else{j=k._elem.outerWidth(true)}if(j>o){o=j}}}if(this.name==="yMidAxis"){for(m=0;m<a;m++){k=l[m];if(k._elem){j=(o-k._elem.outerWidth(true))/2;k._elem.css("left",j)}}}k=null;l=null;if(f){g=this._label._elem.outerWidth(true);n=this._label._elem.outerHeight(true)}if(this.name==="xaxis"){o=o+n;this._elem.css({height:o+"px",left:"0px",bottom:"0px"})}else{if(this.name==="x2axis"){o=o+n;this._elem.css({height:o+"px",left:"0px",top:"0px"})}else{if(this.name==="yaxis"){o=o+g;this._elem.css({width:o+"px",left:"0px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css("width",g+"px")}}else{if(this.name==="yMidAxis"){var j=o/2-g/2;this._elem.css({width:o+"px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css({width:g,left:j,top:0})}}else{o=o+g;this._elem.css({width:o+"px",right:"0px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css("width",g+"px")}}}}}}};e.jqplot.PyramidAxisRenderer.prototype.pack=function(j,g){j=j||{};g=g||this._offsets;var B=this._ticks;var v=this.max;var u=this.min;var o=g.max;var m=g.min;var r=(this._label==null)?false:this._label.show;for(var s in j){this._elem.css(s,j[s])}this._offsets=g;var k=o-m;var l=v-u;var z=this._splitLength;if(this._splitAxis){k-=this._splitLength;this.p2u=function(h){return(h-m)*l/k+u};this.u2p=function(h){if(h<=0){return(h-u)*k/l+m}else{return(h-u)*k/l+m+z}};this.series_u2p=function(h){if(h<=0){return(h-u)*k/l}else{return(h-u)*k/l+z}};this.series_p2u=function(h){return h*l/k+u}}else{this.p2u=function(h){return(h-m)*l/k+u};this.u2p=function(h){return(h-u)*k/l+m};if(this.name.charAt(0)==="x"){this.series_u2p=function(h){return(h-u)*k/l};this.series_p2u=function(h){return h*l/k+u}}else{this.series_u2p=function(h){return(h-v)*k/l};this.series_p2u=function(h){return h*l/k+v}}}if(this.show){if(this.name.charAt(0)==="x"){for(var x=0;x<B.length;x++){var q=B[x];if(q.show&&q.showLabel){var f;if(q.constructor==e.jqplot.CanvasAxisTickRenderer&&q.angle){var A=(this.name=="xaxis")?1:-1;switch(q.labelPosition){case"auto":if(A*q.angle<0){f=-q.getWidth()+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2}else{f=-q._textRenderer.height*Math.sin(q._textRenderer.angle)/2}break;case"end":f=-q.getWidth()+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break;case"start":f=-q._textRenderer.height*Math.sin(q._textRenderer.angle)/2;break;case"middle":f=-q.getWidth()/2+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break;default:f=-q.getWidth()/2+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break}}else{f=-q.getWidth()/2}var C=this.u2p(q.value)+f+"px";q._elem.css("left",C);q.pack()}}if(r){var n=this._label._elem.outerWidth(true);this._label._elem.css("left",m+k/2-n/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}}else{for(var x=0;x<B.length;x++){var q=B[x];if(q.show&&q.showLabel&&!q.isMinorTick){var f;if(q.constructor==e.jqplot.CanvasAxisTickRenderer&&q.angle){var A=(this.name=="yaxis")?1:-1;switch(q.labelPosition){case"auto":case"end":if(A*q.angle<0){f=-q._textRenderer.height*Math.cos(-q._textRenderer.angle)/2}else{f=-q.getHeight()+q._textRenderer.height*Math.cos(q._textRenderer.angle)/2}break;case"start":if(q.angle>0){f=-q._textRenderer.height*Math.cos(-q._textRenderer.angle)/2}else{f=-q.getHeight()+q._textRenderer.height*Math.cos(q._textRenderer.angle)/2}break;case"middle":f=-q.getHeight()/2;break;default:f=-q.getHeight()/2;break}}else{f=-q.getHeight()/2}var C=this.u2p(q.value)+f+"px";q._elem.css("top",C);q.pack()}}if(r){var y=this._label._elem.outerHeight(true);if(this.name!=="yMidAxis"){this._label._elem.css("top",o-k/2-y/2+"px")}if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{if(this.name!=="yMidAxis"){this._label._elem.css("right","0px")}}this._label.pack()}}}B=null}})(jQuery);
@@ -0,0 +1,423 @@
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
+ // Class: $.jqplot.CanvasGridRenderer
32
+ // The default jqPlot grid renderer, creating a grid on a canvas element.
33
+ // The renderer has no additional options beyond the <Grid> class.
34
+ $.jqplot.PyramidGridRenderer = function(){
35
+ $.jqplot.CanvasGridRenderer.call(this);
36
+ };
37
+
38
+ $.jqplot.PyramidGridRenderer.prototype = new $.jqplot.CanvasGridRenderer();
39
+ $.jqplot.PyramidGridRenderer.prototype.constructor = $.jqplot.PyramidGridRenderer;
40
+
41
+ // called with context of Grid object
42
+ $.jqplot.CanvasGridRenderer.prototype.init = function(options) {
43
+ this._ctx;
44
+ this.plotBands = {
45
+ show: false,
46
+ color: 'rgb(230, 219, 179)',
47
+ axis: 'y',
48
+ start: null,
49
+ interval: 10
50
+ };
51
+ $.extend(true, this, options);
52
+ // set the shadow renderer options
53
+ var sopts = {lineJoin:'miter', lineCap:'round', fill:false, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.shadowWidth, closePath:false, strokeStyle:this.shadowColor};
54
+ this.renderer.shadowRenderer.init(sopts);
55
+ };
56
+
57
+ $.jqplot.PyramidGridRenderer.prototype.draw = function() {
58
+ this._ctx = this._elem.get(0).getContext("2d");
59
+ var ctx = this._ctx;
60
+ var axes = this._axes;
61
+ var xp = axes.xaxis.u2p;
62
+ var yp = axes.yMidAxis.u2p;
63
+ var xnudge = axes.xaxis.max/1000.0;
64
+ var xp0 = xp(0);
65
+ var xpn = xp(xnudge);
66
+ var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis','yMidAxis'];
67
+ // Add the grid onto the grid canvas. This is the bottom most layer.
68
+ ctx.save();
69
+ ctx.clearRect(0, 0, this._plotDimensions.width, this._plotDimensions.height);
70
+ ctx.fillStyle = this.backgroundColor || this.background;
71
+
72
+ ctx.fillRect(this._left, this._top, this._width, this._height);
73
+
74
+ if (this.plotBands.show) {
75
+ ctx.save();
76
+ var pb = this.plotBands;
77
+ ctx.fillStyle = pb.color;
78
+ var axis;
79
+ var x, y, w, h;
80
+ // find axis to work with
81
+ if (pb.axis.charAt(0) === 'x') {
82
+ if (axes.xaxis.show) {
83
+ axis = axes.xaxis;
84
+ }
85
+ }
86
+ else if (pb.axis.charAt(0) === 'y') {
87
+ if (axes.yaxis.show) {
88
+ axis = axes.yaxis;
89
+ }
90
+ else if (axes.y2axis.show) {
91
+ axis = axes.y2axis;
92
+ }
93
+ else if (axes.yMidAxis.show) {
94
+ axis = axes.yMidAxis;
95
+ }
96
+ }
97
+
98
+ if (axis !== undefined) {
99
+ // draw some rectangles
100
+ var start = pb.start;
101
+ if (start === null) {
102
+ start = axis.min;
103
+ }
104
+ for (var i = start; i < axis.max; i += 2 * pb.interval) {
105
+ if (axis.name.charAt(0) === 'y') {
106
+ x = this._left;
107
+ y = axis.series_u2p(i + pb.interval) + this._top;
108
+ w = this._right - this._left;
109
+ h = axis.series_u2p(start) - axis.series_u2p(start + pb.interval);
110
+ ctx.fillRect(x, y, w, h);
111
+ }
112
+ // else {
113
+ // y = 0;
114
+ // x = axis.series_u2p(i);
115
+ // h = this._height;
116
+ // w = axis.series_u2p(start + pb.interval) - axis.series_u2p(start);
117
+ // }
118
+
119
+ }
120
+ }
121
+ ctx.restore();
122
+ }
123
+
124
+ ctx.save();
125
+ ctx.lineJoin = 'miter';
126
+ ctx.lineCap = 'butt';
127
+ ctx.lineWidth = this.gridLineWidth;
128
+ ctx.strokeStyle = this.gridLineColor;
129
+ var b, e, s, m;
130
+ for (var i=5; i>0; i--) {
131
+ var name = ax[i-1];
132
+ var axis = axes[name];
133
+ var ticks = axis._ticks;
134
+ var numticks = ticks.length;
135
+ if (axis.show) {
136
+ if (axis.drawBaseline) {
137
+ var bopts = {};
138
+ if (axis.baselineWidth !== null) {
139
+ bopts.lineWidth = axis.baselineWidth;
140
+ }
141
+ if (axis.baselineColor !== null) {
142
+ bopts.strokeStyle = axis.baselineColor;
143
+ }
144
+ switch (name) {
145
+ case 'xaxis':
146
+ if (axes.yMidAxis.show) {
147
+ drawLine (this._left, this._bottom, xp0, this._bottom, bopts);
148
+ drawLine (xpn, this._bottom, this._right, this._bottom, bopts);
149
+ }
150
+ else {
151
+ drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
152
+ }
153
+ break;
154
+ case 'yaxis':
155
+ drawLine (this._left, this._bottom, this._left, this._top, bopts);
156
+ break;
157
+ case 'yMidAxis':
158
+ drawLine(xp0, this._bottom, xp0, this._top, bopts);
159
+ drawLine(xpn, this._bottom, xpn, this._top, bopts);
160
+ break;
161
+ case 'x2axis':
162
+ if (axes.yMidAxis.show) {
163
+ drawLine (this._left, this._top, xp0, this._top, bopts);
164
+ drawLine (xpn, this._top, this._right, this._top, bopts);
165
+ }
166
+ else {
167
+ drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
168
+ }
169
+ break;
170
+ case 'y2axis':
171
+ drawLine (this._right, this._bottom, this._right, this._top, bopts);
172
+ break;
173
+
174
+ }
175
+ }
176
+ for (var j=numticks; j>0; j--) {
177
+ var t = ticks[j-1];
178
+ if (t.show) {
179
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
180
+ switch (name) {
181
+ case 'xaxis':
182
+ // draw the grid line if we should
183
+ if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
184
+ drawLine(pos, this._top, pos, this._bottom);
185
+ }
186
+
187
+ // draw the mark
188
+ if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
189
+ s = t.markSize;
190
+ m = t.mark;
191
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
192
+ switch (m) {
193
+ case 'outside':
194
+ b = this._bottom;
195
+ e = this._bottom+s;
196
+ break;
197
+ case 'inside':
198
+ b = this._bottom-s;
199
+ e = this._bottom;
200
+ break;
201
+ case 'cross':
202
+ b = this._bottom-s;
203
+ e = this._bottom+s;
204
+ break;
205
+ default:
206
+ b = this._bottom;
207
+ e = this._bottom+s;
208
+ break;
209
+ }
210
+ // draw the shadow
211
+ if (this.shadow) {
212
+ this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
213
+ }
214
+ // draw the line
215
+ drawLine(pos, b, pos, e);
216
+ }
217
+ break;
218
+ case 'yaxis':
219
+ // draw the grid line
220
+ if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
221
+ drawLine(this._right, pos, this._left, pos);
222
+ }
223
+
224
+ // draw the mark
225
+ if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
226
+ s = t.markSize;
227
+ m = t.mark;
228
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
229
+ switch (m) {
230
+ case 'outside':
231
+ b = this._left-s;
232
+ e = this._left;
233
+ break;
234
+ case 'inside':
235
+ b = this._left;
236
+ e = this._left+s;
237
+ break;
238
+ case 'cross':
239
+ b = this._left-s;
240
+ e = this._left+s;
241
+ break;
242
+ default:
243
+ b = this._left-s;
244
+ e = this._left;
245
+ break;
246
+ }
247
+ // draw the shadow
248
+ if (this.shadow) {
249
+ this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
250
+ }
251
+ drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
252
+ }
253
+ break;
254
+ case 'yMidAxis':
255
+ // draw the grid line
256
+ if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
257
+ drawLine(this._left, pos, xp0, pos);
258
+ drawLine(xpn, pos, this._right, pos);
259
+ }
260
+ // draw the mark
261
+ if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
262
+ s = t.markSize;
263
+ m = t.mark;
264
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
265
+
266
+ b = xp0;
267
+ e = xp0 + s;
268
+ // draw the shadow
269
+ if (this.shadow) {
270
+ this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
271
+ }
272
+ drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
273
+
274
+ b = xpn - s;
275
+ e = xpn;
276
+ // draw the shadow
277
+ if (this.shadow) {
278
+ this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
279
+ }
280
+ drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
281
+ }
282
+ break;
283
+ case 'x2axis':
284
+ // draw the grid line
285
+ if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
286
+ drawLine(pos, this._bottom, pos, this._top);
287
+ }
288
+
289
+ // draw the mark
290
+ if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
291
+ s = t.markSize;
292
+ m = t.mark;
293
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
294
+ switch (m) {
295
+ case 'outside':
296
+ b = this._top-s;
297
+ e = this._top;
298
+ break;
299
+ case 'inside':
300
+ b = this._top;
301
+ e = this._top+s;
302
+ break;
303
+ case 'cross':
304
+ b = this._top-s;
305
+ e = this._top+s;
306
+ break;
307
+ default:
308
+ b = this._top-s;
309
+ e = this._top;
310
+ break;
311
+ }
312
+ // draw the shadow
313
+ if (this.shadow) {
314
+ this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
315
+ }
316
+ drawLine(pos, b, pos, e);
317
+ }
318
+ break;
319
+ case 'y2axis':
320
+ // draw the grid line
321
+ if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
322
+ drawLine(this._left, pos, this._right, pos);
323
+ }
324
+
325
+ // draw the mark
326
+ if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
327
+ s = t.markSize;
328
+ m = t.mark;
329
+ var pos = Math.round(axis.u2p(t.value)) + 0.5;
330
+ switch (m) {
331
+ case 'outside':
332
+ b = this._right;
333
+ e = this._right+s;
334
+ break;
335
+ case 'inside':
336
+ b = this._right-s;
337
+ e = this._right;
338
+ break;
339
+ case 'cross':
340
+ b = this._right-s;
341
+ e = this._right+s;
342
+ break;
343
+ default:
344
+ b = this._right;
345
+ e = this._right+s;
346
+ break;
347
+ }
348
+ // draw the shadow
349
+ if (this.shadow) {
350
+ this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
351
+ }
352
+ drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
353
+ }
354
+ break;
355
+ default:
356
+ break;
357
+ }
358
+ }
359
+ }
360
+ t = null;
361
+ }
362
+ axis = null;
363
+ ticks = null;
364
+ }
365
+
366
+ ctx.restore();
367
+
368
+ function drawLine(bx, by, ex, ey, opts) {
369
+ ctx.save();
370
+ opts = opts || {};
371
+ if (opts.lineWidth == null || opts.lineWidth != 0){
372
+ $.extend(true, ctx, opts);
373
+ ctx.beginPath();
374
+ ctx.moveTo(bx, by);
375
+ ctx.lineTo(ex, ey);
376
+ ctx.stroke();
377
+ }
378
+ ctx.restore();
379
+ }
380
+
381
+ if (this.shadow) {
382
+ if (axes.yMidAxis.show) {
383
+ var points = [[this._left, this._bottom], [xp0, this._bottom]];
384
+ this.renderer.shadowRenderer.draw(ctx, points);
385
+ var points = [[xpn, this._bottom], [this._right, this._bottom], [this._right, this._top]];
386
+ this.renderer.shadowRenderer.draw(ctx, points);
387
+ var points = [[xp0, this._bottom], [xp0, this._top]];
388
+ this.renderer.shadowRenderer.draw(ctx, points);
389
+ }
390
+ else {
391
+ var points = [[this._left, this._bottom], [this._right, this._bottom], [this._right, this._top]];
392
+ this.renderer.shadowRenderer.draw(ctx, points);
393
+ }
394
+ }
395
+ // Now draw border around grid. Use axis border definitions. start at
396
+ // upper left and go clockwise.
397
+ if (this.borderWidth != 0 && this.drawBorder) {
398
+ if (axes.yMidAxis.show) {
399
+ drawLine (this._left, this._top, xp0, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
400
+ drawLine (xpn, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
401
+ drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth});
402
+ drawLine (this._right, this._bottom, xpn, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
403
+ drawLine (xp0, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
404
+ drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
405
+ drawLine (xp0, this._bottom, xp0, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
406
+ drawLine (xpn, this._bottom, xpn, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
407
+ }
408
+ else {
409
+ drawLine (this._left, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
410
+ drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth});
411
+ drawLine (this._right, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
412
+ drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
413
+ }
414
+ }
415
+ // ctx.lineWidth = this.borderWidth;
416
+ // ctx.strokeStyle = this.borderColor;
417
+ // ctx.strokeRect(this._left, this._top, this._width, this._height);
418
+
419
+ ctx.restore();
420
+ ctx = null;
421
+ axes = null;
422
+ };
423
+ })(jQuery);