mdoc 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -2
  3. data/examples/jqplot.html +62 -0
  4. data/examples/jqplot.md +8 -0
  5. data/examples/js/jquery.jqplot.css +259 -0
  6. data/examples/js/jquery.jqplot.js +11411 -0
  7. data/examples/js/jquery.jqplot.min.css +1 -0
  8. data/examples/js/jquery.jqplot.min.js +3 -0
  9. data/examples/js/jquery.js +9597 -0
  10. data/examples/js/jquery.min.js +5 -0
  11. data/examples/js/plugins/jqplot.BezierCurveRenderer.js +314 -0
  12. data/examples/js/plugins/jqplot.BezierCurveRenderer.min.js +3 -0
  13. data/examples/js/plugins/jqplot.barRenderer.js +801 -0
  14. data/examples/js/plugins/jqplot.barRenderer.min.js +3 -0
  15. data/examples/js/plugins/jqplot.blockRenderer.js +235 -0
  16. data/examples/js/plugins/jqplot.blockRenderer.min.js +3 -0
  17. data/examples/js/plugins/jqplot.bubbleRenderer.js +759 -0
  18. data/examples/js/plugins/jqplot.bubbleRenderer.min.js +3 -0
  19. data/examples/js/plugins/jqplot.canvasAxisLabelRenderer.js +203 -0
  20. data/examples/js/plugins/jqplot.canvasAxisLabelRenderer.min.js +3 -0
  21. data/examples/js/plugins/jqplot.canvasAxisTickRenderer.js +253 -0
  22. data/examples/js/plugins/jqplot.canvasAxisTickRenderer.min.js +3 -0
  23. data/examples/js/plugins/jqplot.canvasOverlay.js +1021 -0
  24. data/examples/js/plugins/jqplot.canvasOverlay.min.js +3 -0
  25. data/examples/js/plugins/jqplot.canvasTextRenderer.js +449 -0
  26. data/examples/js/plugins/jqplot.canvasTextRenderer.min.js +3 -0
  27. data/examples/js/plugins/jqplot.categoryAxisRenderer.js +679 -0
  28. data/examples/js/plugins/jqplot.categoryAxisRenderer.min.js +3 -0
  29. data/examples/js/plugins/jqplot.ciParser.js +116 -0
  30. data/examples/js/plugins/jqplot.ciParser.min.js +3 -0
  31. data/examples/js/plugins/jqplot.cursor.js +1108 -0
  32. data/examples/js/plugins/jqplot.cursor.min.js +3 -0
  33. data/examples/js/plugins/jqplot.dateAxisRenderer.js +741 -0
  34. data/examples/js/plugins/jqplot.dateAxisRenderer.min.js +3 -0
  35. data/examples/js/plugins/jqplot.donutRenderer.js +805 -0
  36. data/examples/js/plugins/jqplot.donutRenderer.min.js +3 -0
  37. data/examples/js/plugins/jqplot.dragable.js +225 -0
  38. data/examples/js/plugins/jqplot.dragable.min.js +3 -0
  39. data/examples/js/plugins/jqplot.enhancedLegendRenderer.js +305 -0
  40. data/examples/js/plugins/jqplot.enhancedLegendRenderer.min.js +3 -0
  41. data/examples/js/plugins/jqplot.funnelRenderer.js +943 -0
  42. data/examples/js/plugins/jqplot.funnelRenderer.min.js +3 -0
  43. data/examples/js/plugins/jqplot.highlighter.js +465 -0
  44. data/examples/js/plugins/jqplot.highlighter.min.js +3 -0
  45. data/examples/js/plugins/jqplot.json2.js +475 -0
  46. data/examples/js/plugins/jqplot.json2.min.js +3 -0
  47. data/examples/js/plugins/jqplot.logAxisRenderer.js +534 -0
  48. data/examples/js/plugins/jqplot.logAxisRenderer.min.js +3 -0
  49. data/examples/js/plugins/jqplot.mekkoAxisRenderer.js +611 -0
  50. data/examples/js/plugins/jqplot.mekkoAxisRenderer.min.js +3 -0
  51. data/examples/js/plugins/jqplot.mekkoRenderer.js +437 -0
  52. data/examples/js/plugins/jqplot.mekkoRenderer.min.js +3 -0
  53. data/examples/js/plugins/jqplot.meterGaugeRenderer.js +1029 -0
  54. data/examples/js/plugins/jqplot.meterGaugeRenderer.min.js +3 -0
  55. data/examples/js/plugins/jqplot.mobile.js +45 -0
  56. data/examples/js/plugins/jqplot.mobile.min.js +3 -0
  57. data/examples/js/plugins/jqplot.ohlcRenderer.js +373 -0
  58. data/examples/js/plugins/jqplot.ohlcRenderer.min.js +3 -0
  59. data/examples/js/plugins/jqplot.pieRenderer.js +904 -0
  60. data/examples/js/plugins/jqplot.pieRenderer.min.js +3 -0
  61. data/examples/js/plugins/jqplot.pointLabels.js +377 -0
  62. data/examples/js/plugins/jqplot.pointLabels.min.js +3 -0
  63. data/examples/js/plugins/jqplot.pyramidAxisRenderer.js +728 -0
  64. data/examples/js/plugins/jqplot.pyramidAxisRenderer.min.js +3 -0
  65. data/examples/js/plugins/jqplot.pyramidGridRenderer.js +429 -0
  66. data/examples/js/plugins/jqplot.pyramidGridRenderer.min.js +3 -0
  67. data/examples/js/plugins/jqplot.pyramidRenderer.js +514 -0
  68. data/examples/js/plugins/jqplot.pyramidRenderer.min.js +3 -0
  69. data/examples/js/plugins/jqplot.trendline.js +223 -0
  70. data/examples/js/plugins/jqplot.trendline.min.js +3 -0
  71. data/examples/js/raphael-min.js +11 -0
  72. data/examples/js/sequence-diagram-min.js +8 -0
  73. data/examples/js/underscore-min.js +5 -0
  74. data/lib/mdoc.rb +1 -0
  75. data/lib/mdoc/processor/jqplot.rb +48 -0
  76. data/lib/mdoc/version.rb +1 -1
  77. data/templates/default.html.erb +1 -1
  78. metadata +74 -2
