var CircularProgressBar=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach((function(e){r(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n={colorCircle:!1,colorSlice:"#00a1ff",end:264,fontColor:"#365b74",fontSize:"1.6rem",fontWeight:400,lineargradient:!1,number:!0,round:!1,opacity:10,size:200,stroke:10};return function e(i){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"initial",(function(e){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,t){e.map((function(e){e.isIntersecting&&e.intersectionRatio>.75&&(o.createSvg(e.target),t.unobserve(e.target))}))}),{root:null,rootMargin:"0px",threshold:1});e.map((function(e){t.observe(e)}))}else e.map((function(e){o.createSvg(e)}))})),r(this,"hex2rgb",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r="string"==typeof e?parseInt(e.replace("#",""),16):e;return"rgba(".concat(r>>16,", ").concat((65280&r)>>8,", ").concat(255&r,", ").concat(t/100,")")})),r(this,"progressBar",(function(e,r,n){var i=n.index,c=n.number,a=n.stroke,s=n.round,l=n.lineargradient,u=n.colorSlice,d=n.colorCircle,f=n.rotation,p=n.opacity,g=n.size;c&&e.insertBefore(o.percentElement(n),e.firstElementChild);var h=document.querySelector(".".concat(o.pieName,"-circle-").concat(i)),m={fill:"none","stroke-width":a,"stroke-dasharray":264,"stroke-linecap":s?"round":""};o.setAttr(h,m,!1),h.setAttribute("style","transform: rotate(".concat(f||-90,"deg); transform-origin: 50% 50%")),o.animationTo(t(t({},n),{},{element:h}),!0),h.setAttribute("stroke",l?"url(#linear-".concat(i,")"):u);var v=d?"":"border-radius:50%;box-shadow:inset 0px 0px ".concat(a,"px ").concat(a,"px ").concat(o.hex2rgb(u,p));r.setAttribute("style","width:".concat(g,"px;height:").concat(g,"px;position:relative;").concat(v))})),r(this,"getDashOffset",(function(e,t){var r=264-e/100*264;return t?-r:r})),r(this,"animationTo",(function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=Math.round(e.percent),c=JSON.parse(document.querySelector('[data-index="'.concat(e.index,'"]')).dataset.pie),a=document.querySelector(".".concat(o.pieName,"-circle-").concat(e.index));if(a){var s=JSON.parse(a.getAttribute("data-angel")),l=r?e:t(t(t({},n),c),e),u=document.querySelector(".".concat(o.pieName,"-percent-").concat(e.index));if(l.animationOff)return l.number&&(u.textContent="".concat(l.percent,"%")),void a.setAttribute("stroke-dashoffset",o.getDashOffset(l.percent,l.inverse));if(0==i&&(l.number&&(u.textContent="0%"),a.setAttribute("stroke-dashoffset",264)),!(i>100||i<=0||s===i)){var d,f=r?0:s,p=function e(){s>=l.percent?f--:f++,d=requestAnimationFrame(e),a.setAttribute("stroke-dashoffset",o.getDashOffset(f,l.inverse)),u&&l.number&&(u.textContent="".concat(f,"%")),f===i&&(a.setAttribute("data-angel",f),cancelAnimationFrame(d))};requestAnimationFrame(p)}}})),r(this,"percentElement",(function(e){var t=e.index,r=e.fontSize,n=e.fontWeight,i=e.fontColor,c=document.createElementNS(o.svg,"text"),a={class:"".concat(o.pieName,"-percent-").concat(t),x:"50%",y:"50%",fill:i,"font-size":r,"font-weight":n,"text-anchor":"middle",dy:"0.35em"};return o.setAttr(c,a,!1),c})),r(this,"createSvg",(function(e){var r=JSON.parse(e.getAttribute("data-pie")),i=e.getAttribute("data-index"),c=t(t(t({},n),r),{},{index:i}),a=document.createElementNS(o.svg,"svg"),s={role:"img",width:c.size,height:c.size,viewBox:"0 0 100 100"};o.setAttr(a,s,!1),c.colorCircle&&a.appendChild(o.circleSvg(c,"bottom")),c.lineargradient&&a.appendChild(o.gradient(c)),a.appendChild(o.circleSvg(c,"top",!0)),e.appendChild(a),o.progressBar(a,e,c)})),r(this,"gradient",(function(e){var t=e.index,r=e.lineargradient,n=document.createElementNS(o.svg,"defs"),i=document.createElementNS(o.svg,"linearGradient");i.id="linear-".concat(t);var c=[].slice.call(r);n.appendChild(i);var a=0;return c.map((function(e){var t=document.createElementNS(o.svg,"stop"),r={offset:"".concat(a,"%"),"stop-color":"".concat(e)};o.setAttr(t,r,!1),i.appendChild(t),a+=100/(c.length-1)})),n})),r(this,"circleSvg",(function(e,r){var n=e.index,i=e.colorCircle,c=e.stroke,a=e.strokeBottom,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=document.createElementNS(o.svg,"circle"),u={fill:"none",stroke:i,"stroke-width":a||c},d="top"===r?{class:"".concat(o.pieName,"-circle-").concat(n)}:u,f=t({cx:"50%",cy:"50%",r:42,"shape-rendering":"geometricPrecision","data-angle":s?0:""},d);return o.setAttr(l,f,!1),l})),r(this,"setAttr",(function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];for(var n in t)r?e.setAttributeNS(null,n,t[n]):e.setAttribute(n,t[n])})),this.pieName=i,this.svg="http://www.w3.org/2000/svg";var c=document.querySelectorAll(".".concat(i)),a=[].slice.call(c);a.map((function(e,t){e.setAttribute("data-index",t+1)})),this.initial(a)}}();
Edit file:circularProgressBar.min.js6680