sunrise-votes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -4
- data/Rakefile +0 -22
- data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
- data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
- data/lib/generators/sunrise/votes/install_generator.rb +1 -1
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
- data/lib/sunrise/votes/version.rb +1 -1
- metadata +33 -79
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +0 -30
data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js
DELETED
@@ -1,30 +0,0 @@
|
|
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.PieRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.PieRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.PieRenderer.prototype.constructor=e.jqplot.PieRenderer;e.jqplot.PieRenderer.prototype.init=function(o,s){this.diameter=null;this.padding=20;this.sliceMargin=0;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.52;this.dataLabelNudge=2;this.dataLabelCenterOn=true;this.startAngle=0;this.tickRenderer=e.jqplot.PieTickRenderer;this._drawData=true;this._type="pie";if(o.highlightMouseDown&&o.highlightMouseOver==null){o.highlightMouseOver=false}e.extend(true,this,o);this._diameter=null;this._radius=null;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var q=0;q<this.seriesColors.length;q++){var p=e.jqplot.getColorComponents(this.seriesColors[q]);var m=[p[0],p[1],p[2]];var r=m[0]+m[1]+m[2];for(var n=0;n<3;n++){m[n]=(r>570)?m[n]*0.8:m[n]+0.3*(255-m[n]);m[n]=parseInt(m[n],10)}this.highlightColors.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}}this.highlightColorGenerator=new e.jqplot.ColorGenerator(this.highlightColors);s.postParseOptionsHooks.addOnce(k);s.postInitHooks.addOnce(g);s.eventListenerHooks.addOnce("jqplotMouseMove",a);s.eventListenerHooks.addOnce("jqplotMouseDown",b);s.eventListenerHooks.addOnce("jqplotMouseUp",j);s.eventListenerHooks.addOnce("jqplotClick",f);s.eventListenerHooks.addOnce("jqplotRightClick",l);s.postDrawHooks.addOnce(h)};e.jqplot.PieRenderer.prototype.setGridData=function(r){var n=[];var s=[];var m=this.startAngle/180*Math.PI;var q=0;this._drawData=false;for(var p=0;p<this.data.length;p++){if(this.data[p][1]!=0){this._drawData=true}n.push(this.data[p][1]);s.push([this.data[p][0]]);if(p>0){n[p]+=n[p-1]}q+=this.data[p][1]}var o=Math.PI*2/n[n.length-1];for(var p=0;p<n.length;p++){s[p][1]=n[p]*o;s[p][2]=this.data[p][1]/q}this.gridData=s};e.jqplot.PieRenderer.prototype.makeGridData=function(r,s){var n=[];var t=[];var q=0;var m=this.startAngle/180*Math.PI;this._drawData=false;for(var p=0;p<r.length;p++){if(this.data[p][1]!=0){this._drawData=true}n.push(r[p][1]);t.push([r[p][0]]);if(p>0){n[p]+=n[p-1]}q+=r[p][1]}var o=Math.PI*2/n[n.length-1];for(var p=0;p<n.length;p++){t[p][1]=n[p]*o;t[p][2]=r[p][1]/q}return t};e.jqplot.PieRenderer.prototype.drawSlice=function(y,w,v,q,t){if(this._drawData){var n=this._diameter/2;var x=this.fill;var u=this.lineWidth;var p=this.sliceMargin;if(this.fill==false){p+=this.lineWidth}y.save();y.translate(this._center[0],this._center[1]);var A=0;if(Math.abs(v-w)>0){A=parseFloat(p)/2/Math.sin((v-w)/2)}var m=A*Math.cos((w+v)/2);var z=A*Math.sin((w+v)/2);if((v-w)<=Math.PI){n-=A}else{n+=A}y.translate(m,z);if(t){for(var s=0;s<this.shadowDepth;s++){y.save();y.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));o(n)}}else{o(n)}}function o(r){if(v>6.282+this.startAngle){v=6.282+this.startAngle;if(w>v){w=6.281+this.startAngle}}if(w>=v){return}y.beginPath();y.fillStyle=q;y.strokeStyle=q;y.lineWidth=u;y.arc(0,0,r,w,v,false);y.lineTo(0,0);y.closePath();if(x){y.fill()}else{y.stroke()}}if(t){for(var s=0;s<this.shadowDepth;s++){y.restore()}}y.restore()};e.jqplot.PieRenderer.prototype.draw=function(M,U,t,O){var P;var J=(t!=undefined)?t:{};var q=0;var p=0;var u=1;var m=new e.jqplot.ColorGenerator(this.seriesColors);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 V=(J.showLine!=undefined)?J.showLine:this.showLine;var N=(J.fill!=undefined)?J.fill:this.fill;var s=M.canvas.width;var H=M.canvas.height;var G=s-q-2*this.padding;var Q=H-p-2*this.padding;var v=Math.min(G,Q);var S=v;this._diameter=this.diameter||S;var K=this._radius=this._diameter/2;var o=this.startAngle/180*Math.PI;this._center=[(s-u*q)/2+u*q,(H-u*p)/2+u*p];this._sliceAngles=[];if(this.shadow){var L="rgba(0,0,0,"+this.shadowAlpha+")";for(var P=0;P<U.length;P++){var A=(P==0)?o:U[P-1][1]+o;this.renderer.drawSlice.call(this,M,A,U[P][1]+o,L,true)}}for(var P=0;P<U.length;P++){var A=(P==0)?o:U[P-1][1]+o;var z=U[P][1]+o;this._sliceAngles.push([A,z]);this.renderer.drawSlice.call(this,M,A,z,m.next(),false);if(this.showDataLabels&&U[P][2]*100>=this.dataLabelThreshold){var R,T=(A+z)/2,C;if(this.dataLabels=="label"){R=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(R,U[P][0])}else{if(this.dataLabels=="value"){R=this.dataLabelFormatString||"%d";C=e.jqplot.sprintf(R,this.data[P][1])}else{if(this.dataLabels=="percent"){R=this.dataLabelFormatString||"%d%%";C=e.jqplot.sprintf(R,U[P][2]*100)}else{if(this.dataLabels.constructor==Array){R=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(R,this.dataLabels[P])}}}}var n=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var F=this._center[0]+Math.cos(T)*n+this.canvas._offsets.left;var E=this._center[1]+Math.sin(T)*n+this.canvas._offsets.top;var D=e('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">'+C+"</div>").insertBefore(O.eventCanvas._elem);if(this.dataLabelCenterOn){F-=D.width()/2;E-=D.height()/2}else{F-=D.width()*Math.sin(T/2);E-=D.height()/2}F=Math.round(F);E=Math.round(E);D.css({left:F,top:E})}}};e.jqplot.PieAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PieAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PieAxisRenderer.prototype.constructor=e.jqplot.PieAxisRenderer;e.jqplot.PieAxisRenderer.prototype.init=function(m){this.tickRenderer=e.jqplot.PieTickRenderer;e.extend(true,this,m);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.PieLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.PieLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.PieLegendRenderer.prototype.constructor=e.jqplot.PieLegendRenderer;e.jqplot.PieLegendRenderer.prototype.init=function(m){this.numberRows=null;this.numberColumns=null;e.extend(true,this,m)};e.jqplot.PieLegendRenderer.prototype.draw=function(){var p=this;if(this.show){var x=this._series;var A="position:absolute;";A+=(this.background)?"background:"+this.background+";":"";A+=(this.border)?"border:"+this.border+";":"";A+=(this.fontSize)?"font-size:"+this.fontSize+";":"";A+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";A+=(this.textColor)?"color:"+this.textColor+";":"";A+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";A+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";A+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";A+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+A+'"></table>');var E=false,w=false,m,u;var y=x[0];var n=new e.jqplot.ColorGenerator(y.seriesColors);if(y.show){var F=y.data;if(this.numberRows){m=this.numberRows;if(!this.numberColumns){u=Math.ceil(F.length/m)}else{u=this.numberColumns}}else{if(this.numberColumns){u=this.numberColumns;m=Math.ceil(F.length/this.numberColumns)}else{m=F.length;u=1}}var D,C,o,r,q,t,v,B;var z=0;for(D=0;D<m;D++){if(w){o=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{o=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(C=0;C<u;C++){if(z<F.length){t=this.labels[z]||F[z][0].toString();B=n.next();if(!w){if(D>0){E=true}else{E=false}}else{if(D==m-1){E=false}else{E=true}}v=(E)?this.rowSpacing:"0";r=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+v+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+B+';"></div></div></td>');q=e('<td class="jqplot-table-legend" style="padding-top:'+v+';"></td>');if(this.escapeHtml){q.text(t)}else{q.html(t)}if(w){q.prependTo(o);r.prependTo(o)}else{r.appendTo(o);q.appendTo(o)}E=true}z++}}}}return this._elem};e.jqplot.PieRenderer.prototype.handleMove=function(o,n,r,q,p){if(q){var m=[q.seriesIndex,q.pointIndex,q.data];p.target.trigger("jqplotDataMouseOver",m);if(p.series[m[0]].highlightMouseOver&&!(m[0]==p.plugins.pieRenderer.highlightedSeriesIndex&&m[1]==p.series[m[0]]._highlightedPoint)){p.target.trigger("jqplotDataHighlight",m);d(p,m[0],m[1])}}else{if(q==null){i(p)}}};function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.legend=n.legend||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==e.jqplot.PieRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==e.jqplot.PieRenderer){m=true}}}}if(m){n.axesDefaults.renderer=e.jqplot.PieAxisRenderer;n.legend.renderer=e.jqplot.PieLegendRenderer;n.legend.preDraw=true;n.seriesDefaults.pointLabels={show:false}}}function g(p,o,m){for(var n=0;n<this.series.length;n++){if(this.series[n].renderer.constructor==e.jqplot.PieRenderer){if(this.series[n].highlightMouseOver){this.series[n].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(q){i(q.data.plot)})}function k(m){for(var n=0;n<this.series.length;n++){this.series[n].seriesColors=this.seriesColors;this.series[n].colorGenerator=this.colorGenerator}}function d(q,p,o){var n=q.series[p];var m=q.plugins.pieRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);n._highlightedPoint=o;q.plugins.pieRenderer.highlightedSeriesIndex=p;n.renderer.drawSlice.call(n,m._ctx,n._sliceAngles[o][0],n._sliceAngles[o][1],n.highlightColorGenerator.get(o),false)}function i(o){var m=o.plugins.pieRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<o.series.length;n++){o.series[n]._highlightedPoint=null}o.plugins.pieRenderer.highlightedSeriesIndex=null;o.target.trigger("jqplotDataUnhighlight")}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataMouseOver");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.pieRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=q.pageX;m.pageY=q.pageY;r.target.trigger(m,o);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function b(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];if(q.series[n[0]].highlightMouseDown&&!(n[0]==q.plugins.pieRenderer.highlightedSeriesIndex&&n[1]==q.series[n[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n);d(q,n[0],n[1])}}else{if(r==null){i(q)}}}function j(o,n,r,q,p){var m=p.plugins.pieRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function f(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];var m=jQuery.Event("jqplotDataClick");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n)}}function l(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var m=r.plugins.pieRenderer.highlightedSeriesIndex;if(m!=null&&r.series[m].highlightMouseDown){i(r)}var n=jQuery.Event("jqplotDataRightClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function h(){this.plugins.pieRenderer={highlightedSeriesIndex:null};this.plugins.pieRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var n=e(this.targetId+" .jqplot-data-label");if(n.length){e(n[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions))}else{this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions))}var m=this.plugins.pieRenderer.highlightCanvas.setContext()}e.jqplot.preInitHooks.push(c);e.jqplot.PieTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.PieTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.PieTickRenderer.prototype.constructor=e.jqplot.PieTickRenderer})(jQuery);
|
data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js
DELETED
@@ -1,337 +0,0 @@
|
|
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.PointLabels
|
34
|
-
* Plugin for putting labels at the data points.
|
35
|
-
*
|
36
|
-
* To use this plugin, include the js
|
37
|
-
* file in your source:
|
38
|
-
*
|
39
|
-
* > <script type="text/javascript" src="plugins/jqplot.pointLabels.js"></script>
|
40
|
-
*
|
41
|
-
* By default, the last value in the data ponit array in the data series is used
|
42
|
-
* for the label. For most series renderers, extra data can be added to the
|
43
|
-
* data point arrays and the last value will be used as the label.
|
44
|
-
*
|
45
|
-
* For instance,
|
46
|
-
* this series:
|
47
|
-
*
|
48
|
-
* > [[1,4], [3,5], [7,2]]
|
49
|
-
*
|
50
|
-
* Would, by default, use the y values in the labels.
|
51
|
-
* Extra data can be added to the series like so:
|
52
|
-
*
|
53
|
-
* > [[1,4,'mid'], [3 5,'hi'], [7,2,'low']]
|
54
|
-
*
|
55
|
-
* And now the point labels would be 'mid', 'low', and 'hi'.
|
56
|
-
*
|
57
|
-
* Options to the point labels and a custom labels array can be passed into the
|
58
|
-
* "pointLabels" option on the series option like so:
|
59
|
-
*
|
60
|
-
* > series:[{pointLabels:{
|
61
|
-
* > labels:['mid', 'hi', 'low'],
|
62
|
-
* > location:'se',
|
63
|
-
* > ypadding: 12
|
64
|
-
* > }
|
65
|
-
* > }]
|
66
|
-
*
|
67
|
-
* A custom labels array in the options takes precendence over any labels
|
68
|
-
* in the series data. If you have a custom labels array in the options,
|
69
|
-
* but still want to use values from the series array as labels, set the
|
70
|
-
* "labelsFromSeries" option to true.
|
71
|
-
*
|
72
|
-
* By default, html entities (<, >, etc.) are escaped in point labels.
|
73
|
-
* If you want to include actual html markup in the labels,
|
74
|
-
* set the "escapeHTML" option to false.
|
75
|
-
*
|
76
|
-
*/
|
77
|
-
$.jqplot.PointLabels = function(options) {
|
78
|
-
// Group: Properties
|
79
|
-
//
|
80
|
-
// prop: show
|
81
|
-
// show the labels or not.
|
82
|
-
this.show = $.jqplot.config.enablePlugins;
|
83
|
-
// prop: location
|
84
|
-
// compass location where to position the label around the point.
|
85
|
-
// 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
|
86
|
-
this.location = 'n';
|
87
|
-
// prop: labelsFromSeries
|
88
|
-
// true to use labels within data point arrays.
|
89
|
-
this.labelsFromSeries = false;
|
90
|
-
// prop: seriesLabelIndex
|
91
|
-
// array index for location of labels within data point arrays.
|
92
|
-
// if null, will use the last element of the data point array.
|
93
|
-
this.seriesLabelIndex = null;
|
94
|
-
// prop: labels
|
95
|
-
// array of arrays of labels, one array for each series.
|
96
|
-
this.labels = [];
|
97
|
-
// actual labels that will get displayed.
|
98
|
-
// needed to preserve user specified labels in labels array.
|
99
|
-
this._labels = [];
|
100
|
-
// prop: stackedValue
|
101
|
-
// true to display value as stacked in a stacked plot.
|
102
|
-
// no effect if labels is specified.
|
103
|
-
this.stackedValue = false;
|
104
|
-
// prop: ypadding
|
105
|
-
// vertical padding in pixels between point and label
|
106
|
-
this.ypadding = 6;
|
107
|
-
// prop: xpadding
|
108
|
-
// horizontal padding in pixels between point and label
|
109
|
-
this.xpadding = 6;
|
110
|
-
// prop: escapeHTML
|
111
|
-
// true to escape html entities in the labels.
|
112
|
-
// If you want to include markup in the labels, set to false.
|
113
|
-
this.escapeHTML = true;
|
114
|
-
// prop: edgeTolerance
|
115
|
-
// Number of pixels that the label must be away from an axis
|
116
|
-
// boundary in order to be drawn. Negative values will allow overlap
|
117
|
-
// with the grid boundaries.
|
118
|
-
this.edgeTolerance = -5;
|
119
|
-
// prop: formatter
|
120
|
-
// A class of a formatter for the tick text. sprintf by default.
|
121
|
-
this.formatter = $.jqplot.DefaultTickFormatter;
|
122
|
-
// prop: formatString
|
123
|
-
// string passed to the formatter.
|
124
|
-
this.formatString = '';
|
125
|
-
// prop: hideZeros
|
126
|
-
// true to not show a label for a value which is 0.
|
127
|
-
this.hideZeros = false;
|
128
|
-
this._elems = [];
|
129
|
-
|
130
|
-
$.extend(true, this, options);
|
131
|
-
};
|
132
|
-
|
133
|
-
var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
|
134
|
-
var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
|
135
|
-
var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
|
136
|
-
|
137
|
-
// called with scope of a series
|
138
|
-
$.jqplot.PointLabels.init = function (target, data, seriesDefaults, opts){
|
139
|
-
var options = $.extend(true, {}, seriesDefaults, opts);
|
140
|
-
options.pointLabels = options.pointLabels || {};
|
141
|
-
if (this.renderer.constructor == $.jqplot.BarRenderer && this.barDirection == 'horizontal' && !options.pointLabels.location) {
|
142
|
-
options.pointLabels.location = 'e';
|
143
|
-
}
|
144
|
-
// add a pointLabels attribute to the series plugins
|
145
|
-
this.plugins.pointLabels = new $.jqplot.PointLabels(options.pointLabels);
|
146
|
-
this.plugins.pointLabels.setLabels.call(this);
|
147
|
-
};
|
148
|
-
|
149
|
-
// called with scope of series
|
150
|
-
$.jqplot.PointLabels.prototype.setLabels = function() {
|
151
|
-
var p = this.plugins.pointLabels;
|
152
|
-
var labelIdx;
|
153
|
-
if (p.seriesLabelIndex != null) {
|
154
|
-
labelIdx = p.seriesLabelIndex;
|
155
|
-
}
|
156
|
-
else if (this.renderer.constructor == $.jqplot.BarRenderer && this.barDirection == 'horizontal') {
|
157
|
-
labelIdx = 0;
|
158
|
-
}
|
159
|
-
else {
|
160
|
-
labelIdx = this._plotData[0].length -1;
|
161
|
-
}
|
162
|
-
p._labels = [];
|
163
|
-
if (p.labels.length == 0 || p.labelsFromSeries) {
|
164
|
-
if (p.stackedValue) {
|
165
|
-
if (this._plotData.length && this._plotData[0].length){
|
166
|
-
// var idx = p.seriesLabelIndex || this._plotData[0].length -1;
|
167
|
-
for (var i=0; i<this._plotData.length; i++) {
|
168
|
-
p._labels.push(this._plotData[i][labelIdx]);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
}
|
172
|
-
else {
|
173
|
-
var d = this.data;
|
174
|
-
if (this.renderer.constructor == $.jqplot.BarRenderer && this.waterfall) {
|
175
|
-
d = this._data;
|
176
|
-
}
|
177
|
-
if (d.length && d[0].length) {
|
178
|
-
// var idx = p.seriesLabelIndex || d[0].length -1;
|
179
|
-
for (var i=0; i<d.length; i++) {
|
180
|
-
p._labels.push(d[i][labelIdx]);
|
181
|
-
}
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
else if (p.labels.length){
|
186
|
-
p._labels = p.labels;
|
187
|
-
}
|
188
|
-
};
|
189
|
-
|
190
|
-
$.jqplot.PointLabels.prototype.xOffset = function(elem, location, padding) {
|
191
|
-
location = location || this.location;
|
192
|
-
padding = padding || this.xpadding;
|
193
|
-
var offset;
|
194
|
-
|
195
|
-
switch (location) {
|
196
|
-
case 'nw':
|
197
|
-
offset = -elem.outerWidth(true) - this.xpadding;
|
198
|
-
break;
|
199
|
-
case 'n':
|
200
|
-
offset = -elem.outerWidth(true)/2;
|
201
|
-
break;
|
202
|
-
case 'ne':
|
203
|
-
offset = this.xpadding;
|
204
|
-
break;
|
205
|
-
case 'e':
|
206
|
-
offset = this.xpadding;
|
207
|
-
break;
|
208
|
-
case 'se':
|
209
|
-
offset = this.xpadding;
|
210
|
-
break;
|
211
|
-
case 's':
|
212
|
-
offset = -elem.outerWidth(true)/2;
|
213
|
-
break;
|
214
|
-
case 'sw':
|
215
|
-
offset = -elem.outerWidth(true) - this.xpadding;
|
216
|
-
break;
|
217
|
-
case 'w':
|
218
|
-
offset = -elem.outerWidth(true) - this.xpadding;
|
219
|
-
break;
|
220
|
-
default: // same as 'nw'
|
221
|
-
offset = -elem.outerWidth(true) - this.xpadding;
|
222
|
-
break;
|
223
|
-
}
|
224
|
-
return offset;
|
225
|
-
};
|
226
|
-
|
227
|
-
$.jqplot.PointLabels.prototype.yOffset = function(elem, location, padding) {
|
228
|
-
location = location || this.location;
|
229
|
-
padding = padding || this.xpadding;
|
230
|
-
var offset;
|
231
|
-
|
232
|
-
switch (location) {
|
233
|
-
case 'nw':
|
234
|
-
offset = -elem.outerHeight(true) - this.ypadding;
|
235
|
-
break;
|
236
|
-
case 'n':
|
237
|
-
offset = -elem.outerHeight(true) - this.ypadding;
|
238
|
-
break;
|
239
|
-
case 'ne':
|
240
|
-
offset = -elem.outerHeight(true) - this.ypadding;
|
241
|
-
break;
|
242
|
-
case 'e':
|
243
|
-
offset = -elem.outerHeight(true)/2;
|
244
|
-
break;
|
245
|
-
case 'se':
|
246
|
-
offset = this.ypadding;
|
247
|
-
break;
|
248
|
-
case 's':
|
249
|
-
offset = this.ypadding;
|
250
|
-
break;
|
251
|
-
case 'sw':
|
252
|
-
offset = this.ypadding;
|
253
|
-
break;
|
254
|
-
case 'w':
|
255
|
-
offset = -elem.outerHeight(true)/2;
|
256
|
-
break;
|
257
|
-
default: // same as 'nw'
|
258
|
-
offset = -elem.outerHeight(true) - this.ypadding;
|
259
|
-
break;
|
260
|
-
}
|
261
|
-
return offset;
|
262
|
-
};
|
263
|
-
|
264
|
-
// called with scope of series
|
265
|
-
$.jqplot.PointLabels.draw = function (sctx, options) {
|
266
|
-
var p = this.plugins.pointLabels;
|
267
|
-
// set labels again in case they have changed.
|
268
|
-
p.setLabels.call(this);
|
269
|
-
// remove any previous labels
|
270
|
-
for (var i=0; i<p._elems.length; i++) {
|
271
|
-
p._elems[i].remove();
|
272
|
-
}
|
273
|
-
if (p.show) {
|
274
|
-
var ax = '_'+this._stackAxis+'axis';
|
275
|
-
|
276
|
-
if (!p.formatString) {
|
277
|
-
p.formatString = this[ax]._ticks[0].formatString;
|
278
|
-
p.formatter = this[ax]._ticks[0].formatter;
|
279
|
-
}
|
280
|
-
|
281
|
-
var pd = this._plotData;
|
282
|
-
var xax = this._xaxis;
|
283
|
-
var yax = this._yaxis;
|
284
|
-
|
285
|
-
for (var i=p._labels.length-1; i>=0; i--) {
|
286
|
-
var label = p._labels[i];
|
287
|
-
|
288
|
-
if (p.hideZeros && parseInt(p._labels[i], 10) == 0) {
|
289
|
-
label = '';
|
290
|
-
}
|
291
|
-
|
292
|
-
if (label != null) {
|
293
|
-
label = p.formatter(p.formatString, label);
|
294
|
-
}
|
295
|
-
var elem = $('<div class="jqplot-point-label jqplot-series-'+this.index+' jqplot-point-'+i+'" style="position:absolute"></div>');
|
296
|
-
elem.insertAfter(sctx.canvas);
|
297
|
-
p._elems.push(elem);
|
298
|
-
if (p.escapeHTML) {
|
299
|
-
elem.text(label);
|
300
|
-
}
|
301
|
-
else {
|
302
|
-
elem.html(label);
|
303
|
-
}
|
304
|
-
var location = p.location;
|
305
|
-
if ((this.fillToZero && pd[i][1] < 0) || (this.waterfall && parseInt(label, 10)) < 0) {
|
306
|
-
location = oppositeLocations[locationIndicies[location]];
|
307
|
-
}
|
308
|
-
var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location);
|
309
|
-
var elt = yax.u2p(pd[i][1]) + p.yOffset(elem, location);
|
310
|
-
if (this.renderer.constructor == $.jqplot.BarRenderer) {
|
311
|
-
if (this.barDirection == "vertical") {
|
312
|
-
ell += this._barNudge;
|
313
|
-
}
|
314
|
-
else {
|
315
|
-
elt -= this._barNudge;
|
316
|
-
}
|
317
|
-
}
|
318
|
-
elem.css('left', ell);
|
319
|
-
elem.css('top', elt);
|
320
|
-
var elr = ell + $(elem).width();
|
321
|
-
var elb = elt + $(elem).height();
|
322
|
-
var et = p.edgeTolerance;
|
323
|
-
var scl = $(sctx.canvas).position().left;
|
324
|
-
var sct = $(sctx.canvas).position().top;
|
325
|
-
var scr = sctx.canvas.width + scl;
|
326
|
-
var scb = sctx.canvas.height + sct;
|
327
|
-
// if label is outside of allowed area, remove it
|
328
|
-
if (ell - et < scl || elt - et < sct || elr + et > scr || elb + et > scb) {
|
329
|
-
$(elem).detach();
|
330
|
-
}
|
331
|
-
}
|
332
|
-
}
|
333
|
-
};
|
334
|
-
|
335
|
-
$.jqplot.postSeriesInitHooks.push($.jqplot.PointLabels.init);
|
336
|
-
$.jqplot.postDrawSeriesHooks.push($.jqplot.PointLabels.draw);
|
337
|
-
})(jQuery);
|
data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js
DELETED
@@ -1,30 +0,0 @@
|
|
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(c){c.jqplot.PointLabels=function(e){this.show=c.jqplot.config.enablePlugins;this.location="n";this.labelsFromSeries=false;this.seriesLabelIndex=null;this.labels=[];this._labels=[];this.stackedValue=false;this.ypadding=6;this.xpadding=6;this.escapeHTML=true;this.edgeTolerance=-5;this.formatter=c.jqplot.DefaultTickFormatter;this.formatString="";this.hideZeros=false;this._elems=[];c.extend(true,this,e)};var a=["nw","n","ne","e","se","s","sw","w"];var d={nw:0,n:1,ne:2,e:3,se:4,s:5,sw:6,w:7};var b=["se","s","sw","w","nw","n","ne","e"];c.jqplot.PointLabels.init=function(i,h,f,g){var e=c.extend(true,{},f,g);e.pointLabels=e.pointLabels||{};if(this.renderer.constructor==c.jqplot.BarRenderer&&this.barDirection=="horizontal"&&!e.pointLabels.location){e.pointLabels.location="e"}this.plugins.pointLabels=new c.jqplot.PointLabels(e.pointLabels);this.plugins.pointLabels.setLabels.call(this)};c.jqplot.PointLabels.prototype.setLabels=function(){var f=this.plugins.pointLabels;var h;if(f.seriesLabelIndex!=null){h=f.seriesLabelIndex}else{if(this.renderer.constructor==c.jqplot.BarRenderer&&this.barDirection=="horizontal"){h=0}else{h=this._plotData[0].length-1}}f._labels=[];if(f.labels.length==0||f.labelsFromSeries){if(f.stackedValue){if(this._plotData.length&&this._plotData[0].length){for(var e=0;e<this._plotData.length;e++){f._labels.push(this._plotData[e][h])}}}else{var g=this.data;if(this.renderer.constructor==c.jqplot.BarRenderer&&this.waterfall){g=this._data}if(g.length&&g[0].length){for(var e=0;e<g.length;e++){f._labels.push(g[e][h])}}}}else{if(f.labels.length){f._labels=f.labels}}};c.jqplot.PointLabels.prototype.xOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerWidth(true)-this.xpadding;break;case"n":h=-f.outerWidth(true)/2;break;case"ne":h=this.xpadding;break;case"e":h=this.xpadding;break;case"se":h=this.xpadding;break;case"s":h=-f.outerWidth(true)/2;break;case"sw":h=-f.outerWidth(true)-this.xpadding;break;case"w":h=-f.outerWidth(true)-this.xpadding;break;default:h=-f.outerWidth(true)-this.xpadding;break}return h};c.jqplot.PointLabels.prototype.yOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerHeight(true)-this.ypadding;break;case"n":h=-f.outerHeight(true)-this.ypadding;break;case"ne":h=-f.outerHeight(true)-this.ypadding;break;case"e":h=-f.outerHeight(true)/2;break;case"se":h=this.ypadding;break;case"s":h=this.ypadding;break;case"sw":h=this.ypadding;break;case"w":h=-f.outerHeight(true)/2;break;default:h=-f.outerHeight(true)-this.ypadding;break}return h};c.jqplot.PointLabels.draw=function(t,h){var r=this.plugins.pointLabels;r.setLabels.call(this);for(var s=0;s<r._elems.length;s++){r._elems[s].remove()}if(r.show){var o="_"+this._stackAxis+"axis";if(!r.formatString){r.formatString=this[o]._ticks[0].formatString;r.formatter=this[o]._ticks[0].formatter}var z=this._plotData;var w=this._xaxis;var n=this._yaxis;for(var s=r._labels.length-1;s>=0;s--){var m=r._labels[s];if(r.hideZeros&&parseInt(r._labels[s],10)==0){m=""}if(m!=null){m=r.formatter(r.formatString,m)}var v=c('<div class="jqplot-point-label jqplot-series-'+this.index+" jqplot-point-"+s+'" style="position:absolute"></div>');v.insertAfter(t.canvas);r._elems.push(v);if(r.escapeHTML){v.text(m)}else{v.html(m)}var f=r.location;if((this.fillToZero&&z[s][1]<0)||(this.waterfall&&parseInt(m,10))<0){f=b[d[f]]}var l=w.u2p(z[s][0])+r.xOffset(v,f);var g=n.u2p(z[s][1])+r.yOffset(v,f);if(this.renderer.constructor==c.jqplot.BarRenderer){if(this.barDirection=="vertical"){l+=this._barNudge}else{g-=this._barNudge}}v.css("left",l);v.css("top",g);var j=l+c(v).width();var q=g+c(v).height();var y=r.edgeTolerance;var e=c(t.canvas).position().left;var u=c(t.canvas).position().top;var x=t.canvas.width+e;var k=t.canvas.height+u;if(l-y<e||g-y<u||j+y>x||q+y>k){c(v).detach()}}}};c.jqplot.postSeriesInitHooks.push(c.jqplot.PointLabels.init);c.jqplot.postDrawSeriesHooks.push(c.jqplot.PointLabels.draw)})(jQuery);
|
data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js
DELETED
@@ -1,220 +0,0 @@
|
|
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.Trendline
|
34
|
-
* Plugin which will automatically compute and draw trendlines for plotted data.
|
35
|
-
*/
|
36
|
-
$.jqplot.Trendline = function() {
|
37
|
-
// Group: Properties
|
38
|
-
|
39
|
-
// prop: show
|
40
|
-
// Wether or not to show the trend line.
|
41
|
-
this.show = $.jqplot.config.enablePlugins;
|
42
|
-
// prop: color
|
43
|
-
// CSS color spec for the trend line.
|
44
|
-
// By default this wil be the same color as the primary line.
|
45
|
-
this.color = '#666666';
|
46
|
-
// prop: renderer
|
47
|
-
// Renderer to use to draw the trend line.
|
48
|
-
// The data series that is plotted may not be rendered as a line.
|
49
|
-
// Therefore, we use our own line renderer here to draw a trend line.
|
50
|
-
this.renderer = new $.jqplot.LineRenderer();
|
51
|
-
// prop: rendererOptions
|
52
|
-
// Options to pass to the line renderer.
|
53
|
-
// By default, markers are not shown on trend lines.
|
54
|
-
this.rendererOptions = {marker:{show:false}};
|
55
|
-
// prop: label
|
56
|
-
// Label for the trend line to use in the legend.
|
57
|
-
this.label = '';
|
58
|
-
// prop: type
|
59
|
-
// Either 'exponential', 'exp', or 'linear'.
|
60
|
-
this.type = 'linear';
|
61
|
-
// prop: shadow
|
62
|
-
// true or false, wether or not to show the shadow.
|
63
|
-
this.shadow = true;
|
64
|
-
// prop: markerRenderer
|
65
|
-
// Renderer to use to draw markers on the line.
|
66
|
-
// I think this is wrong.
|
67
|
-
this.markerRenderer = {show:false};
|
68
|
-
// prop: lineWidth
|
69
|
-
// Width of the trend line.
|
70
|
-
this.lineWidth = 1.5;
|
71
|
-
// prop: shadowAngle
|
72
|
-
// Angle of the shadow on the trend line.
|
73
|
-
this.shadowAngle = 45;
|
74
|
-
// prop: shadowOffset
|
75
|
-
// pixel offset for each stroke of the shadow.
|
76
|
-
this.shadowOffset = 1.0;
|
77
|
-
// prop: shadowAlpha
|
78
|
-
// Alpha transparency of the shadow.
|
79
|
-
this.shadowAlpha = 0.07;
|
80
|
-
// prop: shadowDepth
|
81
|
-
// number of strokes to make of the shadow.
|
82
|
-
this.shadowDepth = 3;
|
83
|
-
this.isTrendline = true;
|
84
|
-
|
85
|
-
};
|
86
|
-
|
87
|
-
$.jqplot.postSeriesInitHooks.push(parseTrendLineOptions);
|
88
|
-
$.jqplot.postDrawSeriesHooks.push(drawTrendline);
|
89
|
-
$.jqplot.addLegendRowHooks.push(addTrendlineLegend);
|
90
|
-
|
91
|
-
// called witin scope of the legend object
|
92
|
-
// current series passed in
|
93
|
-
// must return null or an object {label:label, color:color}
|
94
|
-
function addTrendlineLegend(series) {
|
95
|
-
var lt = series.trendline.label.toString();
|
96
|
-
var ret = null;
|
97
|
-
if (this.renderer.constructor != $.jqplot.PieRenderer && series.trendline.show && lt) {
|
98
|
-
ret = {label:lt, color:series.trendline.color};
|
99
|
-
}
|
100
|
-
return ret;
|
101
|
-
}
|
102
|
-
|
103
|
-
// called within scope of a series
|
104
|
-
function parseTrendLineOptions (target, data, seriesDefaults, options, plot) {
|
105
|
-
if (this.renderer.constructor == $.jqplot.LineRenderer) {
|
106
|
-
this.trendline = new $.jqplot.Trendline();
|
107
|
-
options = options || {};
|
108
|
-
$.extend(true, this.trendline, {color:this.color}, seriesDefaults.trendline, options.trendline);
|
109
|
-
this.trendline.renderer.init.call(this.trendline, null);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
// called within scope of series object
|
114
|
-
function drawTrendline(sctx, options) {
|
115
|
-
// if we have options, merge trendline options in with precedence
|
116
|
-
options = $.extend(true, {}, this.trendline, options);
|
117
|
-
|
118
|
-
if (options.show && this.renderer.constructor != $.jqplot.PieRenderer) {
|
119
|
-
var fit;
|
120
|
-
// this.renderer.setGridData.call(this);
|
121
|
-
var data = options.data || this.data;
|
122
|
-
fit = fitData(data, this.trendline.type);
|
123
|
-
var gridData = options.gridData || this.renderer.makeGridData.call(this, fit.data);
|
124
|
-
this.trendline.renderer.draw.call(this.trendline, sctx, gridData, {showLine:true, shadow:this.trendline.shadow});
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
function regression(x, y, typ) {
|
129
|
-
var type = (typ == null) ? 'linear' : typ;
|
130
|
-
var N = x.length;
|
131
|
-
var slope;
|
132
|
-
var intercept;
|
133
|
-
var SX = 0;
|
134
|
-
var SY = 0;
|
135
|
-
var SXX = 0;
|
136
|
-
var SXY = 0;
|
137
|
-
var SYY = 0;
|
138
|
-
var Y = [];
|
139
|
-
var X = [];
|
140
|
-
|
141
|
-
if (type == 'linear') {
|
142
|
-
X = x;
|
143
|
-
Y = y;
|
144
|
-
}
|
145
|
-
else if (type == 'exp' || type == 'exponential') {
|
146
|
-
for ( var i=0; i<y.length; i++) {
|
147
|
-
// ignore points <= 0, log undefined.
|
148
|
-
if (y[i] <= 0) {
|
149
|
-
N--;
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
X.push(x[i]);
|
153
|
-
Y.push(Math.log(y[i]));
|
154
|
-
}
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
for ( var i = 0; i < N; i++) {
|
159
|
-
SX = SX + X[i];
|
160
|
-
SY = SY + Y[i];
|
161
|
-
SXY = SXY + X[i]* Y[i];
|
162
|
-
SXX = SXX + X[i]* X[i];
|
163
|
-
SYY = SYY + Y[i]* Y[i];
|
164
|
-
}
|
165
|
-
|
166
|
-
slope = (N*SXY - SX*SY)/(N*SXX - SX*SX);
|
167
|
-
intercept = (SY - slope*SX)/N;
|
168
|
-
|
169
|
-
return [slope, intercept];
|
170
|
-
}
|
171
|
-
|
172
|
-
function linearRegression(X,Y) {
|
173
|
-
var ret;
|
174
|
-
ret = regression(X,Y,'linear');
|
175
|
-
return [ret[0],ret[1]];
|
176
|
-
}
|
177
|
-
|
178
|
-
function expRegression(X,Y) {
|
179
|
-
var ret;
|
180
|
-
var x = X;
|
181
|
-
var y = Y;
|
182
|
-
ret = regression(x, y,'exp');
|
183
|
-
var base = Math.exp(ret[0]);
|
184
|
-
var coeff = Math.exp(ret[1]);
|
185
|
-
return [base, coeff];
|
186
|
-
}
|
187
|
-
|
188
|
-
function fitData(data, typ) {
|
189
|
-
var type = (typ == null) ? 'linear' : typ;
|
190
|
-
var ret;
|
191
|
-
var res;
|
192
|
-
var x = [];
|
193
|
-
var y = [];
|
194
|
-
var ypred = [];
|
195
|
-
|
196
|
-
for (i=0; i<data.length; i++){
|
197
|
-
if (data[i] != null && data[i][0] != null && data[i][1] != null) {
|
198
|
-
x.push(data[i][0]);
|
199
|
-
y.push(data[i][1]);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
if (type == 'linear') {
|
204
|
-
ret = linearRegression(x,y);
|
205
|
-
for ( var i=0; i<x.length; i++){
|
206
|
-
res = ret[0]*x[i] + ret[1];
|
207
|
-
ypred.push([x[i], res]);
|
208
|
-
}
|
209
|
-
}
|
210
|
-
else if (type == 'exp' || type == 'exponential') {
|
211
|
-
ret = expRegression(x,y);
|
212
|
-
for ( var i=0; i<x.length; i++){
|
213
|
-
res = ret[1]*Math.pow(ret[0],x[i]);
|
214
|
-
ypred.push([x[i], res]);
|
215
|
-
}
|
216
|
-
}
|
217
|
-
return {data: ypred, slope: ret[0], intercept: ret[1]};
|
218
|
-
}
|
219
|
-
|
220
|
-
})(jQuery);
|