diff --git a/dist/donutty-jquery.js b/dist/donutty-jquery.js index 7df9d22..6fe3e8d 100644 --- a/dist/donutty-jquery.js +++ b/dist/donutty-jquery.js @@ -1,7 +1,7 @@ /** * donutty // Create SVG donut charts with Javascript * @author simeydotme - * @version 1.2.0 + * @version 1.2.1 * @license ISC * @link http://simey.me * @preserve diff --git a/dist/donutty-jquery.min.js b/dist/donutty-jquery.min.js index 6e99c9d..bdb40b9 100644 --- a/dist/donutty-jquery.min.js +++ b/dist/donutty-jquery.min.js @@ -1,7 +1,7 @@ /** * donutty // Create SVG donut charts with Javascript * @author simeydotme - * @version 1.2.0 + * @version 1.2.1 * @license ISC * @link http://simey.me * @preserve diff --git a/dist/donutty.js b/dist/donutty.js index 7e5a7e9..a66b768 100644 --- a/dist/donutty.js +++ b/dist/donutty.js @@ -1,7 +1,7 @@ /** * donutty // Create SVG donut charts with Javascript * @author simeydotme - * @version 1.2.0 + * @version 1.2.1 * @license ISC * @link http://simey.me * @preserve diff --git a/dist/donutty.min.js b/dist/donutty.min.js index cf71bca..19635f4 100644 --- a/dist/donutty.min.js +++ b/dist/donutty.min.js @@ -1,9 +1,9 @@ /** * donutty // Create SVG donut charts with Javascript * @author simeydotme - * @version 1.2.0 + * @version 1.2.1 * @license ISC * @link http://simey.me * @preserve */ -!function(e,t){var i,o="http://www.w3.org/2000/svg";function n(t){return void 0!==t}function s(t){return parseFloat(t,10)}function r(t){return n(t)&&(!0===t||"true"===t)}(i=t.Donutty=function(t,i){return t&&"string"==typeof t?this.$wrapper=e.querySelectorAll(t)[0]:t instanceof window.HTMLElement?this.$wrapper=t:(this.$wrapper=e.body,i=t),this.$wrapper&&(n(i)||(i=this.getOptionsFromTag()),this.state={},this.options=i||{},this.options.min=n(this.options.min)?s(this.options.min):0,this.options.max=n(this.options.max)?s(this.options.max):100,this.options.value=n(this.options.value)?s(this.options.value):50,this.options.round=!n(this.options.round)||r(this.options.round),this.options.circle=!n(this.options.circle)||r(this.options.circle),this.options.padding=n(this.options.padding)?s(this.options.padding):4,this.options.radius=s(this.options.radius)||50,this.options.thickness=s(this.options.thickness)||10,this.options.bg=this.options.bg||"rgba(70, 130, 180, 0.15)",this.options.color=this.options.color||"mediumslateblue",this.options.transition=this.options.transition||"all 1.2s cubic-bezier(0.57, 0.13, 0.18, 0.98)",this.options.text=!!n(this.options.text)&&this.options.text,this.init()),this}).prototype.getOptionsFromTag=function(){return JSON.parse(JSON.stringify(this.$wrapper.dataset))},i.prototype.init=function(){var t;return(this.$wrapper.donutty=this).createState(),t=this.getDashValues(),this.createSvg(),this.createBg(t),this.createDonut(t),this.createText(),this.insertFragments(t),this},i.prototype.createState=function(){return this.state.min=this.options.min,this.state.max=this.options.max,this.state.value=this.options.value,this.state.bg=this.options.bg,this.state.color=this.options.color,this},i.prototype.createText=function(){return"function"==typeof this.options.text&&(this.$text=e.createElement("span"),this.$text.classList.add("donut-text"),this.$text.style.opacity=0,this.updateText()),this},i.prototype.createBg=function(t){return this.$bg=e.createElementNS(o,"circle"),this.$bg.setAttribute("cx","50%"),this.$bg.setAttribute("cy","50%"),this.$bg.setAttribute("r",this.options.radius),this.$bg.setAttribute("fill","transparent"),this.$bg.setAttribute("stroke",this.state.bg),this.$bg.setAttribute("stroke-width",this.options.thickness+this.options.padding),this.$bg.setAttribute("stroke-dasharray",t.full*t.multiplier),this.$bg.classList.add("donut-bg"),this.options.round&&this.$bg.setAttribute("stroke-linecap","round"),this},i.prototype.createDonut=function(t){return this.$donut=e.createElementNS(o,"circle"),this.$donut.setAttribute("fill","transparent"),this.$donut.setAttribute("cx","50%"),this.$donut.setAttribute("cy","50%"),this.$donut.setAttribute("r",this.options.radius),this.$donut.setAttribute("stroke",this.state.color),this.$donut.setAttribute("stroke-width",this.options.thickness),this.$donut.setAttribute("stroke-dashoffset",t.full),this.$donut.setAttribute("stroke-dasharray",t.full),this.$donut.classList.add("donut-fill"),this.$donut.style.opacity=0,this.options.round&&this.$donut.setAttribute("stroke-linecap","round"),this},i.prototype.createSvg=function(){var t=2*this.options.radius+this.options.thickness+2*this.options.padding,i=this.options.round?this.options.thickness/3:0,s=this.options.circle?90+i:-225;return this.$html=e.createDocumentFragment(),this.$svg=e.createElementNS(o,"svg"),this.$svg.setAttribute("xmlns",o),this.$svg.setAttribute("viewbox","0 0 "+t+" "+t),this.$svg.setAttribute("transform","rotate( "+s+" )"),this.$svg.classList.add("donut"),this.$svg.style.width=t,this.$svg.style.height=t,this},i.prototype.insertFragments=function(t){this.$svg.appendChild(this.$bg),this.$svg.appendChild(this.$donut),this.$html.appendChild(this.$svg),this.$text&&this.$html.appendChild(this.$text),this.$wrapper.appendChild(this.$html),this.animate(t.fill,t.full)},i.prototype.getDashValues=function(){var t,i,s,e;return e=this.options.circle?1:.75,s=(t=2*Math.PI*this.options.radius)-t*e/100*(i=(this.state.value-this.state.min)/(this.state.max-this.state.min)*100),this.options.round&&this.options.circle&&i<100&&s