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(a){a.jqplot.PyramidGridRenderer=function(){a.jqplot.CanvasGridRenderer.call(this)};a.jqplot.PyramidGridRenderer.prototype=new a.jqplot.CanvasGridRenderer();a.jqplot.PyramidGridRenderer.prototype.constructor=a.jqplot.PyramidGridRenderer;a.jqplot.CanvasGridRenderer.prototype.init=function(c){this._ctx;this.plotBands={show:false,color:"rgb(230, 219, 179)",axis:"y",start:null,interval:10};a.extend(true,this,c);var b={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};this.renderer.shadowRenderer.init(b)};a.jqplot.PyramidGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var D=this._ctx;var G=this._axes;var q=G.xaxis.u2p;var J=G.yMidAxis.u2p;var l=G.xaxis.max/1000;var u=q(0);var f=q(l);var r=["xaxis","yaxis","x2axis","y2axis","yMidAxis"];D.save();D.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);D.fillStyle=this.backgroundColor||this.background;D.fillRect(this._left,this._top,this._width,this._height);if(this.plotBands.show){D.save();var c=this.plotBands;D.fillStyle=c.color;var d;var o,n,p,I;if(c.axis.charAt(0)==="x"){if(G.xaxis.show){d=G.xaxis}}else{if(c.axis.charAt(0)==="y"){if(G.yaxis.show){d=G.yaxis}else{if(G.y2axis.show){d=G.y2axis}else{if(G.yMidAxis.show){d=G.yMidAxis}}}}}if(d!==undefined){var g=c.start;if(g===null){g=d.min}for(var H=g;H<d.max;H+=2*c.interval){if(d.name.charAt(0)==="y"){o=this._left;n=d.series_u2p(H+c.interval)+this._top;p=this._right-this._left;I=d.series_u2p(g)-d.series_u2p(g+c.interval);D.fillRect(o,n,p,I)}}}D.restore()}D.save();D.lineJoin="miter";D.lineCap="butt";D.lineWidth=this.gridLineWidth;D.strokeStyle=this.gridLineColor;var L,K,A,C;for(var H=5;H>0;H--){var O=r[H-1];var d=G[O];var M=d._ticks;var B=M.length;if(d.show){if(d.drawBaseline){var N={};if(d.baselineWidth!==null){N.lineWidth=d.baselineWidth}if(d.baselineColor!==null){N.strokeStyle=d.baselineColor}switch(O){case"xaxis":if(G.yMidAxis.show){z(this._left,this._bottom,u,this._bottom,N);z(f,this._bottom,this._right,this._bottom,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"yaxis":z(this._left,this._bottom,this._left,this._top,N);break;case"yMidAxis":z(u,this._bottom,u,this._top,N);z(f,this._bottom,f,this._top,N);break;case"x2axis":if(G.yMidAxis.show){z(this._left,this._top,u,this._top,N);z(f,this._top,this._right,this._top,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"y2axis":z(this._right,this._bottom,this._right,this._top,N);break}}for(var E=B;E>0;E--){var v=M[E-1];if(v.show){var k=Math.round(d.u2p(v.value))+0.5;switch(O){case"xaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._top,k,this._bottom)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._bottom;K=this._bottom+A;break;case"inside":L=this._bottom-A;K=this._bottom;break;case"cross":L=this._bottom-A;K=this._bottom+A;break;default:L=this._bottom;K=this._bottom+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"yaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._right,k,this._left,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._left-A;K=this._left;break;case"inside":L=this._left;K=this._left+A;break;case"cross":L=this._left-A;K=this._left+A;break;default:L=this._left-A;K=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"yMidAxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,u,k);z(f,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;L=u;K=u+A;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor});L=f-A;K=f;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"x2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._bottom,k,this._top)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._top-A;K=this._top;break;case"inside":L=this._top;K=this._top+A;break;case"cross":L=this._top-A;K=this._top+A;break;default:L=this._top-A;K=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"y2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._right;K=this._right+A;break;case"inside":L=this._right-A;K=this._right;break;case"cross":L=this._right-A;K=this._right+A;break;default:L=this._right;K=this._right+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;default:break}}}v=null}d=null;M=null}D.restore();function z(j,i,e,b,h){D.save();h=h||{};if(h.lineWidth==null||h.lineWidth!=0){a.extend(true,D,h);D.beginPath();D.moveTo(j,i);D.lineTo(e,b);D.stroke()}D.restore()}if(this.shadow){if(G.yMidAxis.show){var F=[[this._left,this._bottom],[u,this._bottom]];this.renderer.shadowRenderer.draw(D,F);var F=[[f,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F);var F=[[u,this._bottom],[u,this._top]];this.renderer.shadowRenderer.draw(D,F)}else{var F=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F)}}if(this.borderWidth!=0&&this.drawBorder){if(G.yMidAxis.show){z(this._left,this._top,u,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(f,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,f,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(u,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(u,this._bottom,u,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(f,this._bottom,f,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}else{z(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}}D.restore();D=null;G=null}})(jQuery);
@@ -0,0 +1,490 @@
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
+ // Need to ensure pyramid axis and grid renderers are loaded.
33
+ // You should load these with script tags in the html head, that is more efficient
34
+ // as the browser will cache the request.
35
+ // Note, have to block with synchronous request in order to execute bar renderer code.
36
+ if ($.jqplot.PyramidAxisRenderer === undefined) {
37
+ $.ajax({
38
+ url: $.jqplot.pluginLocation + 'jqplot.pyramidAxisRenderer.js',
39
+ dataType: "script",
40
+ async: false
41
+ });
42
+ }
43
+
44
+ if ($.jqplot.PyramidGridRenderer === undefined) {
45
+ $.ajax({
46
+ url: $.jqplot.pluginLocation + 'jqplot.pyramidGridRenderer.js',
47
+ dataType: "script",
48
+ async: false
49
+ });
50
+ }
51
+
52
+ $.jqplot.PyramidRenderer = function(){
53
+ $.jqplot.LineRenderer.call(this);
54
+ };
55
+
56
+ $.jqplot.PyramidRenderer.prototype = new $.jqplot.LineRenderer();
57
+ $.jqplot.PyramidRenderer.prototype.constructor = $.jqplot.PyramidRenderer;
58
+
59
+ // called with scope of a series
60
+ $.jqplot.PyramidRenderer.prototype.init = function(options, plot) {
61
+ options = options || {};
62
+ this._type = 'pyramid';
63
+ // Group: Properties
64
+ //
65
+ // prop: barPadding
66
+ this.barPadding = 10;
67
+ this.barWidth = null;
68
+ // prop: fill
69
+ // True to fill the bars.
70
+ this.fill = true;
71
+ // prop: highlightMouseOver
72
+ // True to highlight slice when moused over.
73
+ // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
74
+ this.highlightMouseOver = true;
75
+ // prop: highlightMouseDown
76
+ // True to highlight when a mouse button is pressed over a slice.
77
+ // This will be disabled if highlightMouseOver is true.
78
+ this.highlightMouseDown = false;
79
+ // prop: highlightColors
80
+ // an array of colors to use when highlighting a slice.
81
+ this.highlightColors = [];
82
+ // prop: offsetBars
83
+ // False will center bars on their y value.
84
+ // True will push bars up by 1/2 bar width to fill between their y values.
85
+ // If true, there needs to be 1 more tick than there are bars.
86
+ this.offsetBars = false;
87
+
88
+ // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
89
+ if (options.highlightMouseDown && options.highlightMouseOver == null) {
90
+ options.highlightMouseOver = false;
91
+ }
92
+
93
+ this.side = 'right';
94
+
95
+ $.extend(true, this, options);
96
+
97
+ // if (this.fill === false) {
98
+ // this.shadow = false;
99
+ // }
100
+
101
+ this.renderer.options = options;
102
+ // index of the currenty highlighted point, if any
103
+ this._highlightedPoint = null;
104
+ // Array of actual data colors used for each data point.
105
+ this._dataColors = [];
106
+ this._barPoints = [];
107
+ this.fillAxis = 'y';
108
+ this._primaryAxis = '_yaxis';
109
+ this._xnudge = 0;
110
+
111
+ // set the shape renderer options
112
+ var opts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill, lineWidth: this.lineWidth};
113
+ this.renderer.shapeRenderer.init(opts);
114
+ // set the shadow renderer options
115
+ var shadow_offset = options.shadowOffset;
116
+ // set the shadow renderer options
117
+ if (shadow_offset == null) {
118
+ // scale the shadowOffset to the width of the line.
119
+ if (this.lineWidth > 2.5) {
120
+ shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6);
121
+ // var shadow_offset = this.shadowOffset;
122
+ }
123
+ // for skinny lines, don't make such a big shadow.
124
+ else {
125
+ shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163;
126
+ }
127
+ }
128
+ var sopts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill, lineWidth: this.lineWidth};
129
+ this.renderer.shadowRenderer.init(sopts);
130
+
131
+ plot.postDrawHooks.addOnce(postPlotDraw);
132
+ plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
133
+
134
+ // if this is the left side of pyramid, set y values to negative.
135
+ if (this.side === 'left') {
136
+ for (var i=0, l=this.data.length; i<l; i++) {
137
+ this.data[i][1] = -Math.abs(this.data[i][1]);
138
+ }
139
+ }
140
+ };
141
+
142
+ // setGridData
143
+ // converts the user data values to grid coordinates and stores them
144
+ // in the gridData array.
145
+ // Called with scope of a series.
146
+ $.jqplot.PyramidRenderer.prototype.setGridData = function(plot) {
147
+ // recalculate the grid data
148
+ var xp = this._xaxis.series_u2p;
149
+ var yp = this._yaxis.series_u2p;
150
+ var data = this._plotData;
151
+ var pdata = this._prevPlotData;
152
+ this.gridData = [];
153
+ this._prevGridData = [];
154
+ var l = data.length;
155
+ var adjust = false;
156
+ var i;
157
+
158
+ // if any data values are < 0, consider this a negative series
159
+ for (i = 0; i < l; i++) {
160
+ if (data[i][1] < 0) {
161
+ this.side = 'left';
162
+ }
163
+ }
164
+
165
+ if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
166
+ this._xnudge = this._xaxis.max/2000.0;
167
+ adjust = true;
168
+ }
169
+
170
+ for (i = 0; i < l; i++) {
171
+ // if not a line series or if no nulls in data, push the converted point onto the array.
172
+ if (data[i][0] != null && data[i][1] != null) {
173
+ this.gridData.push([xp(data[i][1]), yp(data[i][0])]);
174
+ }
175
+ // else if there is a null, preserve it.
176
+ else if (data[i][0] == null) {
177
+ this.gridData.push([xp(data[i][1]), null]);
178
+ }
179
+ else if (data[i][1] == null) {
180
+ this.gridData.push(null, [yp(data[i][0])]);
181
+ }
182
+ // finally, adjust x grid data if have to
183
+ if (data[i][1] === 0 && adjust) {
184
+ this.gridData[i][0] = xp(this._xnudge);
185
+ }
186
+ }
187
+ };
188
+
189
+ // makeGridData
190
+ // converts any arbitrary data values to grid coordinates and
191
+ // returns them. This method exists so that plugins can use a series'
192
+ // linerenderer to generate grid data points without overwriting the
193
+ // grid data associated with that series.
194
+ // Called with scope of a series.
195
+ $.jqplot.PyramidRenderer.prototype.makeGridData = function(data, plot) {
196
+ // recalculate the grid data
197
+ var xp = this._xaxis.series_u2p;
198
+ var yp = this._yaxis.series_u2p;
199
+ var gd = [];
200
+ var l = data.length;
201
+ var adjust = false;
202
+ var i;
203
+
204
+ // if any data values are < 0, consider this a negative series
205
+ for (i = 0; i < l; i++) {
206
+ if (data[i][1] < 0) {
207
+ this.side = 'left';
208
+ }
209
+ }
210
+
211
+ if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
212
+ this._xnudge = this._xaxis.max/2000.0;
213
+ adjust = true;
214
+ }
215
+
216
+ for (i = 0; i < l; i++) {
217
+ // if not a line series or if no nulls in data, push the converted point onto the array.
218
+ if (data[i][0] != null && data[i][1] != null) {
219
+ gd.push([xp(data[i][1]), yp(data[i][0])]);
220
+ }
221
+ // else if there is a null, preserve it.
222
+ else if (data[i][0] == null) {
223
+ gd.push([xp(data[i][1]), null]);
224
+ }
225
+ else if (data[i][1] == null) {
226
+ gd.push([null, yp(data[i][0])]);
227
+ }
228
+ // finally, adjust x grid data if have to
229
+ if (data[i][1] === 0 && adjust) {
230
+ gd[i][0] = xp(this._xnudge);
231
+ }
232
+ }
233
+
234
+ return gd;
235
+ };
236
+
237
+ $.jqplot.PyramidRenderer.prototype.setBarWidth = function() {
238
+ // need to know how many data values we have on the approprate axis and figure it out.
239
+ var i;
240
+ var nvals = 0;
241
+ var nseries = 0;
242
+ var paxis = this[this._primaryAxis];
243
+ var s, series, pos;
244
+ nvals = paxis.max - paxis.min;
245
+ var nticks = paxis.numberTicks;
246
+ var nbins = (nticks-1)/2;
247
+ // so, now we have total number of axis values.
248
+ var temp = (this.barPadding === 0) ? 1.0 : 0;
249
+ if (paxis.name == 'xaxis' || paxis.name == 'x2axis') {
250
+ this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding + temp;
251
+ }
252
+ else {
253
+ if (this.fill) {
254
+ this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding + temp;
255
+ }
256
+ else {
257
+ this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals;
258
+ }
259
+ }
260
+ };
261
+
262
+ $.jqplot.PyramidRenderer.prototype.draw = function(ctx, gridData, options) {
263
+ var i;
264
+ // Ughhh, have to make a copy of options b/c it may be modified later.
265
+ var opts = $.extend({}, options);
266
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
267
+ var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
268
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
269
+ var xp = this._xaxis.series_u2p;
270
+ var yp = this._yaxis.series_u2p;
271
+ var pointx, pointy;
272
+ // clear out data colors.
273
+ this._dataColors = [];
274
+ this._barPoints = [];
275
+
276
+ if (this.renderer.options.barWidth == null) {
277
+ this.renderer.setBarWidth.call(this);
278
+ }
279
+
280
+ // var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
281
+ // var nvals = temp[0];
282
+ // var nseries = temp[1];
283
+ // var pos = temp[2];
284
+ var points = [],
285
+ w,
286
+ h;
287
+
288
+ // this._barNudge = 0;
289
+
290
+ if (showLine) {
291
+ var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors);
292
+ var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors);
293
+ var negativeColor = negativeColors.get(this.index);
294
+ if (! this.useNegativeColors) {
295
+ negativeColor = opts.fillStyle;
296
+ }
297
+ var positiveColor = opts.fillStyle;
298
+ var base;
299
+ var xstart = this._xaxis.series_u2p(this._xnudge);
300
+ var ystart = this._yaxis.series_u2p(this._yaxis.min);
301
+ var yend = this._yaxis.series_u2p(this._yaxis.max);
302
+ var bw = this.barWidth;
303
+ var bw2 = bw/2.0;
304
+ var points = [];
305
+ var yadj = this.offsetBars ? bw2 : 0;
306
+
307
+ for (var i=0, l=gridData.length; i<l; i++) {
308
+ if (this.data[i][0] == null) {
309
+ continue;
310
+ }
311
+ base = gridData[i][1];
312
+ // not stacked and first series in stack
313
+
314
+ if (this._plotData[i][1] < 0) {
315
+ if (this.varyBarColor && !this._stack) {
316
+ if (this.useNegativeColors) {
317
+ opts.fillStyle = negativeColors.next();
318
+ }
319
+ else {
320
+ opts.fillStyle = positiveColors.next();
321
+ }
322
+ }
323
+ }
324
+ else {
325
+ if (this.varyBarColor && !this._stack) {
326
+ opts.fillStyle = positiveColors.next();
327
+ }
328
+ else {
329
+ opts.fillStyle = positiveColor;
330
+ }
331
+ }
332
+
333
+ if (this.fill) {
334
+
335
+ if (this._plotData[i][1] >= 0) {
336
+ // xstart = this._xaxis.series_u2p(this._xnudge);
337
+ w = gridData[i][0] - xstart;
338
+ h = this.barWidth;
339
+ points = [xstart, base - bw2 - yadj, w, h];
340
+ }
341
+ else {
342
+ // xstart = this._xaxis.series_u2p(0);
343
+ w = xstart - gridData[i][0];
344
+ h = this.barWidth;
345
+ points = [gridData[i][0], base - bw2 - yadj, w, h];
346
+ }
347
+
348
+ this._barPoints.push([[points[0], points[1] + h], [points[0], points[1]], [points[0] + w, points[1]], [points[0] + w, points[1] + h]]);
349
+
350
+ if (shadow) {
351
+ this.renderer.shadowRenderer.draw(ctx, points);
352
+ }
353
+ var clr = opts.fillStyle || this.color;
354
+ this._dataColors.push(clr);
355
+ this.renderer.shapeRenderer.draw(ctx, points, opts);
356
+ }
357
+
358
+ else {
359
+ if (i === 0) {
360
+ points =[[xstart, ystart], [gridData[i][0], ystart], [gridData[i][0], gridData[i][1] - bw2 - yadj]];
361
+ }
362
+
363
+ else if (i < l-1) {
364
+ points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2 - yadj], [gridData[i][0], gridData[i][1] + bw2 - yadj], [gridData[i][0], gridData[i][1] - bw2 - yadj]]);
365
+ }
366
+
367
+ // finally, draw the line
368
+ else {
369
+ points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2 - yadj], [gridData[i][0], gridData[i][1] + bw2 - yadj], [gridData[i][0], yend], [xstart, yend]]);
370
+
371
+ if (shadow) {
372
+ this.renderer.shadowRenderer.draw(ctx, points);
373
+ }
374
+ var clr = opts.fillStyle || this.color;
375
+ this._dataColors.push(clr);
376
+ this.renderer.shapeRenderer.draw(ctx, points, opts);
377
+ }
378
+ }
379
+ }
380
+ }
381
+
382
+ if (this.highlightColors.length == 0) {
383
+ this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors);
384
+ }
385
+
386
+ else if (typeof(this.highlightColors) == 'string') {
387
+ this.highlightColors = [];
388
+ for (var i=0; i<this._dataColors.length; i++) {
389
+ this.highlightColors.push(this.highlightColors);
390
+ }
391
+ }
392
+
393
+ };
394
+
395
+
396
+ // setup default renderers for axes and legend so user doesn't have to
397
+ // called with scope of plot
398
+ function preInit(target, data, options) {
399
+ options = options || {};
400
+ options.axesDefaults = options.axesDefaults || {};
401
+ options.grid = options.grid || {};
402
+ options.legend = options.legend || {};
403
+ options.seriesDefaults = options.seriesDefaults || {};
404
+ // only set these if there is a pie series
405
+ var setopts = false;
406
+ if (options.seriesDefaults.renderer === $.jqplot.PyramidRenderer) {
407
+ setopts = true;
408
+ }
409
+ else if (options.series) {
410
+ for (var i=0; i < options.series.length; i++) {
411
+ if (options.series[i].renderer === $.jqplot.PyramidRenderer) {
412
+ setopts = true;
413
+ }
414
+ }
415
+ }
416
+
417
+ if (setopts) {
418
+ options.axesDefaults.renderer = $.jqplot.PyramidAxisRenderer;
419
+ options.grid.renderer = $.jqplot.PyramidGridRenderer;
420
+ options.seriesDefaults.pointLabels = {show: false};
421
+ }
422
+ }
423
+
424
+ // called within context of plot
425
+ // create a canvas which we can draw on.
426
+ // insert it before the eventCanvas, so eventCanvas will still capture events.
427
+ function postPlotDraw() {
428
+ // Memory Leaks patch
429
+ if (this.plugins.pyramidRenderer && this.plugins.pyramidRenderer.highlightCanvas) {
430
+
431
+ this.plugins.pyramidRenderer.highlightCanvas.resetCanvas();
432
+ this.plugins.pyramidRenderer.highlightCanvas = null;
433
+ }
434
+
435
+ this.plugins.pyramidRenderer = {highlightedSeriesIndex:null};
436
+ this.plugins.pyramidRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
437
+
438
+ this.eventCanvas._elem.before(this.plugins.pyramidRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pyramidRenderer-highlight-canvas', this._plotDimensions, this));
439
+ this.plugins.pyramidRenderer.highlightCanvas.setContext();
440
+ this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
441
+ }
442
+
443
+ function highlight (plot, sidx, pidx, points) {
444
+ var s = plot.series[sidx];
445
+ var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
446
+ canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
447
+ s._highlightedPoint = pidx;
448
+ plot.plugins.pyramidRenderer.highlightedSeriesIndex = sidx;
449
+ var opts = {fillStyle: s.highlightColors[pidx], fillRect: false};
450
+ s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
451
+ canvas = null;
452
+ }
453
+
454
+ function unhighlight (plot) {
455
+ var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
456
+ canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
457
+ for (var i=0; i<plot.series.length; i++) {
458
+ plot.series[i]._highlightedPoint = null;
459
+ }
460
+ plot.plugins.pyramidRenderer.highlightedSeriesIndex = null;
461
+ plot.target.trigger('jqplotDataUnhighlight');
462
+ canvas = null;
463
+ }
464
+
465
+
466
+ function handleMove(ev, gridpos, datapos, neighbor, plot) {
467
+ if (neighbor) {
468
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
469
+ var evt1 = jQuery.Event('jqplotDataMouseOver');
470
+ evt1.pageX = ev.pageX;
471
+ evt1.pageY = ev.pageY;
472
+ plot.target.trigger(evt1, ins);
473
+ if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pyramidRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
474
+ var evt = jQuery.Event('jqplotDataHighlight');
475
+ evt.pageX = ev.pageX;
476
+ evt.pageY = ev.pageY;
477
+ plot.target.trigger(evt, ins);
478
+ highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
479
+ }
480
+ }
481
+ else if (neighbor == null) {
482
+ unhighlight (plot);
483
+ }
484
+ }
485
+
486
+ // Have to add hook here, becuase it needs called before series is inited.
487
+ $.jqplot.preInitHooks.push(preInit);
488
+
489
+
490
+ })(jQuery);