@@ -0,0 +1,3 @@
1
+ /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com
2
+ jsDate | (c) 2010-2013 Chris Leonello
3
+ */(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._labelElem=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.ringWidth-this.padding}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,color:this.tickColor});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(){if(this.show){var p=this._series;var x="position:absolute;";x+=(this.background)?"background:"+this.background+";":"";x+=(this.border)?"border:"+this.border+";":"";x+=(this.fontSize)?"font-size:"+this.fontSize+";":"";x+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";x+=(this.textColor)?"color:"+this.textColor+";":"";x+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";x+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";x+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";x+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=c('<table class="jqplot-table-legend" style="'+x+'"></table>');var f=false,q=false,u,o;var w=p[0];if(w.show){var t=w.data;if(this.numberRows){u=this.numberRows;if(!this.numberColumns){o=Math.ceil(t.length/u)}else{o=this.numberColumns}}else{if(this.numberColumns){o=this.numberColumns;u=Math.ceil(t.length/this.numberColumns)}else{u=t.length;o=1}}var n,m,r,g,e,l,k,h;var v=0;for(n=0;n<u;n++){if(q){r=c('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{r=c('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(m=0;m<o;m++){if(v<t.length){l=this.labels[v]||t[v][0].toString();h=w.color;if(!q){if(n>0){f=true}else{f=false}}else{if(n==u-1){f=false}else{f=true}}k=(f)?this.rowSpacing:"0";g=c('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+k+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+h+';"></div></div></td>');e=c('<td class="jqplot-table-legend" style="padding-top:'+k+';"></td>');if(this.escapeHtml){e.text(l)}else{e.html(l)}if(q){e.prependTo(r);g.prependTo(r)}else{g.appendTo(r);e.appendTo(r)}f=true}v++}}}}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||{};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}}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);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * jqplot.jquerymobile plugin
3
+ * jQuery Mobile virtual event support.
4
+ *
5
+ * Version: 1.0.8
6
+ * Revision: 1250
7
+ *
8
+ * Copyright (c) 2011 Takashi Okamoto
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ */
22
+ (function($) {
23
+ function postInit(target, data, options){
24
+ this.bindCustomEvents = function() {
25
+ this.eventCanvas._elem.bind('vclick', {plot:this}, this.onClick);
26
+ this.eventCanvas._elem.bind('dblclick', {plot:this}, this.onDblClick);
27
+ this.eventCanvas._elem.bind('taphold', {plot:this}, this.onDblClick);
28
+ this.eventCanvas._elem.bind('vmousedown', {plot:this}, this.onMouseDown);
29
+ this.eventCanvas._elem.bind('vmousemove', {plot:this}, this.onMouseMove);
30
+ this.eventCanvas._elem.bind('mouseenter', {plot:this}, this.onMouseEnter);
31
+ this.eventCanvas._elem.bind('mouseleave', {plot:this}, this.onMouseLeave);
32
+ if (this.captureRightClick) {
33
+ this.eventCanvas._elem.bind('vmouseup', {plot:this}, this.onRightClick);
34
+ this.eventCanvas._elem.get(0).oncontextmenu = function() {
35
+ return false;
36
+ };
37
+ }
38
+ else {
39
+ this.eventCanvas._elem.bind('vmouseup', {plot:this}, this.onMouseUp);
40
+ }
41
+ };
42
+ this.plugins.mobile = true;
43
+ }
44
+ $.jqplot.postInitHooks.push(postInit);
45
+ })(jQuery);
@@ -0,0 +1,3 @@
1
+ /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com
2
+ jsDate | (c) 2010-2013 Chris Leonello
3
+ */(function(b){function a(e,d,c){this.bindCustomEvents=function(){this.eventCanvas._elem.bind("vclick",{plot:this},this.onClick);this.eventCanvas._elem.bind("dblclick",{plot:this},this.onDblClick);this.eventCanvas._elem.bind("taphold",{plot:this},this.onDblClick);this.eventCanvas._elem.bind("vmousedown",{plot:this},this.onMouseDown);this.eventCanvas._elem.bind("vmousemove",{plot:this},this.onMouseMove);this.eventCanvas._elem.bind("mouseenter",{plot:this},this.onMouseEnter);this.eventCanvas._elem.bind("mouseleave",{plot:this},this.onMouseLeave);if(this.captureRightClick){this.eventCanvas._elem.bind("vmouseup",{plot:this},this.onRightClick);this.eventCanvas._elem.get(0).oncontextmenu=function(){return false}}else{this.eventCanvas._elem.bind("vmouseup",{plot:this},this.onMouseUp)}};this.plugins.mobile=true}b.jqplot.postInitHooks.push(a)})(jQuery);
@@ -0,0 +1,373 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.8
6
+ * Revision: 1250
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ */
31
+ (function($) {
32
+ /**
33
+ * Class: $.jqplot.OHLCRenderer
34
+ * jqPlot Plugin to draw Open Hi Low Close, Candlestick and Hi Low Close charts.
35
+ *
36
+ * To use this plugin, include the renderer js file in
37
+ * your source:
38
+ *
39
+ * > <script type="text/javascript" src="plugins/jqplot.ohlcRenderer.js"></script>
40
+ *
41
+ * You will most likely want to use a date axis renderer
42
+ * for the x axis also, so include the date axis render js file also:
43
+ *
44
+ * > <script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
45
+ *
46
+ * Then you set the renderer in the series options on your plot:
47
+ *
48
+ * > series: [{renderer:$.jqplot.OHLCRenderer}]
49
+ *
50
+ * For OHLC and candlestick charts, data should be specified
51
+ * like so:
52
+ *
53
+ * > dat = [['07/06/2009',138.7,139.68,135.18,135.4], ['06/29/2009',143.46,144.66,139.79,140.02], ...]
54
+ *
55
+ * If the data array has only 4 values per point instead of 5,
56
+ * the renderer will create a Hi Low Close chart instead. In that case,
57
+ * data should be supplied like:
58
+ *
59
+ * > dat = [['07/06/2009',139.68,135.18,135.4], ['06/29/2009',144.66,139.79,140.02], ...]
60
+ *
61
+ * To generate a candlestick chart instead of an OHLC chart,
62
+ * set the "candlestick" option to true:
63
+ *
64
+ * > series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}],
65
+ *
66
+ */
67
+ $.jqplot.OHLCRenderer = function(){
68
+ // subclass line renderer to make use of some of its methods.
69
+ $.jqplot.LineRenderer.call(this);
70
+ // prop: candleStick
71
+ // true to render chart as candleStick.
72
+ // Must have an open price, cannot be a hlc chart.
73
+ this.candleStick = false;
74
+ // prop: tickLength
75
+ // length of the line in pixels indicating open and close price.
76
+ // Default will auto calculate based on plot width and
77
+ // number of points displayed.
78
+ this.tickLength = 'auto';
79
+ // prop: bodyWidth
80
+ // width of the candlestick body in pixels. Default will auto calculate
81
+ // based on plot width and number of candlesticks displayed.
82
+ this.bodyWidth = 'auto';
83
+ // prop: openColor
84
+ // color of the open price tick mark. Default is series color.
85
+ this.openColor = null;
86
+ // prop: closeColor
87
+ // color of the close price tick mark. Default is series color.
88
+ this.closeColor = null;
89
+ // prop: wickColor
90
+ // color of the hi-lo line thorugh the candlestick body.
91
+ // Default is the series color.
92
+ this.wickColor = null;
93
+ // prop: fillUpBody
94
+ // true to render an "up" day (close price greater than open price)
95
+ // with a filled candlestick body.
96
+ this.fillUpBody = false;
97
+ // prop: fillDownBody
98
+ // true to render a "down" day (close price lower than open price)
99
+ // with a filled candlestick body.
100
+ this.fillDownBody = true;
101
+ // prop: upBodyColor
102
+ // Color of candlestick body of an "up" day. Default is series color.
103
+ this.upBodyColor = null;
104
+ // prop: downBodyColor
105
+ // Color of candlestick body on a "down" day. Default is series color.
106
+ this.downBodyColor = null;
107
+ // prop: hlc
108
+ // true if is a hi-low-close chart (no open price).
109
+ // This is determined automatically from the series data.
110
+ this.hlc = false;
111
+ // prop: lineWidth
112
+ // Width of the hi-low line and open/close ticks.
113
+ // Must be set in the rendererOptions for the series.
114
+ this.lineWidth = 1.5;
115
+ this._tickLength;
116
+ this._bodyWidth;
117
+ };
118
+
119
+ $.jqplot.OHLCRenderer.prototype = new $.jqplot.LineRenderer();
120
+ $.jqplot.OHLCRenderer.prototype.constructor = $.jqplot.OHLCRenderer;
121
+
122
+ // called with scope of series.
123
+ $.jqplot.OHLCRenderer.prototype.init = function(options) {
124
+ options = options || {};
125
+ // lineWidth has to be set on the series, changes in renderer
126
+ // constructor have no effect. set the default here
127
+ // if no renderer option for lineWidth is specified.
128
+ this.lineWidth = options.lineWidth || 1.5;
129
+ $.jqplot.LineRenderer.prototype.init.call(this, options);
130
+ this._type = 'ohlc';
131
+ // set the yaxis data bounds here to account for hi and low values
132
+ var db = this._yaxis._dataBounds;
133
+ var d = this._plotData;
134
+ // if data points have less than 5 values, force a hlc chart.
135
+ if (d[0].length < 5) {
136
+ this.renderer.hlc = true;
137
+
138
+ for (var j=0; j<d.length; j++) {
139
+ if (d[j][2] < db.min || db.min == null) {
140
+ db.min = d[j][2];
141
+ }
142
+ if (d[j][1] > db.max || db.max == null) {
143
+ db.max = d[j][1];
144
+ }
145
+ }
146
+ }
147
+ else {
148
+ for (var j=0; j<d.length; j++) {
149
+ if (d[j][3] < db.min || db.min == null) {
150
+ db.min = d[j][3];
151
+ }
152
+ if (d[j][2] > db.max || db.max == null) {
153
+ db.max = d[j][2];
154
+ }
155
+ }
156
+ }
157
+
158
+ };
159
+
160
+ // called within scope of series.
161
+ $.jqplot.OHLCRenderer.prototype.draw = function(ctx, gd, options) {
162
+ var d = this.data;
163
+ var xmin = this._xaxis.min;
164
+ var xmax = this._xaxis.max;
165
+ // index of last value below range of plot.
166
+ var xminidx = 0;
167
+ // index of first value above range of plot.
168
+ var xmaxidx = d.length;
169
+ var xp = this._xaxis.series_u2p;
170
+ var yp = this._yaxis.series_u2p;
171
+ var i, prevColor, ops, b, h, w, a, points;
172
+ var o;
173
+ var r = this.renderer;
174
+ var opts = (options != undefined) ? options : {};
175
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
176
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
177
+ var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke;
178
+ r.bodyWidth = (opts.bodyWidth != undefined) ? opts.bodyWidth : r.bodyWidth;
179
+ r.tickLength = (opts.tickLength != undefined) ? opts.tickLength : r.tickLength;
180
+ ctx.save();
181
+ if (this.show) {
182
+ var x, open, hi, low, close;
183
+ // need to get widths based on number of points shown,
184
+ // not on total number of points. Use the results
185
+ // to speed up drawing in next step.
186
+ for (var i=0; i<d.length; i++) {
187
+ if (d[i][0] < xmin) {
188
+ xminidx = i;
189
+ }
190
+ else if (d[i][0] < xmax) {
191
+ xmaxidx = i+1;
192
+ }
193
+ }
194
+
195
+ var dwidth = this.gridData[xmaxidx-1][0] - this.gridData[xminidx][0];
196
+ var nvisiblePoints = xmaxidx - xminidx;
197
+ try {
198
+ var dinterval = Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval, 10)) - this._xaxis.series_u2p(0));
199
+ }
200
+
201
+ catch (e) {
202
+ var dinterval = dwidth / nvisiblePoints;
203
+ }
204
+
205
+ if (r.candleStick) {
206
+ if (typeof(r.bodyWidth) == 'number') {
207
+ r._bodyWidth = r.bodyWidth;
208
+ }
209
+ else {
210
+ r._bodyWidth = Math.min(20, dinterval/1.65);
211
+ }
212
+ }
213
+ else {
214
+ if (typeof(r.tickLength) == 'number') {
215
+ r._tickLength = r.tickLength;
216
+ }
217
+ else {
218
+ r._tickLength = Math.min(10, dinterval/3.5);
219
+ }
220
+ }
221
+
222
+ for (var i=xminidx; i<xmaxidx; i++) {
223
+ x = xp(d[i][0]);
224
+ if (r.hlc) {
225
+ open = null;
226
+ hi = yp(d[i][1]);
227
+ low = yp(d[i][2]);
228
+ close = yp(d[i][3]);
229
+ }
230
+ else {
231
+ open = yp(d[i][1]);
232
+ hi = yp(d[i][2]);
233
+ low = yp(d[i][3]);
234
+ close = yp(d[i][4]);
235
+ }
236
+ o = {};
237
+ if (r.candleStick && !r.hlc) {
238
+ w = r._bodyWidth;
239
+ a = x - w/2;
240
+ // draw candle
241
+ // determine if candle up or down
242
+ // up, remember grid coordinates increase downward
243
+ if (close < open) {
244
+ // draw wick
245
+ if (r.wickColor) {
246
+ o.color = r.wickColor;
247
+ }
248
+ else if (r.downBodyColor) {
249
+ o.color = r.upBodyColor;
250
+ }
251
+ ops = $.extend(true, {}, opts, o);
252
+ r.shapeRenderer.draw(ctx, [[x, hi], [x, close]], ops);
253
+ r.shapeRenderer.draw(ctx, [[x, open], [x, low]], ops);
254
+ o = {};
255
+ b = close;
256
+ h = open - close;
257
+ // if color specified, use it
258
+ if (r.fillUpBody) {
259
+ o.fillRect = true;
260
+ }
261
+ else {
262
+ o.strokeRect = true;
263
+ w = w - this.lineWidth;
264
+ a = x - w/2;
265
+ }
266
+ if (r.upBodyColor) {
267
+ o.color = r.upBodyColor;
268
+ o.fillStyle = r.upBodyColor;
269
+ }
270
+ points = [a, b, w, h];
271
+ }
272
+ // down
273
+ else if (close > open) {
274
+ // draw wick
275
+ if (r.wickColor) {
276
+ o.color = r.wickColor;
277
+ }
278
+ else if (r.downBodyColor) {
279
+ o.color = r.downBodyColor;
280
+ }
281
+ ops = $.extend(true, {}, opts, o);
282
+ r.shapeRenderer.draw(ctx, [[x, hi], [x, open]], ops);
283
+ r.shapeRenderer.draw(ctx, [[x, close], [x, low]], ops);
284
+
285
+ o = {};
286
+
287
+ b = open;
288
+ h = close - open;
289
+ // if color specified, use it
290
+ if (r.fillDownBody) {
291
+ o.fillRect = true;
292
+ }
293
+ else {
294
+ o.strokeRect = true;
295
+ w = w - this.lineWidth;
296
+ a = x - w/2;
297
+ }
298
+ if (r.downBodyColor) {
299
+ o.color = r.downBodyColor;
300
+ o.fillStyle = r.downBodyColor;
301
+ }
302
+ points = [a, b, w, h];
303
+ }
304
+ // even, open = close
305
+ else {
306
+ // draw wick
307
+ if (r.wickColor) {
308
+ o.color = r.wickColor;
309
+ }
310
+ ops = $.extend(true, {}, opts, o);
311
+ r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], ops);
312
+ o = {};
313
+ o.fillRect = false;
314
+ o.strokeRect = false;
315
+ a = [x - w/2, open];
316
+ b = [x + w/2, close];
317
+ w = null;
318
+ h = null;
319
+ points = [a, b];
320
+ }
321
+ ops = $.extend(true, {}, opts, o);
322
+ r.shapeRenderer.draw(ctx, points, ops);
323
+ }
324
+ else {
325
+ prevColor = opts.color;
326
+ if (r.openColor) {
327
+ opts.color = r.openColor;
328
+ }
329
+ // draw open tick
330
+ if (!r.hlc) {
331
+ r.shapeRenderer.draw(ctx, [[x-r._tickLength, open], [x, open]], opts);
332
+ }
333
+ opts.color = prevColor;
334
+ // draw wick
335
+ if (r.wickColor) {
336
+ opts.color = r.wickColor;
337
+ }
338
+ r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], opts);
339
+ opts.color = prevColor;
340
+ // draw close tick
341
+ if (r.closeColor) {
342
+ opts.color = r.closeColor;
343
+ }
344
+ r.shapeRenderer.draw(ctx, [[x, close], [x+r._tickLength, close]], opts);
345
+ opts.color = prevColor;
346
+ }
347
+ }
348
+ }
349
+
350
+ ctx.restore();
351
+ };
352
+
353
+ $.jqplot.OHLCRenderer.prototype.drawShadow = function(ctx, gd, options) {
354
+ // This is a no-op, shadows drawn with lines.
355
+ };
356
+
357
+ // called with scope of plot.
358
+ $.jqplot.OHLCRenderer.checkOptions = function(target, data, options) {
359
+ // provide some sensible highlighter options by default
360
+ // These aren't good for hlc, only for ohlc or candlestick
361
+ if (!options.highlighter) {
362
+ options.highlighter = {
363
+ showMarker:false,
364
+ tooltipAxes: 'y',
365
+ yvalues: 4,
366
+ 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>'
367
+ };
368
+ }
369
+ };
370
+
371
+ //$.jqplot.preInitHooks.push($.jqplot.OHLCRenderer.checkOptions);
372
+
373
+ })(jQuery);
@@ -0,0 +1,3 @@
1
+ /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com
2
+ jsDate | (c) 2010-2013 Chris Leonello
3
+ */(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,10))-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.65)}}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);
@@ -0,0 +1,904 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.8
6
+ * Revision: 1250
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ */
31
+ (function($) {
32
+ /**
33
+ * Class: $.jqplot.PieRenderer
34
+ * Plugin renderer to draw a pie chart.
35
+ * x values, if present, will be used as slice labels.
36
+ * y values give slice size.
37
+ *
38
+ * To use this renderer, you need to include the
39
+ * pie renderer plugin, for example:
40
+ *
41
+ * > <script type="text/javascript" src="plugins/jqplot.pieRenderer.js"></script>
42
+ *
43
+ * Properties described here are passed into the $.jqplot function
44
+ * as options on the series renderer. For example:
45
+ *
46
+ * > plot2 = $.jqplot('chart2', [s1, s2], {
47
+ * > seriesDefaults: {
48
+ * > renderer:$.jqplot.PieRenderer,
49
+ * > rendererOptions:{
50
+ * > sliceMargin: 2,
51
+ * > startAngle: -90
52
+ * > }
53
+ * > }
54
+ * > });
55
+ *
56
+ * A pie plot will trigger events on the plot target
57
+ * according to user interaction. All events return the event object,
58
+ * the series index, the point (slice) index, and the point data for
59
+ * the appropriate slice.
60
+ *
61
+ * 'jqplotDataMouseOver' - triggered when user mouseing over a slice.
62
+ * 'jqplotDataHighlight' - triggered the first time user mouses over a slice,
63
+ * if highlighting is enabled.
64
+ * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
65
+ * a highlighted slice.
66
+ * 'jqplotDataClick' - triggered when the user clicks on a slice.
67
+ * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if
68
+ * the "captureRightClick" option is set to true on the plot.
69
+ */
70
+ $.jqplot.PieRenderer = function(){
71
+ $.jqplot.LineRenderer.call(this);
72
+ };
73
+
74
+ $.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer();
75
+ $.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer;
76
+
77
+ // called with scope of a series
78
+ $.jqplot.PieRenderer.prototype.init = function(options, plot) {
79
+ // Group: Properties
80
+ //
81
+ // prop: diameter
82
+ // Outer diameter of the pie, auto computed by default
83
+ this.diameter = null;
84
+ // prop: padding
85
+ // padding between the pie and plot edges, legend, etc.
86
+ this.padding = 20;
87
+ // prop: sliceMargin
88
+ // angular spacing between pie slices in degrees.
89
+ this.sliceMargin = 0;
90
+ // prop: fill
91
+ // true or false, whether to fil the slices.
92
+ this.fill = true;
93
+ // prop: shadowOffset
94
+ // offset of the shadow from the slice and offset of
95
+ // each succesive stroke of the shadow from the last.
96
+ this.shadowOffset = 2;
97
+ // prop: shadowAlpha
98
+ // transparency of the shadow (0 = transparent, 1 = opaque)
99
+ this.shadowAlpha = 0.07;
100
+ // prop: shadowDepth
101
+ // number of strokes to apply to the shadow,
102
+ // each stroke offset shadowOffset from the last.
103
+ this.shadowDepth = 5;
104
+ // prop: highlightMouseOver
105
+ // True to highlight slice when moused over.
106
+ // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
107
+ this.highlightMouseOver = true;
108
+ // prop: highlightMouseDown
109
+ // True to highlight when a mouse button is pressed over a slice.
110
+ // This will be disabled if highlightMouseOver is true.
111
+ this.highlightMouseDown = false;
112
+ // prop: highlightColors
113
+ // an array of colors to use when highlighting a slice.
114
+ this.highlightColors = [];
115
+ // prop: dataLabels
116
+ // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
117
+ // Defaults to percentage of each pie slice.
118
+ this.dataLabels = 'percent';
119
+ // prop: showDataLabels
120
+ // true to show data labels on slices.
121
+ this.showDataLabels = false;
122
+ // prop: dataLabelFormatString
123
+ // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
124
+ this.dataLabelFormatString = null;
125
+ // prop: dataLabelThreshold
126
+ // Threshhold in percentage (0-100) of pie area, below which no label will be displayed.
127
+ // This applies to all label types, not just to percentage labels.
128
+ this.dataLabelThreshold = 3;
129
+ // prop: dataLabelPositionFactor
130
+ // A Multiplier (0-1) of the pie radius which controls position of label on slice.
131
+ // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
132
+ this.dataLabelPositionFactor = 0.52;
133
+ // prop: dataLabelNudge
134
+ // Number of pixels to slide the label away from (+) or toward (-) the center of the pie.
135
+ this.dataLabelNudge = 2;
136
+ // prop: dataLabelCenterOn
137
+ // True to center the data label at its position.
138
+ // False to set the inside facing edge of the label at its position.
139
+ this.dataLabelCenterOn = true;
140
+ // prop: startAngle
141
+ // Angle to start drawing pie in degrees.
142
+ // According to orientation of canvas coordinate system:
143
+ // 0 = on the positive x axis
144
+ // -90 = on the positive y axis.
145
+ // 90 = on the negaive y axis.
146
+ // 180 or - 180 = on the negative x axis.
147
+ this.startAngle = 0;
148
+ this.tickRenderer = $.jqplot.PieTickRenderer;
149
+ // Used as check for conditions where pie shouldn't be drawn.
150
+ this._drawData = true;
151
+ this._type = 'pie';
152
+
153
+ // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
154
+ if (options.highlightMouseDown && options.highlightMouseOver == null) {
155
+ options.highlightMouseOver = false;
156
+ }
157
+
158
+ $.extend(true, this, options);
159
+
160
+ if (this.sliceMargin < 0) {
161
+ this.sliceMargin = 0;
162
+ }
163
+
164
+ this._diameter = null;
165
+ this._radius = null;
166
+ // array of [start,end] angles arrays, one for each slice. In radians.
167
+ this._sliceAngles = [];
168
+ // index of the currenty highlighted point, if any
169
+ this._highlightedPoint = null;
170
+
171
+ // set highlight colors if none provided
172
+ if (this.highlightColors.length == 0) {
173
+ for (var i=0; i<this.seriesColors.length; i++){
174
+ var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
175
+ var newrgb = [rgba[0], rgba[1], rgba[2]];
176
+ var sum = newrgb[0] + newrgb[1] + newrgb[2];
177
+ for (var j=0; j<3; j++) {
178
+ // when darkening, lowest color component can be is 60.
179
+ newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
180
+ newrgb[j] = parseInt(newrgb[j], 10);
181
+ }
182
+ this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
183
+ }
184
+ }
185
+
186
+ this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors);
187
+
188
+ plot.postParseOptionsHooks.addOnce(postParseOptions);
189
+ plot.postInitHooks.addOnce(postInit);
190
+ plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
191
+ plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
192
+ plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
193
+ plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
194
+ plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
195
+ plot.postDrawHooks.addOnce(postPlotDraw);
196
+ };
197
+
198
+ $.jqplot.PieRenderer.prototype.setGridData = function(plot) {
199
+ // set gridData property. This will hold angle in radians of each data point.
200
+ var stack = [];
201
+ var td = [];
202
+ var sa = this.startAngle/180*Math.PI;
203
+ var tot = 0;
204
+ // don't know if we have any valid data yet, so set plot to not draw.
205
+ this._drawData = false;
206
+ for (var i=0; i<this.data.length; i++){
207
+ if (this.data[i][1] != 0) {
208
+ // we have data, O.K. to draw.
209
+ this._drawData = true;
210
+ }
211
+ stack.push(this.data[i][1]);
212
+ td.push([this.data[i][0]]);
213
+ if (i>0) {
214
+ stack[i] += stack[i-1];
215
+ }
216
+ tot += this.data[i][1];
217
+ }
218
+ var fact = Math.PI*2/stack[stack.length - 1];
219
+
220
+ for (var i=0; i<stack.length; i++) {
221
+ td[i][1] = stack[i] * fact;
222
+ td[i][2] = this.data[i][1]/tot;
223
+ }
224
+ this.gridData = td;
225
+ };
226
+
227
+ $.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) {
228
+ var stack = [];
229
+ var td = [];
230
+ var tot = 0;
231
+ var sa = this.startAngle/180*Math.PI;
232
+ // don't know if we have any valid data yet, so set plot to not draw.
233
+ this._drawData = false;
234
+ for (var i=0; i<data.length; i++){
235
+ if (this.data[i][1] != 0) {
236
+ // we have data, O.K. to draw.
237
+ this._drawData = true;
238
+ }
239
+ stack.push(data[i][1]);
240
+ td.push([data[i][0]]);
241
+ if (i>0) {
242
+ stack[i] += stack[i-1];
243
+ }
244
+ tot += data[i][1];
245
+ }
246
+ var fact = Math.PI*2/stack[stack.length - 1];
247
+
248
+ for (var i=0; i<stack.length; i++) {
249
+ td[i][1] = stack[i] * fact;
250
+ td[i][2] = data[i][1]/tot;
251
+ }
252
+ return td;
253
+ };
254
+
255
+ function calcRadiusAdjustment(ang) {
256
+ return Math.sin((ang - (ang-Math.PI) / 8 / Math.PI )/2.0);
257
+ }
258
+
259
+ function calcRPrime(ang1, ang2, sliceMargin, fill, lineWidth) {
260
+ var rprime = 0;
261
+ var ang = ang2 - ang1;
262
+ var absang = Math.abs(ang);
263
+ var sm = sliceMargin;
264
+ if (fill == false) {
265
+ sm += lineWidth;
266
+ }
267
+
268
+ if (sm > 0 && absang > 0.01 && absang < 6.282) {
269
+ rprime = parseFloat(sm) / 2.0 / calcRadiusAdjustment(ang);
270
+ }
271
+
272
+ return rprime;
273
+ }
274
+
275
+ $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
276
+ if (this._drawData) {
277
+ var r = this._radius;
278
+ var fill = this.fill;
279
+ var lineWidth = this.lineWidth;
280
+ var sm = this.sliceMargin;
281
+ if (this.fill == false) {
282
+ sm += this.lineWidth;
283
+ }
284
+ ctx.save();
285
+ ctx.translate(this._center[0], this._center[1]);
286
+
287
+ var rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
288
+
289
+ var transx = rprime * Math.cos((ang1 + ang2) / 2.0);
290
+ var transy = rprime * Math.sin((ang1 + ang2) / 2.0);
291
+
292
+ if ((ang2 - ang1) <= Math.PI) {
293
+ r -= rprime;
294
+ }
295
+ else {
296
+ r += rprime;
297
+ }
298
+
299
+ ctx.translate(transx, transy);
300
+
301
+ if (isShadow) {
302
+ for (var i=0, l=this.shadowDepth; i<l; i++) {
303
+ ctx.save();
304
+ ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
305
+ doDraw(r);
306
+ }
307
+ for (var i=0, l=this.shadowDepth; i<l; i++) {
308
+ ctx.restore();
309
+ }
310
+ }
311
+
312
+ else {
313
+ doDraw(r);
314
+ }
315
+ ctx.restore();
316
+ }
317
+
318
+ function doDraw (rad) {
319
+ // Fix for IE and Chrome that can't seem to draw circles correctly.
320
+ // ang2 should always be <= 2 pi since that is the way the data is converted.
321
+ // 2Pi = 6.2831853, Pi = 3.1415927
322
+ if (ang2 > 6.282 + this.startAngle) {
323
+ ang2 = 6.282 + this.startAngle;
324
+ if (ang1 > ang2) {
325
+ ang1 = 6.281 + this.startAngle;
326
+ }
327
+ }
328
+ // Fix for IE, where it can't seem to handle 0 degree angles. Also avoids
329
+ // ugly line on unfilled pies.
330
+ if (ang1 >= ang2) {
331
+ return;
332
+ }
333
+
334
+ ctx.beginPath();
335
+ ctx.fillStyle = color;
336
+ ctx.strokeStyle = color;
337
+ ctx.lineWidth = lineWidth;
338
+ ctx.arc(0, 0, rad, ang1, ang2, false);
339
+ ctx.lineTo(0,0);
340
+ ctx.closePath();
341
+
342
+ if (fill) {
343
+ ctx.fill();
344
+ }
345
+ else {
346
+ ctx.stroke();
347
+ }
348
+ }
349
+ };
350
+
351
+ // called with scope of series
352
+ $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) {
353
+ var i;
354
+ var opts = (options != undefined) ? options : {};
355
+ // offset and direction of offset due to legend placement
356
+ var offx = 0;
357
+ var offy = 0;
358
+ var trans = 1;
359
+ var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
360
+ if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
361
+ var li = options.legendInfo;
362
+ switch (li.location) {
363
+ case 'nw':
364
+ offx = li.width + li.xoffset;
365
+ break;
366
+ case 'w':
367
+ offx = li.width + li.xoffset;
368
+ break;
369
+ case 'sw':
370
+ offx = li.width + li.xoffset;
371
+ break;
372
+ case 'ne':
373
+ offx = li.width + li.xoffset;
374
+ trans = -1;
375
+ break;
376
+ case 'e':
377
+ offx = li.width + li.xoffset;
378
+ trans = -1;
379
+ break;
380
+ case 'se':
381
+ offx = li.width + li.xoffset;
382
+ trans = -1;
383
+ break;
384
+ case 'n':
385
+ offy = li.height + li.yoffset;
386
+ break;
387
+ case 's':
388
+ offy = li.height + li.yoffset;
389
+ trans = -1;
390
+ break;
391
+ default:
392
+ break;
393
+ }
394
+ }
395
+
396
+ var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
397
+ var fill = (opts.fill != undefined) ? opts.fill : this.fill;
398
+ var cw = ctx.canvas.width;
399
+ var ch = ctx.canvas.height;
400
+ var w = cw - offx - 2 * this.padding;
401
+ var h = ch - offy - 2 * this.padding;
402
+ var mindim = Math.min(w,h);
403
+ var d = mindim;
404
+
405
+ // Fixes issue #272. Thanks hugwijst!
406
+ // reset slice angles array.
407
+ this._sliceAngles = [];
408
+
409
+ var sm = this.sliceMargin;
410
+ if (this.fill == false) {
411
+ sm += this.lineWidth;
412
+ }
413
+
414
+ var rprime;
415
+ var maxrprime = 0;
416
+
417
+ var ang, ang1, ang2, shadowColor;
418
+ var sa = this.startAngle / 180 * Math.PI;
419
+
420
+ // have to pre-draw shadows, so loop throgh here and calculate some values also.
421
+ for (var i=0, l=gd.length; i<l; i++) {
422
+ ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
423
+ ang2 = gd[i][1] + sa;
424
+
425
+ this._sliceAngles.push([ang1, ang2]);
426
+
427
+ rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
428
+
429
+ if (Math.abs(ang2-ang1) > Math.PI) {
430
+ maxrprime = Math.max(rprime, maxrprime);
431
+ }
432
+ }
433
+
434
+ if (this.diameter != null && this.diameter > 0) {
435
+ this._diameter = this.diameter - 2*maxrprime;
436
+ }
437
+ else {
438
+ this._diameter = d - 2*maxrprime;
439
+ }
440
+
441
+ // Need to check for undersized pie. This can happen if
442
+ // plot area too small and legend is too big.
443
+ if (this._diameter < 6) {
444
+ $.jqplot.log('Diameter of pie too small, not rendering.');
445
+ return;
446
+ }
447
+
448
+ var r = this._radius = this._diameter/2;
449
+
450
+ this._center = [(cw - trans * offx)/2 + trans * offx + maxrprime * Math.cos(sa), (ch - trans*offy)/2 + trans * offy + maxrprime * Math.sin(sa)];
451
+
452
+ if (this.shadow) {
453
+ for (var i=0, l=gd.length; i<l; i++) {
454
+ shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
455
+ this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], shadowColor, true);
456
+ }
457
+ }
458
+
459
+ for (var i=0; i<gd.length; i++) {
460
+
461
+ this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], colorGenerator.next(), false);
462
+
463
+ if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) {
464
+ var fstr, avgang = (this._sliceAngles[i][0] + this._sliceAngles[i][1])/2, label;
465
+
466
+ if (this.dataLabels == 'label') {
467
+ fstr = this.dataLabelFormatString || '%s';
468
+ label = $.jqplot.sprintf(fstr, gd[i][0]);
469
+ }
470
+ else if (this.dataLabels == 'value') {
471
+ fstr = this.dataLabelFormatString || '%d';
472
+ label = $.jqplot.sprintf(fstr, this.data[i][1]);
473
+ }
474
+ else if (this.dataLabels == 'percent') {
475
+ fstr = this.dataLabelFormatString || '%d%%';
476
+ label = $.jqplot.sprintf(fstr, gd[i][2]*100);
477
+ }
478
+ else if (this.dataLabels.constructor == Array) {
479
+ fstr = this.dataLabelFormatString || '%s';
480
+ label = $.jqplot.sprintf(fstr, this.dataLabels[i]);
481
+ }
482
+
483
+ var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
484
+
485
+ var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left;
486
+ var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top;
487
+
488
+ var labelelem = $('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">' + label + '</div>').insertBefore(plot.eventCanvas._elem);
489
+ if (this.dataLabelCenterOn) {
490
+ x -= labelelem.width()/2;
491
+ y -= labelelem.height()/2;
492
+ }
493
+ else {
494
+ x -= labelelem.width() * Math.sin(avgang/2);
495
+ y -= labelelem.height()/2;
496
+ }
497
+ x = Math.round(x);
498
+ y = Math.round(y);
499
+ labelelem.css({left: x, top: y});
500
+ }
501
+ }
502
+ };
503
+
504
+ $.jqplot.PieAxisRenderer = function() {
505
+ $.jqplot.LinearAxisRenderer.call(this);
506
+ };
507
+
508
+ $.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
509
+ $.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer;
510
+
511
+
512
+ // There are no traditional axes on a pie chart. We just need to provide
513
+ // dummy objects with properties so the plot will render.
514
+ // called with scope of axis object.
515
+ $.jqplot.PieAxisRenderer.prototype.init = function(options){
516
+ //
517
+ this.tickRenderer = $.jqplot.PieTickRenderer;
518
+ $.extend(true, this, options);
519
+ // I don't think I'm going to need _dataBounds here.
520
+ // have to go Axis scaling in a way to fit chart onto plot area
521
+ // and provide u2p and p2u functionality for mouse cursor, etc.
522
+ // for convienence set _dataBounds to 0 and 100 and
523
+ // set min/max to 0 and 100.
524
+ this._dataBounds = {min:0, max:100};
525
+ this.min = 0;
526
+ this.max = 100;
527
+ this.showTicks = false;
528
+ this.ticks = [];
529
+ this.showMark = false;
530
+ this.show = false;
531
+ };
532
+
533
+
534
+
535
+
536
+ $.jqplot.PieLegendRenderer = function(){
537
+ $.jqplot.TableLegendRenderer.call(this);
538
+ };
539
+
540
+ $.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
541
+ $.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer;
542
+
543
+ /**
544
+ * Class: $.jqplot.PieLegendRenderer
545
+ * Legend Renderer specific to pie plots. Set by default
546
+ * when user creates a pie plot.
547
+ */
548
+ $.jqplot.PieLegendRenderer.prototype.init = function(options) {
549
+ // Group: Properties
550
+ //
551
+ // prop: numberRows
552
+ // Maximum number of rows in the legend. 0 or null for unlimited.
553
+ this.numberRows = null;
554
+ // prop: numberColumns
555
+ // Maximum number of columns in the legend. 0 or null for unlimited.
556
+ this.numberColumns = null;
557
+ $.extend(true, this, options);
558
+ };
559
+
560
+ // called with context of legend
561
+ $.jqplot.PieLegendRenderer.prototype.draw = function() {
562
+ var legend = this;
563
+ if (this.show) {
564
+ var series = this._series;
565
+
566
+
567
+ this._elem = $(document.createElement('table'));
568
+ this._elem.addClass('jqplot-table-legend');
569
+
570
+ var ss = {position:'absolute'};
571
+ if (this.background) {
572
+ ss['background'] = this.background;
573
+ }
574
+ if (this.border) {
575
+ ss['border'] = this.border;
576
+ }
577
+ if (this.fontSize) {
578
+ ss['fontSize'] = this.fontSize;
579
+ }
580
+ if (this.fontFamily) {
581
+ ss['fontFamily'] = this.fontFamily;
582
+ }
583
+ if (this.textColor) {
584
+ ss['textColor'] = this.textColor;
585
+ }
586
+ if (this.marginTop != null) {
587
+ ss['marginTop'] = this.marginTop;
588
+ }
589
+ if (this.marginBottom != null) {
590
+ ss['marginBottom'] = this.marginBottom;
591
+ }
592
+ if (this.marginLeft != null) {
593
+ ss['marginLeft'] = this.marginLeft;
594
+ }
595
+ if (this.marginRight != null) {
596
+ ss['marginRight'] = this.marginRight;
597
+ }
598
+
599
+ this._elem.css(ss);
600
+
601
+ // Pie charts legends don't go by number of series, but by number of data points
602
+ // in the series. Refactor things here for that.
603
+
604
+ var pad = false,
605
+ reverse = false,
606
+ nr,
607
+ nc;
608
+ var s = series[0];
609
+ var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
610
+
611
+ if (s.show) {
612
+ var pd = s.data;
613
+ if (this.numberRows) {
614
+ nr = this.numberRows;
615
+ if (!this.numberColumns){
616
+ nc = Math.ceil(pd.length/nr);
617
+ }
618
+ else{
619
+ nc = this.numberColumns;
620
+ }
621
+ }
622
+ else if (this.numberColumns) {
623
+ nc = this.numberColumns;
624
+ nr = Math.ceil(pd.length/this.numberColumns);
625
+ }
626
+ else {
627
+ nr = pd.length;
628
+ nc = 1;
629
+ }
630
+
631
+ var i, j;
632
+ var tr, td1, td2;
633
+ var lt, rs, color;
634
+ var idx = 0;
635
+ var div0, div1;
636
+
637
+ for (i=0; i<nr; i++) {
638
+ tr = $(document.createElement('tr'));
639
+ tr.addClass('jqplot-table-legend');
640
+
641
+ if (reverse){
642
+ tr.prependTo(this._elem);
643
+ }
644
+
645
+ else{
646
+ tr.appendTo(this._elem);
647
+ }
648
+
649
+ for (j=0; j<nc; j++) {
650
+ if (idx < pd.length){
651
+ lt = this.labels[idx] || pd[idx][0].toString();
652
+ color = colorGenerator.next();
653
+ if (!reverse){
654
+ if (i>0){
655
+ pad = true;
656
+ }
657
+ else{
658
+ pad = false;
659
+ }
660
+ }
661
+ else{
662
+ if (i == nr -1){
663
+ pad = false;
664
+ }
665
+ else{
666
+ pad = true;
667
+ }
668
+ }
669
+ rs = (pad) ? this.rowSpacing : '0';
670
+
671
+
672
+
673
+ td1 = $(document.createElement('td'));
674
+ td1.addClass('jqplot-table-legend jqplot-table-legend-swatch');
675
+ td1.css({textAlign: 'center', paddingTop: rs});
676
+
677
+ div0 = $(document.createElement('div'));
678
+ div0.addClass('jqplot-table-legend-swatch-outline');
679
+ div1 = $(document.createElement('div'));
680
+ div1.addClass('jqplot-table-legend-swatch');
681
+ div1.css({backgroundColor: color, borderColor: color});
682
+ td1.append(div0.append(div1));
683
+
684
+ td2 = $(document.createElement('td'));
685
+ td2.addClass('jqplot-table-legend jqplot-table-legend-label');
686
+ td2.css('paddingTop', rs);
687
+
688
+ if (this.escapeHtml){
689
+ td2.text(lt);
690
+ }
691
+ else {
692
+ td2.html(lt);
693
+ }
694
+ if (reverse) {
695
+ td2.prependTo(tr);
696
+ td1.prependTo(tr);
697
+ }
698
+ else {
699
+ td1.appendTo(tr);
700
+ td2.appendTo(tr);
701
+ }
702
+ pad = true;
703
+ }
704
+ idx++;
705
+ }
706
+ }
707
+ }
708
+ }
709
+ return this._elem;
710
+ };
711
+
712
+ $.jqplot.PieRenderer.prototype.handleMove = function(ev, gridpos, datapos, neighbor, plot) {
713
+ if (neighbor) {
714
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
715
+ plot.target.trigger('jqplotDataMouseOver', ins);
716
+ if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
717
+ plot.target.trigger('jqplotDataHighlight', ins);
718
+ highlight (plot, ins[0], ins[1]);
719
+ }
720
+ }
721
+ else if (neighbor == null) {
722
+ unhighlight (plot);
723
+ }
724
+ };
725
+
726
+
727
+ // this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]);
728
+
729
+ // setup default renderers for axes and legend so user doesn't have to
730
+ // called with scope of plot
731
+ function preInit(target, data, options) {
732
+ options = options || {};
733
+ options.axesDefaults = options.axesDefaults || {};
734
+ options.legend = options.legend || {};
735
+ options.seriesDefaults = options.seriesDefaults || {};
736
+ // only set these if there is a pie series
737
+ var setopts = false;
738
+ if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) {
739
+ setopts = true;
740
+ }
741
+ else if (options.series) {
742
+ for (var i=0; i < options.series.length; i++) {
743
+ if (options.series[i].renderer == $.jqplot.PieRenderer) {
744
+ setopts = true;
745
+ }
746
+ }
747
+ }
748
+
749
+ if (setopts) {
750
+ options.axesDefaults.renderer = $.jqplot.PieAxisRenderer;
751
+ options.legend.renderer = $.jqplot.PieLegendRenderer;
752
+ options.legend.preDraw = true;
753
+ options.seriesDefaults.pointLabels = {show: false};
754
+ }
755
+ }
756
+
757
+ function postInit(target, data, options) {
758
+ for (var i=0; i<this.series.length; i++) {
759
+ if (this.series[i].renderer.constructor == $.jqplot.PieRenderer) {
760
+ // don't allow mouseover and mousedown at same time.
761
+ if (this.series[i].highlightMouseOver) {
762
+ this.series[i].highlightMouseDown = false;
763
+ }
764
+ }
765
+ }
766
+ }
767
+
768
+ // called with scope of plot
769
+ function postParseOptions(options) {
770
+ for (var i=0; i<this.series.length; i++) {
771
+ this.series[i].seriesColors = this.seriesColors;
772
+ this.series[i].colorGenerator = $.jqplot.colorGenerator;
773
+ }
774
+ }
775
+
776
+ function highlight (plot, sidx, pidx) {
777
+ var s = plot.series[sidx];
778
+ var canvas = plot.plugins.pieRenderer.highlightCanvas;
779
+ canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
780
+ s._highlightedPoint = pidx;
781
+ plot.plugins.pieRenderer.highlightedSeriesIndex = sidx;
782
+ s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColorGenerator.get(pidx), false);
783
+ }
784
+
785
+ function unhighlight (plot) {
786
+ var canvas = plot.plugins.pieRenderer.highlightCanvas;
787
+ canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
788
+ for (var i=0; i<plot.series.length; i++) {
789
+ plot.series[i]._highlightedPoint = null;
790
+ }
791
+ plot.plugins.pieRenderer.highlightedSeriesIndex = null;
792
+ plot.target.trigger('jqplotDataUnhighlight');
793
+ }
794
+
795
+ function handleMove(ev, gridpos, datapos, neighbor, plot) {
796
+ if (neighbor) {
797
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
798
+ var evt1 = jQuery.Event('jqplotDataMouseOver');
799
+ evt1.pageX = ev.pageX;
800
+ evt1.pageY = ev.pageY;
801
+ plot.target.trigger(evt1, ins);
802
+ if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
803
+ var evt = jQuery.Event('jqplotDataHighlight');
804
+ evt.which = ev.which;
805
+ evt.pageX = ev.pageX;
806
+ evt.pageY = ev.pageY;
807
+ plot.target.trigger(evt, ins);
808
+ highlight (plot, ins[0], ins[1]);
809
+ }
810
+ }
811
+ else if (neighbor == null) {
812
+ unhighlight (plot);
813
+ }
814
+ }
815
+
816
+ function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
817
+ if (neighbor) {
818
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
819
+ if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
820
+ var evt = jQuery.Event('jqplotDataHighlight');
821
+ evt.which = ev.which;
822
+ evt.pageX = ev.pageX;
823
+ evt.pageY = ev.pageY;
824
+ plot.target.trigger(evt, ins);
825
+ highlight (plot, ins[0], ins[1]);
826
+ }
827
+ }
828
+ else if (neighbor == null) {
829
+ unhighlight (plot);
830
+ }
831
+ }
832
+
833
+ function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
834
+ var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
835
+ if (idx != null && plot.series[idx].highlightMouseDown) {
836
+ unhighlight(plot);
837
+ }
838
+ }
839
+
840
+ function handleClick(ev, gridpos, datapos, neighbor, plot) {
841
+ if (neighbor) {
842
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
843
+ var evt = jQuery.Event('jqplotDataClick');
844
+ evt.which = ev.which;
845
+ evt.pageX = ev.pageX;
846
+ evt.pageY = ev.pageY;
847
+ plot.target.trigger(evt, ins);
848
+ }
849
+ }
850
+
851
+ function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
852
+ if (neighbor) {
853
+ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
854
+ var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
855
+ if (idx != null && plot.series[idx].highlightMouseDown) {
856
+ unhighlight(plot);
857
+ }
858
+ var evt = jQuery.Event('jqplotDataRightClick');
859
+ evt.which = ev.which;
860
+ evt.pageX = ev.pageX;
861
+ evt.pageY = ev.pageY;
862
+ plot.target.trigger(evt, ins);
863
+ }
864
+ }
865
+
866
+ // called within context of plot
867
+ // create a canvas which we can draw on.
868
+ // insert it before the eventCanvas, so eventCanvas will still capture events.
869
+ function postPlotDraw() {
870
+ // Memory Leaks patch
871
+ if (this.plugins.pieRenderer && this.plugins.pieRenderer.highlightCanvas) {
872
+ this.plugins.pieRenderer.highlightCanvas.resetCanvas();
873
+ this.plugins.pieRenderer.highlightCanvas = null;
874
+ }
875
+
876
+ this.plugins.pieRenderer = {highlightedSeriesIndex:null};
877
+ this.plugins.pieRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
878
+
879
+ // do we have any data labels? if so, put highlight canvas before those
880
+ var labels = $(this.targetId+' .jqplot-data-label');
881
+ if (labels.length) {
882
+ $(labels[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
883
+ }
884
+ // else put highlight canvas before event canvas.
885
+ else {
886
+ this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
887
+ }
888
+
889
+ var hctx = this.plugins.pieRenderer.highlightCanvas.setContext();
890
+ this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
891
+ }
892
+
893
+ $.jqplot.preInitHooks.push(preInit);
894
+
895
+ $.jqplot.PieTickRenderer = function() {
896
+ $.jqplot.AxisTickRenderer.call(this);
897
+ };
898
+
899
+ $.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
900
+ $.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer;
901
+
902
+ })(jQuery);
903
+
904
+