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.
Files changed (71) hide show
  1. data/README.rdoc +2 -4
  2. data/Rakefile +0 -22
  3. data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
  4. data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
  5. data/lib/generators/sunrise/votes/install_generator.rb +1 -1
  6. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
  7. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
  8. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
  9. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
  10. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
  11. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
  12. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
  13. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
  14. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
  15. data/lib/sunrise/votes/version.rb +1 -1
  16. metadata +33 -79
  17. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
  18. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
  19. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
  20. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
  21. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
  22. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
  23. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
  24. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
  25. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
  26. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
  27. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
  28. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
  29. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
  30. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
  31. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
  32. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
  33. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
  34. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
  35. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
  36. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
  37. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
  38. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
  39. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
  40. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
  41. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
  42. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
  43. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
  44. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
  45. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
  46. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
  47. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
  48. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
  49. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
  50. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
  51. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
  52. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
  53. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
  54. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
  55. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
  56. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
  57. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
  58. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
  59. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
  60. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
  61. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
  62. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
  63. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
  64. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
  65. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
  66. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
  67. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
  68. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
  69. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
  70. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
  71. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +0 -30
@@ -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.MeterGaugeRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.MeterGaugeRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.MeterGaugeRenderer.prototype.constructor=c.jqplot.MeterGaugeRenderer;c.jqplot.MeterGaugeRenderer.prototype.init=function(e){this.diameter=null;this.padding=null;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=4;this.background="#efefef";this.ringColor="#BBC6D0";this.needleColor="#C3D3E5";this.tickColor="989898";this.ringWidth=null;this.min;this.max;this.ticks=[];this.showTicks=true;this.showTickLabels=true;this.label=null;this.labelHeightAdjust=0;this.labelPosition="inside";this.intervals=[];this.intervalColors=["#4bb2c5","#EAA228","#c5b47f","#579575","#839557","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc","#c747a3","#cddf54","#FBD178","#26B4E3","#bd70c7"];this.intervalInnerRadius=null;this.intervalOuterRadius=null;this.tickRenderer=c.jqplot.MeterGaugeTickRenderer;this.tickPositions=[1,2,2.5,5,10];this.tickSpacing=30;this.numberMinorTicks=null;this.hubRadius=null;this.tickPadding=null;this.needleThickness=null;this.needlePad=6;this.pegNeedle=true;this._type="meterGauge";c.extend(true,this,e);this.type=null;this.numberTicks=null;this.tickInterval=null;this.span=180;if(this.type=="circular"){this.semiCircular=false}else{if(this.type!="circular"){this.semiCircular=true}else{this.semiCircular=(this.span<=180)?true:false}}this._tickPoints=[];this._labelElm=null;this.startAngle=(90+(360-this.span)/2)*Math.PI/180;this.endAngle=(90-(360-this.span)/2)*Math.PI/180;this.setmin=!!(this.min==null);this.setmax=!!(this.max==null);if(this.intervals.length){if(this.intervals[0].length==null||this.intervals.length==1){for(var f=0;f<this.intervals.length;f++){this.intervals[f]=[this.intervals[f],this.intervals[f],this.intervalColors[f]]}}else{if(this.intervals[0].length==2){for(f=0;f<this.intervals.length;f++){this.intervals[f]=[this.intervals[f][0],this.intervals[f][1],this.intervalColors[f]]}}}}if(this.ticks.length){if(this.ticks[0].length==null||this.ticks[0].length==1){for(var f=0;f<this.ticks.length;f++){this.ticks[f]=[this.ticks[f],this.ticks[f]]}}this.min=(this.min==null)?this.ticks[0][0]:this.min;this.max=(this.max==null)?this.ticks[this.ticks.length-1][0]:this.max;this.setmin=false;this.setmax=false;this.numberTicks=this.ticks.length;this.tickInterval=this.ticks[1][0]-this.ticks[0][0];this.tickFactor=Math.floor(parseFloat((Math.log(this.tickInterval)/Math.log(10)).toFixed(11)));this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}if(!this.numberMinorTicks){this.numberMinorTicks=1}}else{if(this.intervals.length){this.min=(this.min==null)?0:this.min;this.setmin=false;if(this.max==null){if(this.intervals[this.intervals.length-1][0]>=this.data[0][1]){this.max=this.intervals[this.intervals.length-1][0];this.setmax=false}}else{this.setmax=false}}else{this.min=(this.min==null)?0:this.min;this.setmin=false;if(this.max==null){this.max=this.data[0][1]*1.25;this.setmax=true}else{this.setmax=false}}}};c.jqplot.MeterGaugeRenderer.prototype.setGridData=function(j){var f=[];var k=[];var e=this.startAngle;for(var h=0;h<this.data.length;h++){f.push(this.data[h][1]);k.push([this.data[h][0]]);if(h>0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h<f.length;h++){k[h][1]=f[h]*g}this.gridData=k};c.jqplot.MeterGaugeRenderer.prototype.makeGridData=function(j,k){var f=[];var l=[];var e=this.startAngle;for(var h=0;h<j.length;h++){f.push(j[h][1]);l.push([j[h][0]]);if(h>0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h<f.length;h++){l[h][1]=f[h]*g}return l};function b(j,f,g){var e;for(var h=j.length-1;h>=0;h--){e=f/(j[h]*Math.pow(10,g));if(e==4||e==5){return e-1}}return null}c.jqplot.MeterGaugeRenderer.prototype.draw=function(X,aC,ap){var aa;var aM=(ap!=undefined)?ap:{};var ai=0;var ah=0;var at=1;if(ap.legendInfo&&ap.legendInfo.placement=="inside"){var aI=ap.legendInfo;switch(aI.location){case"nw":ai=aI.width+aI.xoffset;break;case"w":ai=aI.width+aI.xoffset;break;case"sw":ai=aI.width+aI.xoffset;break;case"ne":ai=aI.width+aI.xoffset;at=-1;break;case"e":ai=aI.width+aI.xoffset;at=-1;break;case"se":ai=aI.width+aI.xoffset;at=-1;break;case"n":ah=aI.height+aI.yoffset;break;case"s":ah=aI.height+aI.yoffset;at=-1;break;default:break}}if(this.label){this._labelElem=c('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+"</div>");this.canvas._elem.after(this._labelElem)}var m=(aM.shadow!=undefined)?aM.shadow:this.shadow;var N=(aM.showLine!=undefined)?aM.showLine:this.showLine;var I=(aM.fill!=undefined)?aM.fill:this.fill;var K=X.canvas.width;var S=X.canvas.height;if(this.padding==null){this.padding=Math.round(Math.min(K,S)/30)}var Q=K-ai-2*this.padding;var ab=S-ah-2*this.padding;if(this.labelPosition=="bottom"&&this.label){ab-=this._labelElem.outerHeight(true)}var L=Math.min(Q,ab);var ad=L;if(!this.diameter){if(this.semiCircular){if(Q>=2*ab){if(!this.ringWidth){this.ringWidth=2*ab/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=2*(ab-2*this.innerPad)}else{if(!this.ringWidth){this.ringWidth=Q/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=Q-2*this.innerPad}this._center=[(K-at*ai)/2+at*ai,(S+at*ah-this.padding-this.ringWidth-this.innerPad)]}else{if(!this.ringWidth){this.ringWidth=ad/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=0;this.diameter=ad-this.ringWidth;this._center=[(K-at*ai)/2+at*ai,(S-at*ah)/2+at*ah]}}if(this._labelElem&&this.labelPosition=="bottom"){this._center[1]-=this._labelElem.outerHeight(true)}this._radius=this.diameter/2;this.tickSpacing=6000/this.diameter;if(!this.hubRadius){this.hubRadius=this.diameter/18}this.shadowOffset=0.5+this.ringWidth/9;this.shadowWidth=this.ringWidth*1;this.tickPadding=3+Math.pow(this.diameter/20,0.7);this.tickOuterRadius=this._radius-this.ringWidth/2-this.tickPadding;this.tickLength=(this.showTicks)?this._radius/13:0;if(this.ticks.length==0){var A=this.max,aL=this.min,q=this.setmax,aG=this.setmin,au=(A-aL)*this.tickSpacing/this.span;var aw=Math.floor(parseFloat((Math.log(au)/Math.log(10)).toFixed(11)));var an=(au/Math.pow(10,aw));(an>2&&an<=2.5)?an=2.5:an=Math.ceil(an);var T=this.tickPositions;var aA,ak;for(aa=0;aa<T.length;aa++){if(an==T[aa]||aa&&T[aa-1]<an&&an<T[aa]){au=T[aa]*Math.pow(10,aw);aA=aa}}for(aa=0;aa<T.length;aa++){if(an==T[aa]||aa&&T[aa-1]<an&&an<T[aa]){au=T[aa]*Math.pow(10,aw);ak=Math.ceil((A-aL)/au)}}if(q&&aG){var aP=(aL>0)?aL-aL%au:aL-aL%au-au;if(!this.forceZero){var D=Math.min(aL-aP,0.8*au);var o=Math.floor(D/T[aA]);if(o>1){aP=aP+T[aA]*(o-1);if(parseInt(aP,10)!=aP&&parseInt(aP-T[aA],10)==aP-T[aA]){aP=aP-T[aA]}}}if(aL==aP){aL-=au}else{if(aL-aP>0.23*au){aL=aP}else{aL=aP-au;ak+=1}}ak+=1;var E=aL+(ak-1)*au;if(A>=E){E+=au;ak+=1}if(E-A<0.23*au){E+=au;ak+=1}this.max=A=E;this.min=aL;this.tickInterval=au;this.numberTicks=ak;var O;for(aa=0;aa<ak;aa++){O=parseFloat((aL+aa*au).toFixed(11));this.ticks.push([O,O])}this.max=this.ticks[ak-1][1];this.tickFactor=aw;this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}}else{if(q){var E=aL+(ak-1)*au;if(A>=E){A=E+au;ak+=1}else{A=E}this.tickInterval=this.tickInterval||au;this.numberTicks=this.numberTicks||ak;var O;for(aa=0;aa<this.numberTicks;aa++){O=parseFloat((aL+aa*this.tickInterval).toFixed(11));this.ticks.push([O,O])}this.max=this.ticks[this.numberTicks-1][1];this.tickFactor=aw;this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}}}if(!q&&!aG){var P=this.max-this.min;aw=Math.floor(parseFloat((Math.log(P)/Math.log(10)).toFixed(11)))-1;var aN=[5,6,4,7,3,8,9,10,2],V,C,av=0,M;if(P>1){var aJ=String(P);if(aJ.search(/\./)==-1){var aF=aJ.search(/0+$/);av=(aF>0)?aJ.length-aF-1:0}}M=P/Math.pow(10,av);for(aa=0;aa<aN.length;aa++){V=M/(aN[aa]-1);if(V==parseInt(V,10)){this.numberTicks=aN[aa];this.tickInterval=P/(this.numberTicks-1);this.tickFactor=aw+1;break}}var O;for(aa=0;aa<this.numberTicks;aa++){O=parseFloat((this.min+aa*this.tickInterval).toFixed(11));this.ticks.push([O,O])}this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}if(!this.numberMinorTicks){this.numberMinorTicks=1;var aH=[4,5,3,6,2];for(aa=0;aa<5;aa++){var ao=this.tickInterval/aH[aa];if(ao==parseInt(ao,10)){this.numberMinorTicks=aH[aa]-1;break}}}}}var U=this._radius,aE=this.startAngle,k=this.endAngle,H=Math.PI,e=Math.PI/2;if(this.semiCircular){var z=Math.atan(this.innerPad/U),ac=this.outerStartAngle=aE-z,aB=this.outerEndAngle=k+z,B=this.hubStartAngle=aE-Math.atan(this.innerPad/this.hubRadius*2),af=this.hubEndAngle=k+Math.atan(this.innerPad/this.hubRadius*2);X.save();X.translate(this._center[0],this._center[1]);X.lineJoin="round";X.lineCap="round";X.save();X.beginPath();X.fillStyle=this.background;X.arc(0,0,U,ac,aB,false);X.closePath();X.fill();X.restore();var aj="rgba(0,0,0,"+this.shadowAlpha+")";X.save();for(var aa=0;aa<this.shadowDepth;aa++){X.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));X.beginPath();X.strokeStyle=aj;X.lineWidth=this.shadowWidth;X.arc(0,0,U,ac,aB,false);X.closePath();X.stroke()}X.restore();X.save();var az=parseInt((this.shadowDepth+1)/2,10);for(var aa=0;aa<az;aa++){X.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));X.beginPath();X.fillStyle=aj;X.arc(0,0,this.hubRadius,B,af,false);X.closePath();X.fill()}X.restore();X.save();X.beginPath();X.strokeStyle=this.ringColor;X.lineWidth=this.ringWidth;X.arc(0,0,U,ac,aB,false);X.closePath();X.stroke();X.restore();X.save();X.beginPath();X.fillStyle=this.ringColor;X.arc(0,0,this.hubRadius,B,af,false);X.closePath();X.fill();X.restore();if(this.showTicks){X.save();var f=this.tickOuterRadius,aq=this.tickLength,v=aq/2,F=this.numberMinorTicks,am=this.span*Math.PI/180/(this.ticks.length-1),p=am/(F+1);for(aa=0;aa<this.ticks.length;aa++){X.beginPath();X.lineWidth=1.5+this.diameter/360;X.strokeStyle=this.ringColor;var ae=am*aa+aE;X.moveTo(-f*Math.cos(am*aa+aE),f*Math.sin(am*aa+aE));X.lineTo(-(f-aq)*Math.cos(am*aa+aE),(f-aq)*Math.sin(am*aa+aE));this._tickPoints.push([(f-aq)*Math.cos(am*aa+aE)+this._center[0]+this.canvas._offsets.left,(f-aq)*Math.sin(am*aa+aE)+this._center[1]+this.canvas._offsets.top,am*aa+aE]);X.stroke();X.lineWidth=1+this.diameter/440;if(aa<this.ticks.length-1){for(var Y=1;Y<=F;Y++){X.beginPath();X.moveTo(-f*Math.cos(am*aa+p*Y+aE),f*Math.sin(am*aa+p*Y+aE));X.lineTo(-(f-v)*Math.cos(am*aa+p*Y+aE),(f-v)*Math.sin(am*aa+p*Y+aE));X.stroke()}}}X.restore()}if(this.showTickLabels){var J,W,T,aO,g,G,n=0;var an=this.tickPadding*(1-1/(this.diameter/80+1));for(aa=0;aa<this.ticks.length;aa++){J=c('<div class="jqplot-meterGauge-tick" style="position:absolute;">'+this.ticks[aa][1]+"</div>");this.canvas._elem.after(J);aO=J.outerWidth(true);g=J.outerHeight(true);W=this._tickPoints[aa][0]-aO*(this._tickPoints[aa][2]-Math.PI)/Math.PI-an*Math.cos(this._tickPoints[aa][2]);T=this._tickPoints[aa][1]-g/2+g/2*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5)+an/3*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5);J.css({left:W,top:T});G=aO*Math.cos(this._tickPoints[aa][2])+g*Math.sin(Math.PI/2+this._tickPoints[aa][2]/2);n=(G>n)?G:n}}if(this.label&&this.labelPosition=="inside"){var W=this._center[0]+this.canvas._offsets.left;var an=this.tickPadding*(1-1/(this.diameter/80+1));var T=0.5*(this._center[1]+this.canvas._offsets.top-this.hubRadius)+0.5*(this._center[1]+this.canvas._offsets.top-this.tickOuterRadius+this.tickLength+an)+this.labelHeightAdjust;W-=this._labelElem.outerWidth(true)/2;T-=this._labelElem.outerHeight(true)/2;this._labelElem.css({left:W,top:T})}else{if(this.label&&this.labelPosition=="bottom"){var W=this._center[0]+this.canvas._offsets.left-this._labelElem.outerWidth(true)/2;var T=this._center[1]+this.canvas._offsets.top+this.innerPad+ +this.ringWidth+this.padding+this.labelHeightAdjust;this._labelElem.css({left:W,top:T})}}X.save();var ax=this.intervalInnerRadius||this.hubRadius*1.5;if(this.intervalOuterRadius==null){if(this.showTickLabels){var ag=(this.tickOuterRadius-this.tickLength-this.tickPadding-this.diameter/8)}else{var ag=(this.tickOuterRadius-this.tickLength-this.diameter/16)}}else{var ag=this.intervalOuterRadius}var P=this.max-this.min;var aD=this.intervals[this.intervals.length-1]-this.min;var y,Z,u=this.span*Math.PI/180;for(aa=0;aa<this.intervals.length;aa++){y=(aa==0)?aE:aE+(this.intervals[aa-1][0]-this.min)*u/P;if(y<0){y=0}Z=aE+(this.intervals[aa][0]-this.min)*u/P;if(Z<0){Z=0}X.beginPath();X.fillStyle=this.intervals[aa][2];X.arc(0,0,ax,y,Z,false);X.lineTo(ag*Math.cos(Z),ag*Math.sin(Z));X.arc(0,0,ag,Z,y,true);X.lineTo(ax*Math.cos(y),ax*Math.sin(y));X.closePath();X.fill()}X.restore();var ay=this.data[0][1];var R=this.max-this.min;if(this.pegNeedle){if(this.data[0][1]>this.max+R*3/this.span){ay=this.max+R*3/this.span}if(this.data[0][1]<this.min-R*3/this.span){ay=this.min-R*3/this.span}}var al=(ay-this.min)/R*this.span*Math.PI/180+this.startAngle;X.save();X.beginPath();X.fillStyle=this.ringColor;X.strokeStyle=this.ringColor;this.needleLength=(this.tickOuterRadius-this.tickLength)*0.85;this.needleThickness=(this.needleThickness<2)?2:this.needleThickness;var aK=this.needleThickness*0.4;var x=this.needleLength/10;var s=(this.needleThickness-aK)/10;var ar;for(var aa=0;aa<10;aa++){ar=this.needleThickness-aa*s;X.moveTo(x*aa*Math.cos(al),x*aa*Math.sin(al));X.lineWidth=ar;X.lineTo(x*(aa+1)*Math.cos(al),x*(aa+1)*Math.sin(al));X.stroke()}X.restore()}else{this._center=[(K-at*ai)/2+at*ai,(S-at*ah)/2+at*ah]}};c.jqplot.MeterGaugeAxisRenderer=function(){c.jqplot.LinearAxisRenderer.call(this)};c.jqplot.MeterGaugeAxisRenderer.prototype=new c.jqplot.LinearAxisRenderer();c.jqplot.MeterGaugeAxisRenderer.prototype.constructor=c.jqplot.MeterGaugeAxisRenderer;c.jqplot.MeterGaugeAxisRenderer.prototype.init=function(e){this.tickRenderer=c.jqplot.MeterGaugeTickRenderer;c.extend(true,this,e);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};c.jqplot.MeterGaugeLegendRenderer=function(){c.jqplot.TableLegendRenderer.call(this)};c.jqplot.MeterGaugeLegendRenderer.prototype=new c.jqplot.TableLegendRenderer();c.jqplot.MeterGaugeLegendRenderer.prototype.constructor=c.jqplot.MeterGaugeLegendRenderer;c.jqplot.MeterGaugeLegendRenderer.prototype.init=function(e){this.numberRows=null;this.numberColumns=null;c.extend(true,this,e)};c.jqplot.MeterGaugeLegendRenderer.prototype.draw=function(){var g=this;if(this.show){var p=this._series;var t="position:absolute;";t+=(this.background)?"background:"+this.background+";":"";t+=(this.border)?"border:"+this.border+";":"";t+=(this.fontSize)?"font-size:"+this.fontSize+";":"";t+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";t+=(this.textColor)?"color:"+this.textColor+";":"";t+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";t+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";t+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";t+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=c('<table class="jqplot-table-legend" style="'+t+'"></table>');var x=false,o=false,e,m;var q=p[0];if(q.show){var y=q.data;if(this.numberRows){e=this.numberRows;if(!this.numberColumns){m=Math.ceil(y.length/e)}else{m=this.numberColumns}}else{if(this.numberColumns){m=this.numberColumns;e=Math.ceil(y.length/this.numberColumns)}else{e=y.length;m=1}}var w,v,f,k,h,l,n,u;var r=0;for(w=0;w<e;w++){if(o){f=c('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{f=c('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(v=0;v<m;v++){if(r<y.length){l=this.labels[r]||y[r][0].toString();u=colorGenerator.next();if(!o){if(w>0){x=true}else{x=false}}else{if(w==e-1){x=false}else{x=true}}n=(x)?this.rowSpacing:"0";k=c('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+n+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+u+';"></div></div></td>');h=c('<td class="jqplot-table-legend" style="padding-top:'+n+';"></td>');if(this.escapeHtml){h.text(l)}else{h.html(l)}if(o){h.prependTo(f);k.prependTo(f)}else{k.appendTo(f);h.appendTo(f)}x=true}r++}}}}return this._elem};function a(j,h,f){f=f||{};f.axesDefaults=f.axesDefaults||{};f.legend=f.legend||{};f.seriesDefaults=f.seriesDefaults||{};f.grid=f.grid||{};f.gridPadding=f.gridPadding||{};var e=false;if(f.seriesDefaults.renderer==c.jqplot.MeterGaugeRenderer){e=true}else{if(f.series){for(var g=0;g<f.series.length;g++){if(f.series[g].renderer==c.jqplot.MeterGaugeRenderer){e=true}}}}if(e){f.axesDefaults.renderer=c.jqplot.MeterGaugeAxisRenderer;f.legend.renderer=c.jqplot.MeterGaugeLegendRenderer;f.legend.preDraw=true;f.grid.background=f.grid.background||"white";f.grid.drawGridlines=false;f.grid.borderWidth=(f.grid.borderWidth!=null)?f.grid.borderWidth:0;f.grid.shadow=(f.grid.shadow!=null)?f.grid.shadow:false;f.gridPadding.top=(f.gridPadding.top!=null)?f.gridPadding.top:0;f.gridPadding.bottom=(f.gridPadding.bottom!=null)?f.gridPadding.bottom:0;f.gridPadding.left=(f.gridPadding.left!=null)?f.gridPadding.left:0;f.gridPadding.right=(f.gridPadding.right!=null)?f.gridPadding.right:0}}function d(e){}c.jqplot.preInitHooks.push(a);c.jqplot.postParseOptionsHooks.push(d);c.jqplot.MeterGaugeTickRenderer=function(){c.jqplot.AxisTickRenderer.call(this)};c.jqplot.MeterGaugeTickRenderer.prototype=new c.jqplot.AxisTickRenderer();c.jqplot.MeterGaugeTickRenderer.prototype.constructor=c.jqplot.MeterGaugeTickRenderer})(jQuery);
@@ -1,372 +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
- * Class: $.jqplot.OHLCRenderer
33
- * jqPlot Plugin to draw Open Hi Low Close, Candlestick and Hi Low Close charts.
34
- *
35
- * To use this plugin, include the renderer js file in
36
- * your source:
37
- *
38
- * > <script type="text/javascript" src="plugins/jqplot.ohlcRenderer.js"></script>
39
- *
40
- * You will most likely want to use a date axis renderer
41
- * for the x axis also, so include the date axis render js file also:
42
- *
43
- * > <script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
44
- *
45
- * Then you set the renderer in the series options on your plot:
46
- *
47
- * > series: [{renderer:$.jqplot.OHLCRenderer}]
48
- *
49
- * For OHLC and candlestick charts, data should be specified
50
- * like so:
51
- *
52
- * > dat = [['07/06/2009',138.7,139.68,135.18,135.4], ['06/29/2009',143.46,144.66,139.79,140.02], ...]
53
- *
54
- * If the data array has only 4 values per point instead of 5,
55
- * the renderer will create a Hi Low Close chart instead. In that case,
56
- * data should be supplied like:
57
- *
58
- * > dat = [['07/06/2009',139.68,135.18,135.4], ['06/29/2009',144.66,139.79,140.02], ...]
59
- *
60
- * To generate a candlestick chart instead of an OHLC chart,
61
- * set the "candlestick" option to true:
62
- *
63
- * > series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}],
64
- *
65
- */
66
- $.jqplot.OHLCRenderer = function(){
67
- // subclass line renderer to make use of some of it's methods.
68
- $.jqplot.LineRenderer.call(this);
69
- // prop: candleStick
70
- // true to render chart as candleStick.
71
- // Must have an open price, cannot be a hlc chart.
72
- this.candleStick = false;
73
- // prop: tickLength
74
- // length of the line in pixels indicating open and close price.
75
- // Default will auto calculate based on plot width and
76
- // number of points displayed.
77
- this.tickLength = 'auto';
78
- // prop: bodyWidth
79
- // width of the candlestick body in pixels. Default will auto calculate
80
- // based on plot width and number of candlesticks displayed.
81
- this.bodyWidth = 'auto';
82
- // prop: openColor
83
- // color of the open price tick mark. Default is series color.
84
- this.openColor = null;
85
- // prop: closeColor
86
- // color of the close price tick mark. Default is series color.
87
- this.closeColor = null;
88
- // prop: wickColor
89
- // color of the hi-lo line thorugh the candlestick body.
90
- // Default is the series color.
91
- this.wickColor = null;
92
- // prop: fillUpBody
93
- // true to render an "up" day (close price greater than open price)
94
- // with a filled candlestick body.
95
- this.fillUpBody = false;
96
- // prop: fillDownBody
97
- // true to render a "down" day (close price lower than open price)
98
- // with a filled candlestick body.
99
- this.fillDownBody = true;
100
- // prop: upBodyColor
101
- // Color of candlestick body of an "up" day. Default is series color.
102
- this.upBodyColor = null;
103
- // prop: downBodyColor
104
- // Color of candlestick body on a "down" day. Default is series color.
105
- this.downBodyColor = null;
106
- // prop: hlc
107
- // true if is a hi-low-close chart (no open price).
108
- // This is determined automatically from the series data.
109
- this.hlc = false;
110
- // prop: lineWidth
111
- // Width of the hi-low line and open/close ticks.
112
- // Must be set in the rendererOptions for the series.
113
- this.lineWidth = 1.5;
114
- this._tickLength;
115
- this._bodyWidth;
116
- };
117
-
118
- $.jqplot.OHLCRenderer.prototype = new $.jqplot.LineRenderer();
119
- $.jqplot.OHLCRenderer.prototype.constructor = $.jqplot.OHLCRenderer;
120
-
121
- // called with scope of series.
122
- $.jqplot.OHLCRenderer.prototype.init = function(options) {
123
- options = options || {};
124
- // lineWidth has to be set on the series, changes in renderer
125
- // constructor have no effect. set the default here
126
- // if no renderer option for lineWidth is specified.
127
- this.lineWidth = options.lineWidth || 1.5;
128
- $.jqplot.LineRenderer.prototype.init.call(this, options);
129
- this._type = 'ohlc';
130
- // set the yaxis data bounds here to account for hi and low values
131
- var db = this._yaxis._dataBounds;
132
- var d = this._plotData;
133
- // if data points have less than 5 values, force a hlc chart.
134
- if (d[0].length < 5) {
135
- this.renderer.hlc = true;
136
-
137
- for (var j=0; j<d.length; j++) {
138
- if (d[j][2] < db.min || db.min == null) {
139
- db.min = d[j][2];
140
- }
141
- if (d[j][1] > db.max || db.max == null) {
142
- db.max = d[j][1];
143
- }
144
- }
145
- }
146
- else {
147
- for (var j=0; j<d.length; j++) {
148
- if (d[j][3] < db.min || db.min == null) {
149
- db.min = d[j][3];
150
- }
151
- if (d[j][2] > db.max || db.max == null) {
152
- db.max = d[j][2];
153
- }
154
- }
155
- }
156
-
157
- };
158
-
159
- // called within scope of series.
160
- $.jqplot.OHLCRenderer.prototype.draw = function(ctx, gd, options) {
161
- var d = this.data;
162
- var xmin = this._xaxis.min;
163
- var xmax = this._xaxis.max;
164
- // index of last value below range of plot.
165
- var xminidx = 0;
166
- // index of first value above range of plot.
167
- var xmaxidx = d.length;
168
- var xp = this._xaxis.series_u2p;
169
- var yp = this._yaxis.series_u2p;
170
- var i, prevColor, ops, b, h, w, a, points;
171
- var o;
172
- var r = this.renderer;
173
- var opts = (options != undefined) ? options : {};
174
- var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
175
- var fill = (opts.fill != undefined) ? opts.fill : this.fill;
176
- var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke;
177
- r.bodyWidth = (opts.bodyWidth != undefined) ? opts.bodyWidth : r.bodyWidth;
178
- r.tickLength = (opts.tickLength != undefined) ? opts.tickLength : r.tickLength;
179
- ctx.save();
180
- if (this.show) {
181
- var x, open, hi, low, close;
182
- // need to get widths based on number of points shown,
183
- // not on total number of points. Use the results
184
- // to speed up drawing in next step.
185
- for (var i=0; i<d.length; i++) {
186
- if (d[i][0] < xmin) {
187
- xminidx = i;
188
- }
189
- else if (d[i][0] < xmax) {
190
- xmaxidx = i+1;
191
- }
192
- }
193
-
194
- var dwidth = this.gridData[xmaxidx-1][0] - this.gridData[xminidx][0];
195
- var nvisiblePoints = xmaxidx - xminidx;
196
- try {
197
- var dinterval = Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval)) - this._xaxis.series_u2p(0));
198
- }
199
-
200
- catch (e) {
201
- var dinterval = dwidth / nvisiblePoints;
202
- }
203
-
204
- if (r.candleStick) {
205
- if (typeof(r.bodyWidth) == 'number') {
206
- r._bodyWidth = r.bodyWidth;
207
- }
208
- else {
209
- r._bodyWidth = Math.min(20, dinterval/1.75);
210
- }
211
- }
212
- else {
213
- if (typeof(r.tickLength) == 'number') {
214
- r._tickLength = r.tickLength;
215
- }
216
- else {
217
- r._tickLength = Math.min(10, dinterval/3.5);
218
- }
219
- }
220
-
221
- for (var i=xminidx; i<xmaxidx; i++) {
222
- x = xp(d[i][0]);
223
- if (r.hlc) {
224
- open = null;
225
- hi = yp(d[i][1]);
226
- low = yp(d[i][2]);
227
- close = yp(d[i][3]);
228
- }
229
- else {
230
- open = yp(d[i][1]);
231
- hi = yp(d[i][2]);
232
- low = yp(d[i][3]);
233
- close = yp(d[i][4]);
234
- }
235
- o = {};
236
- if (r.candleStick && !r.hlc) {
237
- w = r._bodyWidth;
238
- a = x - w/2;
239
- // draw candle
240
- // determine if candle up or down
241
- // up, remember grid coordinates increase downward
242
- if (close < open) {
243
- // draw wick
244
- if (r.wickColor) {
245
- o.color = r.wickColor;
246
- }
247
- else if (r.downBodyColor) {
248
- o.color = r.upBodyColor;
249
- }
250
- ops = $.extend(true, {}, opts, o);
251
- r.shapeRenderer.draw(ctx, [[x, hi], [x, close]], ops);
252
- r.shapeRenderer.draw(ctx, [[x, open], [x, low]], ops);
253
- o = {};
254
- b = close;
255
- h = open - close;
256
- // if color specified, use it
257
- if (r.fillUpBody) {
258
- o.fillRect = true;
259
- }
260
- else {
261
- o.strokeRect = true;
262
- w = w - this.lineWidth;
263
- a = x - w/2;
264
- }
265
- if (r.upBodyColor) {
266
- o.color = r.upBodyColor;
267
- o.fillStyle = r.upBodyColor;
268
- }
269
- points = [a, b, w, h];
270
- }
271
- // down
272
- else if (close > open) {
273
- // draw wick
274
- if (r.wickColor) {
275
- o.color = r.wickColor;
276
- }
277
- else if (r.downBodyColor) {
278
- o.color = r.downBodyColor;
279
- }
280
- ops = $.extend(true, {}, opts, o);
281
- r.shapeRenderer.draw(ctx, [[x, hi], [x, open]], ops);
282
- r.shapeRenderer.draw(ctx, [[x, close], [x, low]], ops);
283
-
284
- o = {};
285
-
286
- b = open;
287
- h = close - open;
288
- // if color specified, use it
289
- if (r.fillDownBody) {
290
- o.fillRect = true;
291
- }
292
- else {
293
- o.strokeRect = true;
294
- w = w - this.lineWidth;
295
- a = x - w/2;
296
- }
297
- if (r.downBodyColor) {
298
- o.color = r.downBodyColor;
299
- o.fillStyle = r.downBodyColor;
300
- }
301
- points = [a, b, w, h];
302
- }
303
- // even, open = close
304
- else {
305
- // draw wick
306
- if (r.wickColor) {
307
- o.color = r.wickColor;
308
- }
309
- ops = $.extend(true, {}, opts, o);
310
- r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], ops);
311
- o = {};
312
- o.fillRect = false;
313
- o.strokeRect = false;
314
- a = [x - w/2, open];
315
- b = [x + w/2, close];
316
- w = null;
317
- h = null;
318
- points = [a, b];
319
- }
320
- ops = $.extend(true, {}, opts, o);
321
- r.shapeRenderer.draw(ctx, points, ops);
322
- }
323
- else {
324
- prevColor = opts.color;
325
- if (r.openColor) {
326
- opts.color = r.openColor;
327
- }
328
- // draw open tick
329
- if (!r.hlc) {
330
- r.shapeRenderer.draw(ctx, [[x-r._tickLength, open], [x, open]], opts);
331
- }
332
- opts.color = prevColor;
333
- // draw wick
334
- if (r.wickColor) {
335
- opts.color = r.wickColor;
336
- }
337
- r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], opts);
338
- opts.color = prevColor;
339
- // draw close tick
340
- if (r.closeColor) {
341
- opts.color = r.closeColor;
342
- }
343
- r.shapeRenderer.draw(ctx, [[x, close], [x+r._tickLength, close]], opts);
344
- opts.color = prevColor;
345
- }
346
- }
347
- }
348
-
349
- ctx.restore();
350
- };
351
-
352
- $.jqplot.OHLCRenderer.prototype.drawShadow = function(ctx, gd, options) {
353
- // This is a no-op, shadows drawn with lines.
354
- };
355
-
356
- // called with scope of plot.
357
- $.jqplot.OHLCRenderer.checkOptions = function(target, data, options) {
358
- // provide some sensible highlighter options by default
359
- // These aren't good for hlc, only for ohlc or candlestick
360
- if (!options.highlighter) {
361
- options.highlighter = {
362
- showMarker:false,
363
- tooltipAxes: 'y',
364
- yvalues: 4,
365
- formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>'
366
- };
367
- }
368
- };
369
-
370
- //$.jqplot.preInitHooks.push($.jqplot.OHLCRenderer.checkOptions);
371
-
372
- })(jQuery);
@@ -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(a){a.jqplot.OHLCRenderer=function(){a.jqplot.LineRenderer.call(this);this.candleStick=false;this.tickLength="auto";this.bodyWidth="auto";this.openColor=null;this.closeColor=null;this.wickColor=null;this.fillUpBody=false;this.fillDownBody=true;this.upBodyColor=null;this.downBodyColor=null;this.hlc=false;this.lineWidth=1.5;this._tickLength;this._bodyWidth};a.jqplot.OHLCRenderer.prototype=new a.jqplot.LineRenderer();a.jqplot.OHLCRenderer.prototype.constructor=a.jqplot.OHLCRenderer;a.jqplot.OHLCRenderer.prototype.init=function(e){e=e||{};this.lineWidth=e.lineWidth||1.5;a.jqplot.LineRenderer.prototype.init.call(this,e);this._type="ohlc";var b=this._yaxis._dataBounds;var f=this._plotData;if(f[0].length<5){this.renderer.hlc=true;for(var c=0;c<f.length;c++){if(f[c][2]<b.min||b.min==null){b.min=f[c][2]}if(f[c][1]>b.max||b.max==null){b.max=f[c][1]}}}else{for(var c=0;c<f.length;c++){if(f[c][3]<b.min||b.min==null){b.min=f[c][3]}if(f[c][2]>b.max||b.max==null){b.max=f[c][2]}}}};a.jqplot.OHLCRenderer.prototype.draw=function(A,N,j){var J=this.data;var v=this._xaxis.min;var z=this._xaxis.max;var l=0;var K=J.length;var p=this._xaxis.series_u2p;var G=this._yaxis.series_u2p;var D,E,f,M,F,n,O,C;var y;var u=this.renderer;var s=(j!=undefined)?j:{};var k=(s.shadow!=undefined)?s.shadow:this.shadow;var B=(s.fill!=undefined)?s.fill:this.fill;var c=(s.fillAndStroke!=undefined)?s.fillAndStroke:this.fillAndStroke;u.bodyWidth=(s.bodyWidth!=undefined)?s.bodyWidth:u.bodyWidth;u.tickLength=(s.tickLength!=undefined)?s.tickLength:u.tickLength;A.save();if(this.show){var m,q,g,Q,t;for(var D=0;D<J.length;D++){if(J[D][0]<v){l=D}else{if(J[D][0]<z){K=D+1}}}var I=this.gridData[K-1][0]-this.gridData[l][0];var L=K-l;try{var P=Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval))-this._xaxis.series_u2p(0))}catch(H){var P=I/L}if(u.candleStick){if(typeof(u.bodyWidth)=="number"){u._bodyWidth=u.bodyWidth}else{u._bodyWidth=Math.min(20,P/1.75)}}else{if(typeof(u.tickLength)=="number"){u._tickLength=u.tickLength}else{u._tickLength=Math.min(10,P/3.5)}}for(var D=l;D<K;D++){m=p(J[D][0]);if(u.hlc){q=null;g=G(J[D][1]);Q=G(J[D][2]);t=G(J[D][3])}else{q=G(J[D][1]);g=G(J[D][2]);Q=G(J[D][3]);t=G(J[D][4])}y={};if(u.candleStick&&!u.hlc){n=u._bodyWidth;O=m-n/2;if(t<q){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.upBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,t]],f);u.shapeRenderer.draw(A,[[m,q],[m,Q]],f);y={};M=t;F=q-t;if(u.fillUpBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.upBodyColor){y.color=u.upBodyColor;y.fillStyle=u.upBodyColor}C=[O,M,n,F]}else{if(t>q){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.downBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,q]],f);u.shapeRenderer.draw(A,[[m,t],[m,Q]],f);y={};M=q;F=t-q;if(u.fillDownBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.downBodyColor){y.color=u.downBodyColor;y.fillStyle=u.downBodyColor}C=[O,M,n,F]}else{if(u.wickColor){y.color=u.wickColor}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,Q]],f);y={};y.fillRect=false;y.strokeRect=false;O=[m-n/2,q];M=[m+n/2,t];n=null;F=null;C=[O,M]}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,C,f)}else{E=s.color;if(u.openColor){s.color=u.openColor}if(!u.hlc){u.shapeRenderer.draw(A,[[m-u._tickLength,q],[m,q]],s)}s.color=E;if(u.wickColor){s.color=u.wickColor}u.shapeRenderer.draw(A,[[m,g],[m,Q]],s);s.color=E;if(u.closeColor){s.color=u.closeColor}u.shapeRenderer.draw(A,[[m,t],[m+u._tickLength,t]],s);s.color=E}}}A.restore()};a.jqplot.OHLCRenderer.prototype.drawShadow=function(b,d,c){};a.jqplot.OHLCRenderer.checkOptions=function(d,c,b){if(!b.highlighter){b.highlighter={showMarker:false,tooltipAxes:"y",yvalues:4,formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>'}}}})(jQuery);
@@ -1,797 +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
- * Class: $.jqplot.PieRenderer
33
- * Plugin renderer to draw a pie chart.
34
- * x values, if present, will be used as slice labels.
35
- * y values give slice size.
36
- *
37
- * To use this renderer, you need to include the
38
- * pie renderer plugin, for example:
39
- *
40
- * > <script type="text/javascript" src="plugins/jqplot.pieRenderer.js"></script>
41
- *
42
- * Properties described here are passed into the $.jqplot function
43
- * as options on the series renderer. For example:
44
- *
45
- * > plot2 = $.jqplot('chart2', [s1, s2], {
46
- * > seriesDefaults: {
47
- * > renderer:$.jqplot.PieRenderer,
48
- * > rendererOptions:{
49
- * > sliceMargin: 2,
50
- * > startAngle: -90
51
- * > }
52
- * > }
53
- * > });
54
- *
55
- * A pie plot will trigger events on the plot target
56
- * according to user interaction. All events return the event object,
57
- * the series index, the point (slice) index, and the point data for
58
- * the appropriate slice.
59
- *
60
- * 'jqplotDataMouseOver' - triggered when user mouseing over a slice.
61
- * 'jqplotDataHighlight' - triggered the first time user mouses over a slice,
62
- * if highlighting is enabled.
63
- * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
64
- * a highlighted slice.
65
- * 'jqplotDataClick' - triggered when the user clicks on a slice.
66
- * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if
67
- * the "captureRightClick" option is set to true on the plot.
68
- */
69
- $.jqplot.PieRenderer = function(){
70
- $.jqplot.LineRenderer.call(this);
71
- };
72
-
73
- $.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer();
74
- $.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer;
75
-
76
- // called with scope of a series
77
- $.jqplot.PieRenderer.prototype.init = function(options, plot) {
78
- // Group: Properties
79
- //
80
- // prop: diameter
81
- // Outer diameter of the pie, auto computed by default
82
- this.diameter = null;
83
- // prop: padding
84
- // padding between the pie and plot edges, legend, etc.
85
- this.padding = 20;
86
- // prop: sliceMargin
87
- // angular spacing between pie slices in degrees.
88
- this.sliceMargin = 0;
89
- // prop: fill
90
- // true or false, wether to fil the slices.
91
- this.fill = true;
92
- // prop: shadowOffset
93
- // offset of the shadow from the slice and offset of
94
- // each succesive stroke of the shadow from the last.
95
- this.shadowOffset = 2;
96
- // prop: shadowAlpha
97
- // transparency of the shadow (0 = transparent, 1 = opaque)
98
- this.shadowAlpha = 0.07;
99
- // prop: shadowDepth
100
- // number of strokes to apply to the shadow,
101
- // each stroke offset shadowOffset from the last.
102
- this.shadowDepth = 5;
103
- // prop: highlightMouseOver
104
- // True to highlight slice when moused over.
105
- // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
106
- this.highlightMouseOver = true;
107
- // prop: highlightMouseDown
108
- // True to highlight when a mouse button is pressed over a slice.
109
- // This will be disabled if highlightMouseOver is true.
110
- this.highlightMouseDown = false;
111
- // prop: highlightColors
112
- // an array of colors to use when highlighting a slice.
113
- this.highlightColors = [];
114
- // prop: dataLabels
115
- // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
116
- // Defaults to percentage of each pie slice.
117
- this.dataLabels = 'percent';
118
- // prop: showDataLabels
119
- // true to show data labels on slices.
120
- this.showDataLabels = false;
121
- // prop: dataLabelFormatString
122
- // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
123
- this.dataLabelFormatString = null;
124
- // prop: dataLabelThreshold
125
- // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed.
126
- // This applies to all label types, not just to percentage labels.
127
- this.dataLabelThreshold = 3;
128
- // prop: dataLabelPositionFactor
129
- // A Multiplier (0-1) of the pie radius which controls position of label on slice.
130
- // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
131
- this.dataLabelPositionFactor = 0.52;
132
- // prop: dataLabelNudge
133
- // Number of pixels to slide the label away from (+) or toward (-) the center of the pie.
134
- this.dataLabelNudge = 2;
135
- // prop: dataLabelCenterOn
136
- // True to center the data label at its position.
137
- // False to set the inside facing edge of the label at its position.
138
- this.dataLabelCenterOn = true;
139
- // prop: startAngle
140
- // Angle to start drawing pie in degrees.
141
- // According to orientation of canvas coordinate system:
142
- // 0 = on the positive x axis
143
- // -90 = on the positive y axis.
144
- // 90 = on the negaive y axis.
145
- // 180 or - 180 = on the negative x axis.
146
- this.startAngle = 0;
147
- this.tickRenderer = $.jqplot.PieTickRenderer;
148
- // Used as check for conditions where pie shouldn't be drawn.
149
- this._drawData = true;
150
- this._type = 'pie';
151
-
152
- // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
153
- if (options.highlightMouseDown && options.highlightMouseOver == null) {
154
- options.highlightMouseOver = false;
155
- }
156
-
157
- $.extend(true, this, options);
158
- this._diameter = null;
159
- this._radius = null;
160
- // array of [start,end] angles arrays, one for each slice. In radians.
161
- this._sliceAngles = [];
162
- // index of the currenty highlighted point, if any
163
- this._highlightedPoint = null;
164
-
165
- // set highlight colors if none provided
166
- if (this.highlightColors.length == 0) {
167
- for (var i=0; i<this.seriesColors.length; i++){
168
- var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
169
- var newrgb = [rgba[0], rgba[1], rgba[2]];
170
- var sum = newrgb[0] + newrgb[1] + newrgb[2];
171
- for (var j=0; j<3; j++) {
172
- // when darkening, lowest color component can be is 60.
173
- newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
174
- newrgb[j] = parseInt(newrgb[j], 10);
175
- }
176
- this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
177
- }
178
- }
179
-
180
- this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors);
181
-
182
- plot.postParseOptionsHooks.addOnce(postParseOptions);
183
- plot.postInitHooks.addOnce(postInit);
184
- plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
185
- plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
186
- plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
187
- plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
188
- plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
189
- plot.postDrawHooks.addOnce(postPlotDraw);
190
- };
191
-
192
- $.jqplot.PieRenderer.prototype.setGridData = function(plot) {
193
- // set gridData property. This will hold angle in radians of each data point.
194
- var stack = [];
195
- var td = [];
196
- var sa = this.startAngle/180*Math.PI;
197
- var tot = 0;
198
- // don't know if we have any valid data yet, so set plot to not draw.
199
- this._drawData = false;
200
- for (var i=0; i<this.data.length; i++){
201
- if (this.data[i][1] != 0) {
202
- // we have data, O.K. to draw.
203
- this._drawData = true;
204
- }
205
- stack.push(this.data[i][1]);
206
- td.push([this.data[i][0]]);
207
- if (i>0) {
208
- stack[i] += stack[i-1];
209
- }
210
- tot += this.data[i][1];
211
- }
212
- var fact = Math.PI*2/stack[stack.length - 1];
213
-
214
- for (var i=0; i<stack.length; i++) {
215
- td[i][1] = stack[i] * fact;
216
- td[i][2] = this.data[i][1]/tot;
217
- }
218
- this.gridData = td;
219
- };
220
-
221
- $.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) {
222
- var stack = [];
223
- var td = [];
224
- var tot = 0;
225
- var sa = this.startAngle/180*Math.PI;
226
- // don't know if we have any valid data yet, so set plot to not draw.
227
- this._drawData = false;
228
- for (var i=0; i<data.length; i++){
229
- if (this.data[i][1] != 0) {
230
- // we have data, O.K. to draw.
231
- this._drawData = true;
232
- }
233
- stack.push(data[i][1]);
234
- td.push([data[i][0]]);
235
- if (i>0) {
236
- stack[i] += stack[i-1];
237
- }
238
- tot += data[i][1];
239
- }
240
- var fact = Math.PI*2/stack[stack.length - 1];
241
-
242
- for (var i=0; i<stack.length; i++) {
243
- td[i][1] = stack[i] * fact;
244
- td[i][2] = data[i][1]/tot;
245
- }
246
- return td;
247
- };
248
-
249
- $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
250
- if (this._drawData) {
251
- var r = this._diameter / 2.0;
252
- var fill = this.fill;
253
- var lineWidth = this.lineWidth;
254
- var sm = this.sliceMargin;
255
- if (this.fill == false) {
256
- sm += this.lineWidth;
257
- }
258
- ctx.save();
259
- ctx.translate(this._center[0], this._center[1]);
260
- var rprime = 0;
261
- if (Math.abs(ang2-ang1) > 0) {
262
- rprime = parseFloat(sm) / 2.0 / Math.sin((ang2 - ang1)/2.0);
263
- }
264
- var transx = rprime * Math.cos((ang1 + ang2) / 2.0);
265
- var transy = rprime * Math.sin((ang1 + ang2) / 2.0);
266
- if ((ang2 - ang1) <= Math.PI) {
267
- r -= rprime;
268
- }
269
- else {
270
- r += rprime;
271
- }
272
- ctx.translate(transx, transy);
273
-
274
- if (isShadow) {
275
- for (var i=0; i<this.shadowDepth; i++) {
276
- ctx.save();
277
- ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
278
- doDraw(r);
279
- }
280
- }
281
-
282
- else {
283
- doDraw(r);
284
- }
285
- }
286
-
287
- function doDraw (rad) {
288
- // Fix for IE and Chrome that can't seem to draw circles correctly.
289
- // ang2 should always be <= 2 pi since that is the way the data is converted.
290
- if (ang2 > 6.282 + this.startAngle) {
291
- ang2 = 6.282 + this.startAngle;
292
- if (ang1 > ang2) {
293
- ang1 = 6.281 + this.startAngle;
294
- }
295
- }
296
- // Fix for IE, where it can't seem to handle 0 degree angles. Also avoids
297
- // ugly line on unfilled pies.
298
- if (ang1 >= ang2) {
299
- return;
300
- }
301
-
302
- ctx.beginPath();
303
- ctx.fillStyle = color;
304
- ctx.strokeStyle = color;
305
- ctx.lineWidth = lineWidth;
306
- ctx.arc(0, 0, rad, ang1, ang2, false);
307
- ctx.lineTo(0,0);
308
- ctx.closePath();
309
-
310
- if (fill) {
311
- ctx.fill();
312
- }
313
- else {
314
- ctx.stroke();
315
- }
316
- }
317
-
318
- if (isShadow) {
319
- for (var i=0; i<this.shadowDepth; i++) {
320
- ctx.restore();
321
- }
322
- }
323
-
324
- ctx.restore();
325
- };
326
-
327
- // called with scope of series
328
- $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) {
329
- var i;
330
- var opts = (options != undefined) ? options : {};
331
- // offset and direction of offset due to legend placement
332
- var offx = 0;
333
- var offy = 0;
334
- var trans = 1;
335
- var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
336
- if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
337
- var li = options.legendInfo;
338
- switch (li.location) {
339
- case 'nw':
340
- offx = li.width + li.xoffset;
341
- break;
342
- case 'w':
343
- offx = li.width + li.xoffset;
344
- break;
345
- case 'sw':
346
- offx = li.width + li.xoffset;
347
- break;
348
- case 'ne':
349
- offx = li.width + li.xoffset;
350
- trans = -1;
351
- break;
352
- case 'e':
353
- offx = li.width + li.xoffset;
354
- trans = -1;
355
- break;
356
- case 'se':
357
- offx = li.width + li.xoffset;
358
- trans = -1;
359
- break;
360
- case 'n':
361
- offy = li.height + li.yoffset;
362
- break;
363
- case 's':
364
- offy = li.height + li.yoffset;
365
- trans = -1;
366
- break;
367
- default:
368
- break;
369
- }
370
- }
371
-
372
- var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
373
- var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
374
- var fill = (opts.fill != undefined) ? opts.fill : this.fill;
375
- var cw = ctx.canvas.width;
376
- var ch = ctx.canvas.height;
377
- var w = cw - offx - 2 * this.padding;
378
- var h = ch - offy - 2 * this.padding;
379
- var mindim = Math.min(w,h);
380
- var d = mindim;
381
- // this._diameter = this.diameter || d;
382
- this._diameter = this.diameter || d; // - this.sliceMargin;
383
-
384
- var r = this._radius = this._diameter/2;
385
- var sa = this.startAngle / 180 * Math.PI;
386
- this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy];
387
-
388
- // Fixes issue #272. Thanks hugwijst!
389
- // reset slice angles array.
390
- this._sliceAngles = [];
391
-
392
- if (this.shadow) {
393
- var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
394
- for (var i=0; i<gd.length; i++) {
395
- var ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
396
- // Adjust ang1 and ang2 for sliceMargin
397
- // ang1 += this.sliceMargin/180*Math.PI;
398
- this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1]+sa, shadowColor, true);
399
- }
400
-
401
- }
402
- for (var i=0; i<gd.length; i++) {
403
- var ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
404
- // Adjust ang1 and ang2 for sliceMargin
405
- // ang1 += this.sliceMargin/180*Math.PI;
406
- var ang2 = gd[i][1] + sa;
407
- this._sliceAngles.push([ang1, ang2]);
408
-
409
- this.renderer.drawSlice.call (this, ctx, ang1, ang2, colorGenerator.next(), false);
410
-
411
- if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) {
412
- var fstr, avgang = (ang1+ang2)/2, label;
413
-
414
- if (this.dataLabels == 'label') {
415
- fstr = this.dataLabelFormatString || '%s';
416
- label = $.jqplot.sprintf(fstr, gd[i][0]);
417
- }
418
- else if (this.dataLabels == 'value') {
419
- fstr = this.dataLabelFormatString || '%d';
420
- label = $.jqplot.sprintf(fstr, this.data[i][1]);
421
- }
422
- else if (this.dataLabels == 'percent') {
423
- fstr = this.dataLabelFormatString || '%d%%';
424
- label = $.jqplot.sprintf(fstr, gd[i][2]*100);
425
- }
426
- else if (this.dataLabels.constructor == Array) {
427
- fstr = this.dataLabelFormatString || '%s';
428
- label = $.jqplot.sprintf(fstr, this.dataLabels[i]);
429
- }
430
-
431
- var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
432
-
433
- var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left;
434
- var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top;
435
-
436
- var labelelem = $('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">' + label + '</div>').insertBefore(plot.eventCanvas._elem);
437
- if (this.dataLabelCenterOn) {
438
- x -= labelelem.width()/2;
439
- y -= labelelem.height()/2;
440
- }
441
- else {
442
- x -= labelelem.width() * Math.sin(avgang/2);
443
- y -= labelelem.height()/2;
444
- }
445
- x = Math.round(x);
446
- y = Math.round(y);
447
- labelelem.css({left: x, top: y});
448
- }
449
- }
450
-
451
- };
452
-
453
- $.jqplot.PieAxisRenderer = function() {
454
- $.jqplot.LinearAxisRenderer.call(this);
455
- };
456
-
457
- $.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
458
- $.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer;
459
-
460
-
461
- // There are no traditional axes on a pie chart. We just need to provide
462
- // dummy objects with properties so the plot will render.
463
- // called with scope of axis object.
464
- $.jqplot.PieAxisRenderer.prototype.init = function(options){
465
- //
466
- this.tickRenderer = $.jqplot.PieTickRenderer;
467
- $.extend(true, this, options);
468
- // I don't think I'm going to need _dataBounds here.
469
- // have to go Axis scaling in a way to fit chart onto plot area
470
- // and provide u2p and p2u functionality for mouse cursor, etc.
471
- // for convienence set _dataBounds to 0 and 100 and
472
- // set min/max to 0 and 100.
473
- this._dataBounds = {min:0, max:100};
474
- this.min = 0;
475
- this.max = 100;
476
- this.showTicks = false;
477
- this.ticks = [];
478
- this.showMark = false;
479
- this.show = false;
480
- };
481
-
482
-
483
-
484
-
485
- $.jqplot.PieLegendRenderer = function(){
486
- $.jqplot.TableLegendRenderer.call(this);
487
- };
488
-
489
- $.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
490
- $.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer;
491
-
492
- /**
493
- * Class: $.jqplot.PieLegendRenderer
494
- * Legend Renderer specific to pie plots. Set by default
495
- * when user creates a pie plot.
496
- */
497
- $.jqplot.PieLegendRenderer.prototype.init = function(options) {
498
- // Group: Properties
499
- //
500
- // prop: numberRows
501
- // Maximum number of rows in the legend. 0 or null for unlimited.
502
- this.numberRows = null;
503
- // prop: numberColumns
504
- // Maximum number of columns in the legend. 0 or null for unlimited.
505
- this.numberColumns = null;
506
- $.extend(true, this, options);
507
- };
508
-
509
- // called with context of legend
510
- $.jqplot.PieLegendRenderer.prototype.draw = function() {
511
- var legend = this;
512
- if (this.show) {
513
- var series = this._series;
514
- var ss = 'position:absolute;';
515
- ss += (this.background) ? 'background:'+this.background+';' : '';
516
- ss += (this.border) ? 'border:'+this.border+';' : '';
517
- ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
518
- ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
519
- ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
520
- ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
521
- ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
522
- ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
523
- ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
524
- this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
525
- // Pie charts legends don't go by number of series, but by number of data points
526
- // in the series. Refactor things here for that.
527
-
528
- var pad = false,
529
- reverse = false,
530
- nr,
531
- nc;
532
- var s = series[0];
533
- var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
534
-
535
- if (s.show) {
536
- var pd = s.data;
537
- if (this.numberRows) {
538
- nr = this.numberRows;
539
- if (!this.numberColumns){
540
- nc = Math.ceil(pd.length/nr);
541
- }
542
- else{
543
- nc = this.numberColumns;
544
- }
545
- }
546
- else if (this.numberColumns) {
547
- nc = this.numberColumns;
548
- nr = Math.ceil(pd.length/this.numberColumns);
549
- }
550
- else {
551
- nr = pd.length;
552
- nc = 1;
553
- }
554
-
555
- var i, j, tr, td1, td2, lt, rs, color;
556
- var idx = 0;
557
-
558
- for (i=0; i<nr; i++) {
559
- if (reverse){
560
- tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
561
- }
562
- else{
563
- tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
564
- }
565
- for (j=0; j<nc; j++) {
566
- if (idx < pd.length){
567
- lt = this.labels[idx] || pd[idx][0].toString();
568
- color = colorGenerator.next();
569
- if (!reverse){
570
- if (i>0){
571
- pad = true;
572
- }
573
- else{
574
- pad = false;
575
- }
576
- }
577
- else{
578
- if (i == nr -1){
579
- pad = false;
580
- }
581
- else{
582
- pad = true;
583
- }
584
- }
585
- rs = (pad) ? this.rowSpacing : '0';
586
-
587
- td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
588
- '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
589
- '</div></td>');
590
- td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
591
- if (this.escapeHtml){
592
- td2.text(lt);
593
- }
594
- else {
595
- td2.html(lt);
596
- }
597
- if (reverse) {
598
- td2.prependTo(tr);
599
- td1.prependTo(tr);
600
- }
601
- else {
602
- td1.appendTo(tr);
603
- td2.appendTo(tr);
604
- }
605
- pad = true;
606
- }
607
- idx++;
608
- }
609
- }
610
- }
611
- }
612
- return this._elem;
613
- };
614
-
615
- $.jqplot.PieRenderer.prototype.handleMove = function(ev, gridpos, datapos, neighbor, plot) {
616
- if (neighbor) {
617
- var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
618
- plot.target.trigger('jqplotDataMouseOver', ins);
619
- if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
620
- plot.target.trigger('jqplotDataHighlight', ins);
621
- highlight (plot, ins[0], ins[1]);
622
- }
623
- }
624
- else if (neighbor == null) {
625
- unhighlight (plot);
626
- }
627
- };
628
-
629
-
630
- // this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]);
631
-
632
- // setup default renderers for axes and legend so user doesn't have to
633
- // called with scope of plot
634
- function preInit(target, data, options) {
635
- options = options || {};
636
- options.axesDefaults = options.axesDefaults || {};
637
- options.legend = options.legend || {};
638
- options.seriesDefaults = options.seriesDefaults || {};
639
- // only set these if there is a pie series
640
- var setopts = false;
641
- if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) {
642
- setopts = true;
643
- }
644
- else if (options.series) {
645
- for (var i=0; i < options.series.length; i++) {
646
- if (options.series[i].renderer == $.jqplot.PieRenderer) {
647
- setopts = true;
648
- }
649
- }
650
- }
651
-
652
- if (setopts) {
653
- options.axesDefaults.renderer = $.jqplot.PieAxisRenderer;
654
- options.legend.renderer = $.jqplot.PieLegendRenderer;
655
- options.legend.preDraw = true;
656
- options.seriesDefaults.pointLabels = {show: false};
657
- }
658
- }
659
-
660
- function postInit(target, data, options) {
661
- for (var i=0; i<this.series.length; i++) {
662
- if (this.series[i].renderer.constructor == $.jqplot.PieRenderer) {
663
- // don't allow mouseover and mousedown at same time.
664
- if (this.series[i].highlightMouseOver) {
665
- this.series[i].highlightMouseDown = false;
666
- }
667
- }
668
- }
669
- this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
670
- }
671
-
672
- // called with scope of plot
673
- function postParseOptions(options) {
674
- for (var i=0; i<this.series.length; i++) {
675
- this.series[i].seriesColors = this.seriesColors;
676
- this.series[i].colorGenerator = this.colorGenerator;
677
- }
678
- }
679
-
680
- function highlight (plot, sidx, pidx) {
681
- var s = plot.series[sidx];
682
- var canvas = plot.plugins.pieRenderer.highlightCanvas;
683
- canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
684
- s._highlightedPoint = pidx;
685
- plot.plugins.pieRenderer.highlightedSeriesIndex = sidx;
686
- s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColorGenerator.get(pidx), false);
687
- }
688
-
689
- function unhighlight (plot) {
690
- var canvas = plot.plugins.pieRenderer.highlightCanvas;
691
- canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
692
- for (var i=0; i<plot.series.length; i++) {
693
- plot.series[i]._highlightedPoint = null;
694
- }
695
- plot.plugins.pieRenderer.highlightedSeriesIndex = null;
696
- plot.target.trigger('jqplotDataUnhighlight');
697
- }
698
-
699
- function handleMove(ev, gridpos, datapos, neighbor, plot) {
700
- if (neighbor) {
701
- var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
702
- var evt1 = jQuery.Event('jqplotDataMouseOver');
703
- evt1.pageX = ev.pageX;
704
- evt1.pageY = ev.pageY;
705
- plot.target.trigger(evt1, ins);
706
- if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
707
- var evt = jQuery.Event('jqplotDataHighlight');
708
- evt.pageX = ev.pageX;
709
- evt.pageY = ev.pageY;
710
- plot.target.trigger(evt, ins);
711
- highlight (plot, ins[0], ins[1]);
712
- }
713
- }
714
- else if (neighbor == null) {
715
- unhighlight (plot);
716
- }
717
- }
718
-
719
- function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
720
- if (neighbor) {
721
- var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
722
- if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
723
- var evt = jQuery.Event('jqplotDataHighlight');
724
- evt.pageX = ev.pageX;
725
- evt.pageY = ev.pageY;
726
- plot.target.trigger(evt, ins);
727
- highlight (plot, ins[0], ins[1]);
728
- }
729
- }
730
- else if (neighbor == null) {
731
- unhighlight (plot);
732
- }
733
- }
734
-
735
- function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
736
- var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
737
- if (idx != null && plot.series[idx].highlightMouseDown) {
738
- unhighlight(plot);
739
- }
740
- }
741
-
742
- function handleClick(ev, gridpos, datapos, neighbor, plot) {
743
- if (neighbor) {
744
- var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
745
- var evt = jQuery.Event('jqplotDataClick');
746
- evt.pageX = ev.pageX;
747
- evt.pageY = ev.pageY;
748
- plot.target.trigger(evt, ins);
749
- }
750
- }
751
-
752
- function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
753
- if (neighbor) {
754
- var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
755
- var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
756
- if (idx != null && plot.series[idx].highlightMouseDown) {
757
- unhighlight(plot);
758
- }
759
- var evt = jQuery.Event('jqplotDataRightClick');
760
- evt.pageX = ev.pageX;
761
- evt.pageY = ev.pageY;
762
- plot.target.trigger(evt, ins);
763
- }
764
- }
765
-
766
- // called within context of plot
767
- // create a canvas which we can draw on.
768
- // insert it before the eventCanvas, so eventCanvas will still capture events.
769
- function postPlotDraw() {
770
- this.plugins.pieRenderer = {highlightedSeriesIndex:null};
771
- this.plugins.pieRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
772
-
773
- // do we have any data labels? if so, put highlight canvas before those
774
- var labels = $(this.targetId+' .jqplot-data-label');
775
- if (labels.length) {
776
- $(labels[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions));
777
- }
778
- // else put highlight canvas before event canvas.
779
- else {
780
- this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions));
781
- }
782
-
783
- var hctx = this.plugins.pieRenderer.highlightCanvas.setContext();
784
- }
785
-
786
- $.jqplot.preInitHooks.push(preInit);
787
-
788
- $.jqplot.PieTickRenderer = function() {
789
- $.jqplot.AxisTickRenderer.call(this);
790
- };
791
-
792
- $.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
793
- $.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer;
794
-
795
- })(jQuery);
796
-
797
-