OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/assets/javascripts/jquery.jqplot/plugins/jqplot.pieRenderer.min.js

14 lines
5.5 KiB

/**
* Copyright (c) 2009 Chris Leonello
* jqPlot is currently available for use in all personal or commercial projects
* under both the MIT and GPL version 2.0 licenses. This means that you can
* choose the license that best suits your project and use it accordingly.
*
* Although not required, the author would appreciate an email letting him
* know of any substantial use of jqPlot. You can reach the author at:
* chris dot leonello at gmail dot com or see http://www.jqplot.com/info.php .
*
* If you are feeling kind and generous, consider supporting the project by
* making a donation at: http://www.jqplot.com/donate.php .
*/
(function(b){b.jqplot.PieRenderer=function(){b.jqplot.LineRenderer.call(this)};b.jqplot.PieRenderer.prototype=new b.jqplot.LineRenderer();b.jqplot.PieRenderer.prototype.constructor=b.jqplot.PieRenderer;b.jqplot.PieRenderer.prototype.init=function(d){this.diameter=null;this.padding=20;this.sliceMargin=0;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.tickRenderer=b.jqplot.PieTickRenderer;b.extend(true,this,d);if(this.diameter!=null){this.diameter=this.diameter-this.sliceMargin}this._diameter=null};b.jqplot.PieRenderer.prototype.setGridData=function(d){};b.jqplot.PieRenderer.prototype.makeGridData=function(g,h){var d=[];var j=[];for(var f=0;f<g.length;f++){d.push(g[f][1]);j.push([g[f][0]]);if(f>0){d[f]+=d[f-1]}}var e=Math.PI*2/d[d.length-1];for(var f=0;f<d.length;f++){j[f][1]=d[f]*e}return j};b.jqplot.PieRenderer.prototype.drawSlice=function(n,l,k,f,h){var d=this._diameter/2;var m=this.fill;var j=this.lineWidth;n.save();n.translate(this.sliceMargin*Math.cos((l+k)/2),this.sliceMargin*Math.sin((l+k)/2));if(h){for(var g=0;g<this.shadowDepth;g++){n.save();n.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));e()}}else{e()}function e(){if(k>6.282){k=6.282;if(l>k){l=6.281}}n.beginPath();n.moveTo(0,0);n.fillStyle=f;n.strokeStyle=f;n.lineWidth=j;n.arc(0,0,d,l,k,false);n.closePath();if(m){n.fill()}else{n.stroke()}}if(h){for(var g=0;g<this.shadowDepth;g++){n.restore()}}n.restore()};b.jqplot.PieRenderer.prototype.draw=function(v,B,k){var y;var s=(k!=undefined)?k:{};var g=0;var f=0;var l=1;var e=new this.colorGenerator(this.seriesColors);if(k.legendInfo){var q=k.legendInfo;switch(q.location){case"nw":g=q.width+q.xoffset;break;case"w":g=q.width+q.xoffset;break;case"sw":g=q.width+q.xoffset;break;case"ne":g=q.width+q.xoffset;l=-1;break;case"e":g=q.width+q.xoffset;l=-1;break;case"se":g=q.width+q.xoffset;l=-1;break;case"n":f=q.height+q.yoffset;break;case"s":f=q.height+q.yoffset;l=-1;break;default:break}}var n=(s.shadow!=undefined)?s.shadow:this.shadow;var C=(s.showLine!=undefined)?s.showLine:this.showLine;var x=(s.fill!=undefined)?s.fill:this.fill;var j=v.canvas.width;var p=v.canvas.height;var o=j-g-2*this.padding;var z=p-f-2*this.padding;var A=Math.min(o,z);this._diameter=this.diameter||A-this.sliceMargin;var t=this._diameter/2;v.save();v.translate((j-l*g)/2+l*g,(p-l*f)/2+l*f);if(this.shadow){var u="rgba(0,0,0,"+this.shadowAlpha+")";for(var y=0;y<B.length;y++){var m=(y==0)?0:B[y-1][1];this.renderer.drawSlice.call(this,v,m,B[y][1],u,true)}}for(var y=0;y<B.length;y++){var m=(y==0)?0:B[y-1][1];this.renderer.drawSlice.call(this,v,m,B[y][1],e.next())}v.restore()};b.jqplot.PieAxisRenderer=function(){b.jqplot.LinearAxisRenderer.call(this)};b.jqplot.PieAxisRenderer.prototype=new b.jqplot.LinearAxisRenderer();b.jqplot.PieAxisRenderer.prototype.constructor=b.jqplot.PieAxisRenderer;b.jqplot.PieAxisRenderer.prototype.init=function(d){this.tickRenderer=b.jqplot.PieTickRenderer;b.extend(true,this,d);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};b.jqplot.PieLegendRenderer=function(){b.jqplot.TableLegendRenderer.call(this)};b.jqplot.PieLegendRenderer.prototype=new b.jqplot.TableLegendRenderer();b.jqplot.PieLegendRenderer.prototype.constructor=b.jqplot.PieLegendRenderer;b.jqplot.PieLegendRenderer.prototype.draw=function(){var k=this;if(this.show){var f=this._series;var m="position:absolute;";m+=(this.background)?"background:"+this.background+";":"";m+=(this.border)?"border:"+this.border+";":"";m+=(this.fontSize)?"font-size:"+this.fontSize+";":"";m+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";m+=(this.textColor)?"color:"+this.textColor+";":"";this._elem=b('<table class="jqplot-table-legend" style="'+m+'"></table>');var d=false;var l=f[0];var h=new l.colorGenerator(l.seriesColors);if(l.show){var j=l.data;for(var g=0;g<j.length;g++){var e=j[g][0].toString();if(e){this.renderer.addrow.call(this,e,h.next(),d);d=true}}}}return this._elem};function a(h,g,e){e=e||{};e.axesDefaults=e.axesDefaults||{};e.legend=e.legend||{};e.seriesDefaults=e.seriesDefaults||{};var d=false;if(e.seriesDefaults.renderer==b.jqplot.PieRenderer){d=true}else{if(e.series){for(var f=0;f<e.series.length;f++){if(e.series[f].renderer==b.jqplot.PieRenderer){d=true}}}}if(d){e.axesDefaults.renderer=b.jqplot.PieAxisRenderer;e.legend.renderer=b.jqplot.PieLegendRenderer;e.legend.preDraw=true}}function c(d){for(var e=0;e<this.series.length;e++){this.series[e].seriesColors=this.seriesColors;this.series[e].colorGenerator=this.colorGenerator}}b.jqplot.preInitHooks.push(a);b.jqplot.postParseOptionsHooks.push(c);b.jqplot.PieTickRenderer=function(){b.jqplot.AxisTickRenderer.call(this)};b.jqplot.PieTickRenderer.prototype=new b.jqplot.AxisTickRenderer();b.jqplot.PieTickRenderer.prototype.constructor=b.jqplot.PieTickRenderer})(jQuery);