sunrise-votes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/Gemfile +5 -0
  2. data/README.rdoc +14 -0
  3. data/Rakefile +46 -0
  4. data/app/controllers/manage/ballot_box/votes_controller.rb +36 -0
  5. data/app/views/manage/ballot_box/votes/_model_filter.html.erb +34 -0
  6. data/app/views/manage/ballot_box/votes/_vote.html.erb +48 -0
  7. data/app/views/manage/ballot_box/votes/index.html.erb +29 -0
  8. data/app/views/manage/ballot_box/votes/show.html.erb +112 -0
  9. data/config/locales/ru.yml +5 -0
  10. data/config/locales/uk.yml +5 -0
  11. data/config/routes.rb +8 -0
  12. data/lib/generators/sunrise/votes/USAGE +5 -0
  13. data/lib/generators/sunrise/votes/install_generator.rb +16 -0
  14. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +35 -0
  15. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +226 -0
  16. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +30 -0
  17. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +312 -0
  18. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +30 -0
  19. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +702 -0
  20. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +30 -0
  21. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +234 -0
  22. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +30 -0
  23. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +748 -0
  24. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +30 -0
  25. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +199 -0
  26. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +30 -0
  27. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +238 -0
  28. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +30 -0
  29. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +614 -0
  30. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +30 -0
  31. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +420 -0
  32. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +30 -0
  33. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +634 -0
  34. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +30 -0
  35. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +115 -0
  36. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +30 -0
  37. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +1002 -0
  38. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +30 -0
  39. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +439 -0
  40. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +30 -0
  41. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +904 -0
  42. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +30 -0
  43. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +218 -0
  44. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +30 -0
  45. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +199 -0
  46. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +30 -0
  47. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +932 -0
  48. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +30 -0
  49. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +406 -0
  50. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +30 -0
  51. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +475 -0
  52. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +30 -0
  53. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +446 -0
  54. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +30 -0
  55. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +607 -0
  56. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +30 -0
  57. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +432 -0
  58. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +30 -0
  59. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +1142 -0
  60. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +30 -0
  61. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +372 -0
  62. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +30 -0
  63. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +797 -0
  64. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +30 -0
  65. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +337 -0
  66. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +30 -0
  67. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +220 -0
  68. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +30 -0
  69. data/lib/sunrise-votes.rb +2 -0
  70. data/lib/sunrise/votes.rb +12 -0
  71. data/lib/sunrise/votes/engine.rb +18 -0
  72. data/lib/sunrise/votes/version.rb +5 -0
  73. metadata +164 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b1_r746
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(e){e.jqplot.DonutRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.DonutRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.DonutRenderer.prototype.constructor=e.jqplot.DonutRenderer;e.jqplot.DonutRenderer.prototype.init=function(p,t){this.diameter=null;this.innerDiameter=null;this.thickness=null;this.padding=20;this.sliceMargin=0;this.ringMargin=null;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.4;this.dataLabelNudge=0;this.startAngle=0;this.tickRenderer=e.jqplot.DonutTickRenderer;this._drawData=true;this._type="donut";if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);if(this.diameter!=null){this.diameter=this.diameter-this.sliceMargin}this._diameter=null;this._innerDiameter=null;this._radius=null;this._innerRadius=null;this._thickness=null;this._previousSeries=[];this._numberSeries=1;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var q=e.jqplot.getColorComponents(this.seriesColors[r]);var n=[q[0],q[1],q[2]];var s=n[0]+n[1]+n[2];for(var o=0;o<3;o++){n[o]=(s>570)?n[o]*0.8:n[o]+0.3*(255-n[o]);n[o]=parseInt(n[o],10)}this.highlightColors.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}}t.postParseOptionsHooks.addOnce(l);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",b);t.eventListenerHooks.addOnce("jqplotMouseDown",a);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",m);t.postDrawHooks.addOnce(h)};e.jqplot.DonutRenderer.prototype.setGridData=function(s){var o=[];var t=[];var n=this.startAngle/180*Math.PI;var r=0;this._drawData=false;for(var q=0;q<this.data.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(this.data[q][1]);t.push([this.data[q][0]]);if(q>0){o[q]+=o[q-1]}r+=this.data[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){t[q][1]=o[q]*p;t[q][2]=this.data[q][1]/r}this.gridData=t};e.jqplot.DonutRenderer.prototype.makeGridData=function(s,t){var o=[];var u=[];var r=0;var n=this.startAngle/180*Math.PI;this._drawData=false;for(var q=0;q<s.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(s[q][1]);u.push([s[q][0]]);if(q>0){o[q]+=o[q-1]}r+=s[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){u[q][1]=o[q]*p;u[q][2]=s[q][1]/r}return u};e.jqplot.DonutRenderer.prototype.drawSlice=function(x,u,t,p,s){var n=this._diameter/2;var v=n-this._thickness;var w=this.fill;x.save();x.translate(this._center[0],this._center[1]);if(s){for(var q=0;q<this.shadowDepth;q++){x.save();x.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));o()}}else{o()}function o(){if(t>6.282+this.startAngle){t=6.282+this.startAngle;if(u>t){u=6.281+this.startAngle}}if(u>=t){return}x.beginPath();x.fillStyle=p;x.strokeStyle=p;x.arc(0,0,n,u,t,false);x.lineTo(v*Math.cos(t),v*Math.sin(t));x.arc(0,0,v,t,u,true);x.closePath();if(w){x.fill()}else{x.stroke()}}if(s){for(var q=0;q<this.shadowDepth;q++){x.restore()}}x.restore()};e.jqplot.DonutRenderer.prototype.draw=function(N,V,t,P){var Q;var J=(t!=undefined)?t:{};var q=0;var p=0;var u=1;if(t.legendInfo&&t.legendInfo.placement=="insideGrid"){var I=t.legendInfo;switch(I.location){case"nw":q=I.width+I.xoffset;break;case"w":q=I.width+I.xoffset;break;case"sw":q=I.width+I.xoffset;break;case"ne":q=I.width+I.xoffset;u=-1;break;case"e":q=I.width+I.xoffset;u=-1;break;case"se":q=I.width+I.xoffset;u=-1;break;case"n":p=I.height+I.yoffset;break;case"s":p=I.height+I.yoffset;u=-1;break;default:break}}var B=(J.shadow!=undefined)?J.shadow:this.shadow;var W=(J.showLine!=undefined)?J.showLine:this.showLine;var O=(J.fill!=undefined)?J.fill:this.fill;var s=N.canvas.width;var H=N.canvas.height;var G=s-q-2*this.padding;var R=H-p-2*this.padding;var v=Math.min(G,R);var T=v;var X=(this.ringMargin==null)?this.sliceMargin*2:this.ringMargin;for(var Q=0;Q<this._previousSeries.length;Q++){T-=2*this._previousSeries[Q]._thickness+2*X}this._diameter=this.diameter||T;if(this.innerDiameter!=null){var M=(this._numberSeries>1&&this.index>0)?this._previousSeries[0]._diameter:this._diameter;this._thickness=this.thickness||(M-this.innerDiameter-2*X*this._numberSeries)/this._numberSeries/2}else{this._thickness=this.thickness||v/2/(this._numberSeries+1)*0.85}var K=this._radius=this._diameter/2;this._innerRadius=this._radius-this._thickness;var o=this.startAngle/180*Math.PI;this._center=[(s-u*q)/2+u*q,(H-u*p)/2+u*p];if(this.shadow){var L="rgba(0,0,0,"+this.shadowAlpha+")";for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;this.renderer.drawSlice.call(this,N,A,V[Q][1]+o,L,true)}}for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;var z=V[Q][1]+o;this._sliceAngles.push([A,z]);this.renderer.drawSlice.call(this,N,A,z,this.seriesColors[Q],false);if(this.showDataLabels&&V[Q][2]*100>=this.dataLabelThreshold){var S,U=(A+z)/2,C;if(this.dataLabels=="label"){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,V[Q][0])}else{if(this.dataLabels=="value"){S=this.dataLabelFormatString||"%d";C=e.jqplot.sprintf(S,this.data[Q][1])}else{if(this.dataLabels=="percent"){S=this.dataLabelFormatString||"%d%%";C=e.jqplot.sprintf(S,V[Q][2]*100)}else{if(this.dataLabels.constructor==Array){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,this.dataLabels[Q])}}}}var n=this._innerRadius+this._thickness*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var F=this._center[0]+Math.cos(U)*n+this.canvas._offsets.left;var E=this._center[1]+Math.sin(U)*n+this.canvas._offsets.top;var D=e('<span class="jqplot-donut-series jqplot-data-label" style="position:absolute;">'+C+"</span>").insertBefore(P.eventCanvas._elem);F-=D.width()/2;E-=D.height()/2;F=Math.round(F);E=Math.round(E);D.css({left:F,top:E})}}};e.jqplot.DonutAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.DonutAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.DonutAxisRenderer.prototype.constructor=e.jqplot.DonutAxisRenderer;e.jqplot.DonutAxisRenderer.prototype.init=function(n){this.tickRenderer=e.jqplot.DonutTickRenderer;e.extend(true,this,n);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.DonutLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.DonutLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.DonutLegendRenderer.prototype.constructor=e.jqplot.DonutLegendRenderer;e.jqplot.DonutLegendRenderer.prototype.init=function(n){this.numberRows=null;this.numberColumns=null;e.extend(true,this,n)};e.jqplot.DonutLegendRenderer.prototype.draw=function(){var q=this;if(this.show){var y=this._series;var B="position:absolute;";B+=(this.background)?"background:"+this.background+";":"";B+=(this.border)?"border:"+this.border+";":"";B+=(this.fontSize)?"font-size:"+this.fontSize+";":"";B+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";B+=(this.textColor)?"color:"+this.textColor+";":"";B+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";B+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";B+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";B+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+B+'"></table>');var F=false,x=false,n,v;var z=y[0];var o=new e.jqplot.ColorGenerator(z.seriesColors);if(z.show){var G=z.data;if(this.numberRows){n=this.numberRows;if(!this.numberColumns){v=Math.ceil(G.length/n)}else{v=this.numberColumns}}else{if(this.numberColumns){v=this.numberColumns;n=Math.ceil(G.length/this.numberColumns)}else{n=G.length;v=1}}var E,D,p,t,r,u,w,C;var A=0;for(E=0;E<n;E++){if(x){p=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{p=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(D=0;D<v;D++){if(A<G.length){u=this.labels[A]||G[A][0].toString();C=o.next();if(!x){if(E>0){F=true}else{F=false}}else{if(E==n-1){F=false}else{F=true}}w=(F)?this.rowSpacing:"0";t=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+w+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+C+';"></div></div></td>');r=e('<td class="jqplot-table-legend" style="padding-top:'+w+';"></td>');if(this.escapeHtml){r.text(u)}else{r.html(u)}if(x){r.prependTo(p);t.prependTo(p)}else{t.appendTo(p);r.appendTo(p)}F=true}A++}}}}return this._elem};function c(r,q,o){o=o||{};o.axesDefaults=o.axesDefaults||{};o.legend=o.legend||{};o.seriesDefaults=o.seriesDefaults||{};var n=false;if(o.seriesDefaults.renderer==e.jqplot.DonutRenderer){n=true}else{if(o.series){for(var p=0;p<o.series.length;p++){if(o.series[p].renderer==e.jqplot.DonutRenderer){n=true}}}}if(n){o.axesDefaults.renderer=e.jqplot.DonutAxisRenderer;o.legend.renderer=e.jqplot.DonutLegendRenderer;o.legend.preDraw=true;o.seriesDefaults.pointLabels={show:false}}}function g(r,q,o){for(var p=1;p<this.series.length;p++){if(!this.series[p]._previousSeries.length){for(var n=0;n<p;n++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer&&this.series[n].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._previousSeries.push(this.series[n])}}}}for(p=0;p<this.series.length;p++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._numberSeries=this.series.length;if(this.series[p].highlightMouseOver){this.series[p].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(s){i(s.data.plot)})}var k=false;function l(n){for(var o=0;o<this.series.length;o++){this.series[o].seriesColors=this.seriesColors;this.series[o].colorGenerator=this.colorGenerator}}function d(r,q,p){var o=r.series[q];var n=r.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);o._highlightedPoint=p;r.plugins.donutRenderer.highlightedSeriesIndex=q;o.renderer.drawSlice.call(o,n._ctx,o._sliceAngles[p][0],o._sliceAngles[p][1],o.highlightColors[p],false)}function i(p){var n=p.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);for(var o=0;o<p.series.length;o++){p.series[o]._highlightedPoint=null}p.plugins.donutRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function b(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataMouseOver");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);if(s.series[p[0]].highlightMouseOver&&!(p[0]==s.plugins.donutRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=r.pageX;n.pageY=r.pageY;s.target.trigger(n,p);d(s,p[0],p[1])}}else{if(t==null){i(s)}}}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];if(r.series[o[0]].highlightMouseDown&&!(o[0]==r.plugins.donutRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function j(p,o,s,r,q){var n=q.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&q.series[n].highlightMouseDown){i(q)}}function f(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function m(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var n=s.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&s.series[n].highlightMouseDown){i(s)}var o=jQuery.Event("jqplotDataRightClick");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}function h(){this.plugins.donutRenderer={highlightedSeriesIndex:null};this.plugins.donutRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var o=e(this.targetId+" .jqplot-data-label");if(o.length){e(o[0]).before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions))}else{this.eventCanvas._elem.before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions))}var n=this.plugins.donutRenderer.highlightCanvas.setContext()}e.jqplot.preInitHooks.push(c);e.jqplot.DonutTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.DonutTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.DonutTickRenderer.prototype.constructor=e.jqplot.DonutTickRenderer})(jQuery);
@@ -0,0 +1,218 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b1_r746
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
+ /**
33
+ * Class: $.jqplot.Dragable
34
+ * Plugin to make plotted points dragable by the user.
35
+ */
36
+ $.jqplot.Dragable = function(options) {
37
+ // Group: Properties
38
+ this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
39
+ this.shapeRenderer = new $.jqplot.ShapeRenderer();
40
+ this.isDragging = false;
41
+ this.isOver = false;
42
+ this._ctx;
43
+ this._elem;
44
+ this._point;
45
+ this._gridData;
46
+ // prop: color
47
+ // CSS color spec for the dragged point (and adjacent line segment or bar).
48
+ this.color;
49
+ // prop: constrainTo
50
+ // Constrain dragging motion to an axis or to none.
51
+ // Allowable values are 'none', 'x', 'y'
52
+ this.constrainTo = 'none'; // 'x', 'y', or 'none';
53
+ $.extend(true, this, options);
54
+ };
55
+
56
+ function DragCanvas() {
57
+ $.jqplot.GenericCanvas.call(this);
58
+ this.isDragging = false;
59
+ this.isOver = false;
60
+ this._neighbor;
61
+ this._cursors = [];
62
+ }
63
+
64
+ DragCanvas.prototype = new $.jqplot.GenericCanvas();
65
+ DragCanvas.prototype.constructor = DragCanvas;
66
+
67
+
68
+ // called within scope of series
69
+ $.jqplot.Dragable.parseOptions = function (defaults, opts) {
70
+ var options = opts || {};
71
+ this.plugins.dragable = new $.jqplot.Dragable(options.dragable);
72
+ // since this function is called before series options are parsed,
73
+ // we can set this here and it will be overridden if needed.
74
+ this.isDragable = $.jqplot.config.enablePlugins;
75
+ };
76
+
77
+ // called within context of plot
78
+ // create a canvas which we can draw on.
79
+ // insert it before the eventCanvas, so eventCanvas will still capture events.
80
+ // add a new DragCanvas object to the plot plugins to handle drawing on this new canvas.
81
+ $.jqplot.Dragable.postPlotDraw = function() {
82
+ this.plugins.dragable = {previousCursor:'auto', isOver:false};
83
+ this.plugins.dragable.dragCanvas = new DragCanvas();
84
+
85
+ this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding, 'jqplot-dragable-canvas', this._plotDimensions));
86
+ var dctx = this.plugins.dragable.dragCanvas.setContext();
87
+ };
88
+
89
+ //$.jqplot.preInitHooks.push($.jqplot.Dragable.init);
90
+ $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Dragable.parseOptions);
91
+ $.jqplot.postDrawHooks.push($.jqplot.Dragable.postPlotDraw);
92
+ $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
93
+ $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleDown]);
94
+ $.jqplot.eventListenerHooks.push(['jqplotMouseUp', handleUp]);
95
+
96
+
97
+ function initDragPoint(plot, neighbor) {
98
+ var s = plot.series[neighbor.seriesIndex];
99
+ var drag = s.plugins.dragable;
100
+
101
+ // first, init the mark renderer for the dragged point
102
+ var smr = s.markerRenderer;
103
+ var mr = drag.markerRenderer;
104
+ mr.style = smr.style;
105
+ mr.lineWidth = smr.lineWidth + 2.5;
106
+ mr.size = smr.size + 5;
107
+ if (!drag.color) {
108
+ var rgba = $.jqplot.getColorComponents(smr.color);
109
+ var newrgb = [rgba[0], rgba[1], rgba[2]];
110
+ var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
111
+ drag.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
112
+ }
113
+ mr.color = drag.color;
114
+ mr.init();
115
+
116
+ var start = (neighbor.pointIndex > 0) ? neighbor.pointIndex - 1 : 0;
117
+ var end = neighbor.pointIndex+2;
118
+ drag._gridData = s.gridData.slice(start, end);
119
+ }
120
+
121
+ function handleMove(ev, gridpos, datapos, neighbor, plot) {
122
+ if (plot.plugins.dragable.dragCanvas.isDragging) {
123
+ var dc = plot.plugins.dragable.dragCanvas;
124
+ var dp = dc._neighbor;
125
+ var s = plot.series[dp.seriesIndex];
126
+ var drag = s.plugins.dragable;
127
+ var gd = s.gridData;
128
+
129
+ // compute the new grid position with any constraints.
130
+ var x = (drag.constrainTo == 'y') ? dp.gridData[0] : gridpos.x;
131
+ var y = (drag.constrainTo == 'x') ? dp.gridData[1] : gridpos.y;
132
+
133
+ // compute data values for any listeners.
134
+ var xu = s._xaxis.series_p2u(x);
135
+ var yu = s._yaxis.series_p2u(y);
136
+
137
+ // clear the canvas then redraw effect at new position.
138
+ var ctx = dc._ctx;
139
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
140
+
141
+ // adjust our gridData for the new mouse position
142
+ if (dp.pointIndex > 0) {
143
+ drag._gridData[1] = [x, y];
144
+ }
145
+ else {
146
+ drag._gridData[0] = [x, y];
147
+ }
148
+ plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color, markerOptions:{color:drag.color, shadow:false}, trendline:{show:false}});
149
+ plot.target.trigger('jqplotSeriesPointChange', [dp.seriesIndex, dp.pointIndex, [xu,yu], [x,y]]);
150
+ }
151
+ else if (neighbor != null) {
152
+ var series = plot.series[neighbor.seriesIndex];
153
+ if (series.isDragable) {
154
+ var dc = plot.plugins.dragable.dragCanvas;
155
+ if (!dc.isOver) {
156
+ dc._cursors.push(ev.target.style.cursor);
157
+ ev.target.style.cursor = "pointer";
158
+ }
159
+ dc.isOver = true;
160
+ }
161
+ }
162
+ else if (neighbor == null) {
163
+ var dc = plot.plugins.dragable.dragCanvas;
164
+ if (dc.isOver) {
165
+ ev.target.style.cursor = dc._cursors.pop();
166
+ dc.isOver = false;
167
+ }
168
+ }
169
+ }
170
+
171
+ function handleDown(ev, gridpos, datapos, neighbor, plot) {
172
+ var dc = plot.plugins.dragable.dragCanvas;
173
+ dc._cursors.push(ev.target.style.cursor);
174
+ if (neighbor != null) {
175
+ var s = plot.series[neighbor.seriesIndex];
176
+ var drag = s.plugins.dragable;
177
+ if (s.isDragable && !dc.isDragging) {
178
+ dc._neighbor = neighbor;
179
+ dc.isDragging = true;
180
+ initDragPoint(plot, neighbor);
181
+ drag.markerRenderer.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], dc._ctx);
182
+ ev.target.style.cursor = "move";
183
+ plot.target.trigger('jqplotDragStart', [neighbor.seriesIndex, neighbor.pointIndex, gridpos, datapos]);
184
+ }
185
+ }
186
+ // Just in case of a hickup, we'll clear the drag canvas and reset.
187
+ else {
188
+ var ctx = dc._ctx;
189
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
190
+ dc.isDragging = false;
191
+ }
192
+ }
193
+
194
+ function handleUp(ev, gridpos, datapos, neighbor, plot) {
195
+ if (plot.plugins.dragable.dragCanvas.isDragging) {
196
+ var dc = plot.plugins.dragable.dragCanvas;
197
+ // clear the canvas
198
+ var ctx = dc._ctx;
199
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
200
+ dc.isDragging = false;
201
+ // redraw the series canvas at the new point.
202
+ var dp = dc._neighbor;
203
+ var s = plot.series[dp.seriesIndex];
204
+ var drag = s.plugins.dragable;
205
+ // compute the new grid position with any constraints.
206
+ var x = (drag.constrainTo == 'y') ? dp.data[0] : datapos[s.xaxis];
207
+ var y = (drag.constrainTo == 'x') ? dp.data[1] : datapos[s.yaxis];
208
+ // var x = datapos[s.xaxis];
209
+ // var y = datapos[s.yaxis];
210
+ s.data[dp.pointIndex][0] = x;
211
+ s.data[dp.pointIndex][1] = y;
212
+ plot.drawSeries({preventJqPlotSeriesDrawTrigger:true}, dp.seriesIndex);
213
+ dc._neighbor = null;
214
+ ev.target.style.cursor = dc._cursors.pop();
215
+ plot.target.trigger('jqplotDragStop', [gridpos, datapos]);
216
+ }
217
+ }
218
+ })(jQuery);
@@ -0,0 +1,30 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b1_r746
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(d){d.jqplot.Dragable=function(g){this.markerRenderer=new d.jqplot.MarkerRenderer({shadow:false});this.shapeRenderer=new d.jqplot.ShapeRenderer();this.isDragging=false;this.isOver=false;this._ctx;this._elem;this._point;this._gridData;this.color;this.constrainTo="none";d.extend(true,this,g)};function b(){d.jqplot.GenericCanvas.call(this);this.isDragging=false;this.isOver=false;this._neighbor;this._cursors=[]}b.prototype=new d.jqplot.GenericCanvas();b.prototype.constructor=b;d.jqplot.Dragable.parseOptions=function(i,h){var g=h||{};this.plugins.dragable=new d.jqplot.Dragable(g.dragable);this.isDragable=d.jqplot.config.enablePlugins};d.jqplot.Dragable.postPlotDraw=function(){this.plugins.dragable={previousCursor:"auto",isOver:false};this.plugins.dragable.dragCanvas=new b();this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding,"jqplot-dragable-canvas",this._plotDimensions));var g=this.plugins.dragable.dragCanvas.setContext()};d.jqplot.preParseSeriesOptionsHooks.push(d.jqplot.Dragable.parseOptions);d.jqplot.postDrawHooks.push(d.jqplot.Dragable.postPlotDraw);d.jqplot.eventListenerHooks.push(["jqplotMouseMove",e]);d.jqplot.eventListenerHooks.push(["jqplotMouseDown",c]);d.jqplot.eventListenerHooks.push(["jqplotMouseUp",a]);function f(n,p){var q=n.series[p.seriesIndex];var m=q.plugins.dragable;var h=q.markerRenderer;var i=m.markerRenderer;i.style=h.style;i.lineWidth=h.lineWidth+2.5;i.size=h.size+5;if(!m.color){var l=d.jqplot.getColorComponents(h.color);var o=[l[0],l[1],l[2]];var k=(l[3]>=0.6)?l[3]*0.6:l[3]*(2-l[3]);m.color="rgba("+o[0]+","+o[1]+","+o[2]+","+k+")"}i.color=m.color;i.init();var g=(p.pointIndex>0)?p.pointIndex-1:0;var j=p.pointIndex+2;m._gridData=q.gridData.slice(g,j)}function e(o,l,h,t,m){if(m.plugins.dragable.dragCanvas.isDragging){var u=m.plugins.dragable.dragCanvas;var i=u._neighbor;var w=m.series[i.seriesIndex];var k=w.plugins.dragable;var r=w.gridData;var p=(k.constrainTo=="y")?i.gridData[0]:l.x;var n=(k.constrainTo=="x")?i.gridData[1]:l.y;var g=w._xaxis.series_p2u(p);var q=w._yaxis.series_p2u(n);var v=u._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);if(i.pointIndex>0){k._gridData[1]=[p,n]}else{k._gridData[0]=[p,n]}m.series[i.seriesIndex].draw(u._ctx,{gridData:k._gridData,shadow:false,preventJqPlotSeriesDrawTrigger:true,color:k.color,markerOptions:{color:k.color,shadow:false},trendline:{show:false}});m.target.trigger("jqplotSeriesPointChange",[i.seriesIndex,i.pointIndex,[g,q],[p,n]])}else{if(t!=null){var j=m.series[t.seriesIndex];if(j.isDragable){var u=m.plugins.dragable.dragCanvas;if(!u.isOver){u._cursors.push(o.target.style.cursor);o.target.style.cursor="pointer"}u.isOver=true}}else{if(t==null){var u=m.plugins.dragable.dragCanvas;if(u.isOver){o.target.style.cursor=u._cursors.pop();u.isOver=false}}}}}function c(k,i,g,l,j){var m=j.plugins.dragable.dragCanvas;m._cursors.push(k.target.style.cursor);if(l!=null){var o=j.series[l.seriesIndex];var h=o.plugins.dragable;if(o.isDragable&&!m.isDragging){m._neighbor=l;m.isDragging=true;f(j,l);h.markerRenderer.draw(o.gridData[l.pointIndex][0],o.gridData[l.pointIndex][1],m._ctx);k.target.style.cursor="move";j.target.trigger("jqplotDragStart",[l.seriesIndex,l.pointIndex,i,g])}}else{var n=m._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);m.isDragging=false}}function a(m,j,g,o,k){if(k.plugins.dragable.dragCanvas.isDragging){var p=k.plugins.dragable.dragCanvas;var q=p._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);p.isDragging=false;var h=p._neighbor;var r=k.series[h.seriesIndex];var i=r.plugins.dragable;var n=(i.constrainTo=="y")?h.data[0]:g[r.xaxis];var l=(i.constrainTo=="x")?h.data[1]:g[r.yaxis];r.data[h.pointIndex][0]=n;r.data[h.pointIndex][1]=l;k.drawSeries({preventJqPlotSeriesDrawTrigger:true},h.seriesIndex);p._neighbor=null;m.target.style.cursor=p._cursors.pop();k.target.trigger("jqplotDragStop",[j,g])}}})(jQuery);
@@ -0,0 +1,199 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b1_r746
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.EnhancedLegendRenderer
32
+ // Legend renderer which can specify the number of rows and/or columns in the legend.
33
+ $.jqplot.EnhancedLegendRenderer = function(){
34
+ $.jqplot.TableLegendRenderer.call(this);
35
+ };
36
+
37
+ $.jqplot.EnhancedLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
38
+ $.jqplot.EnhancedLegendRenderer.prototype.constructor = $.jqplot.EnhancedLegendRenderer;
39
+
40
+ // called with scope of legend.
41
+ $.jqplot.EnhancedLegendRenderer.prototype.init = function(options) {
42
+ // prop: numberRows
43
+ // Maximum number of rows in the legend. 0 or null for unlimited.
44
+ this.numberRows = null;
45
+ // prop: numberColumns
46
+ // Maximum number of columns in the legend. 0 or null for unlimited.
47
+ this.numberColumns = null;
48
+ // prop: seriesToggle
49
+ // false to not enable series on/off toggling on the legend.
50
+ // true or a fadein/fadeout speed (number of milliseconds or 'fast', 'normal', 'slow')
51
+ // to enable show/hide of series on click of legend item.
52
+ this.seriesToggle = 'normal';
53
+ // prop: disableIEFading
54
+ // true to toggle series with a show/hide method only and not allow fading in/out.
55
+ // This is to overcome poor performance of fade in some versions of IE.
56
+ this.disableIEFading = true;
57
+ $.extend(true, this, options);
58
+
59
+ if (this.seriesToggle) {
60
+ $.jqplot.postDrawHooks.push(postDraw);
61
+ }
62
+ };
63
+
64
+ // called with scope of legend
65
+ $.jqplot.EnhancedLegendRenderer.prototype.draw = function() {
66
+ var legend = this;
67
+ if (this.show) {
68
+ var series = this._series;
69
+ var s;
70
+ var ss = 'position:absolute;';
71
+ ss += (this.background) ? 'background:'+this.background+';' : '';
72
+ ss += (this.border) ? 'border:'+this.border+';' : '';
73
+ ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
74
+ ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
75
+ ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
76
+ ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
77
+ ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
78
+ ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
79
+ ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
80
+ this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
81
+ if (this.seriesToggle) {
82
+ this._elem.css('z-index', '3');
83
+ }
84
+
85
+ var pad = false,
86
+ reverse = false,
87
+ nr, nc;
88
+ if (this.numberRows) {
89
+ nr = this.numberRows;
90
+ if (!this.numberColumns){
91
+ nc = Math.ceil(series.length/nr);
92
+ }
93
+ else{
94
+ nc = this.numberColumns;
95
+ }
96
+ }
97
+ else if (this.numberColumns) {
98
+ nc = this.numberColumns;
99
+ nr = Math.ceil(series.length/this.numberColumns);
100
+ }
101
+ else {
102
+ nr = series.length;
103
+ nc = 1;
104
+ }
105
+
106
+ var i, j, tr, td1, td2, lt, rs;
107
+ var idx = 0;
108
+ // check to see if we need to reverse
109
+ for (i=series.length-1; i>=0; i--) {
110
+ if (series[i]._stack || series[i].renderer.constructor == $.jqplot.BezierCurveRenderer){
111
+ reverse = true;
112
+ }
113
+ }
114
+
115
+ for (i=0; i<nr; i++) {
116
+ if (reverse){
117
+ tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
118
+ }
119
+ else{
120
+ tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
121
+ }
122
+ for (j=0; j<nc; j++) {
123
+ if (idx < series.length && series[idx].show && series[idx].showLabel){
124
+ s = series[idx];
125
+ lt = this.labels[idx] || s.label.toString();
126
+ if (lt) {
127
+ var color = s.color;
128
+ if (!reverse){
129
+ if (i>0){
130
+ pad = true;
131
+ }
132
+ else{
133
+ pad = false;
134
+ }
135
+ }
136
+ else{
137
+ if (i == nr -1){
138
+ pad = false;
139
+ }
140
+ else{
141
+ pad = true;
142
+ }
143
+ }
144
+ rs = (pad) ? this.rowSpacing : '0';
145
+
146
+ td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
147
+ '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+
148
+ '</div></td>');
149
+ td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
150
+ if (this.escapeHtml){
151
+ td2.text(lt);
152
+ }
153
+ else {
154
+ td2.html(lt);
155
+ }
156
+ if (reverse) {
157
+ if (this.showLabels) {td2.prependTo(tr);}
158
+ if (this.showSwatches) {td1.prependTo(tr);}
159
+ }
160
+ else {
161
+ if (this.showSwatches) {td1.appendTo(tr);}
162
+ if (this.showLabels) {td2.appendTo(tr);}
163
+ }
164
+
165
+ if (this.seriesToggle) {
166
+ var speed;
167
+ if (typeof(this.seriesToggle) == 'string' || typeof(this.seriesToggle) == 'number') {
168
+ if (!$.browser.msie || !this.disableIEFading) {
169
+ speed = this.seriesToggle;
170
+ }
171
+ }
172
+ if (this.showSwatches) {
173
+ td1.bind('click', {series:s, speed:speed}, s.toggleDisplay);
174
+ td1.addClass('jqplot-seriesToggle');
175
+ }
176
+ if (this.showLabels) {
177
+ td2.bind('click', {series:s, speed:speed}, s.toggleDisplay);
178
+ td2.addClass('jqplot-seriesToggle');
179
+ }
180
+ }
181
+
182
+ pad = true;
183
+ }
184
+ }
185
+ idx++;
186
+ }
187
+ }
188
+ }
189
+ return this._elem;
190
+ };
191
+
192
+ // called with scope of plot.
193
+ var postDraw = function () {
194
+ if (this.legend.renderer.constructor == $.jqplot.EnhancedLegendRenderer && this.legend.seriesToggle){
195
+ var e = this.legend._elem.detach();
196
+ this.eventCanvas._elem.after(e);
197
+ }
198
+ };
199
+ })(jQuery);