function MfCharts(t){this.options=t,this.canvas=t.canvas,this.ctx=this.canvas.getContext("2d"),this.colors=t.colors,this.titleOptions=t.titleOptions,this.totalValue=[...Object.values(this.options.data)].reduce(((t,i)=>t+i),0),this.radius=Math.min(this.canvas.width/2,this.canvas.height/2)-t.padding,this.drawLine=function(t,i,s,e,h,a){t.save(),t.strokeStyle=a,t.beginPath(),t.moveTo(i,s),t.lineTo(e,h),t.stroke(),t.restore()},this.drawArc=function(t,i,s,e,h,a,o){t.save(),t.strokeStyle=o,t.beginPath(),t.arc(i,s,e,h,a),t.stroke(),t.restore()},this.drawPieSlice=function(t,i,s,e,h,a,o,n){t.save(),t.fillStyle=o,t.strokeStyle=n,t.beginPath(),t.moveTo(i,s),t.arc(i,s,e,h,a),t.closePath(),t.fill(),t.stroke(),t.restore()},this.drawSlices=function(){var t=0,i=-Math.PI/2;for(var s in this.options.data){var e=this.options.data[s],h=2*Math.PI*e/this.totalValue;this.drawPieSlice(this.ctx,this.canvas.width/2,this.canvas.height/2,this.radius,i,i+h,this.colors[t%this.colors.length]),i+=h,t++}this.options.doughnutHoleSize&&(this.drawPieSlice(this.ctx,this.canvas.width/2,this.canvas.height/2,this.options.doughnutHoleSize*this.radius,0,2*Math.PI,"#FFF","#FFF"),this.drawArc(this.ctx,this.canvas.width/2,this.canvas.height/2,this.options.doughnutHoleSize*this.radius,0,2*Math.PI,"#000"))},this.drawLabels=function(){var t=-Math.PI/2;for(var i in this.options.data){var s=this.options.data[i],e=2*Math.PI*s/this.totalValue,h=this.canvas.width/2+this.radius/2*Math.cos(t+e/2),a=this.canvas.height/2+this.radius/2*Math.sin(t+e/2);if(this.options.doughnutHoleSize){var o=this.radius*this.options.doughnutHoleSize/2;h=this.canvas.width/2+(o+this.radius/2)*Math.cos(t+e/2),a=this.canvas.height/2+(o+this.radius/2)*Math.sin(t+e/2)}var n=Number(100*s/this.totalValue).toFixed(2);this.ctx.fillStyle="black",this.ctx.font="20px Khand",this.ctx.fillText(n+"%",h,a),t+=e}},this.drawTitle=function(){this.ctx.save(),this.ctx.textBaseline="bottom",this.ctx.textAlign=this.titleOptions.align,this.ctx.fillStyle=this.titleOptions.fill,this.ctx.font=`${this.titleOptions.font.weight} ${this.titleOptions.font.size} ${this.titleOptions.font.family}`;let t=this.canvas.width/2;"left"==this.titleOptions.align&&(t=10),"right"==this.titleOptions.align&&(t=this.canvas.width-10),this.ctx.fillText(this.options.seriesName,t,this.canvas.height),this.ctx.restore()},this.drawLegend=function(){let t=0,i=document.querySelector("div[for='quiz_overview_canvas']"),s=document.createElement("ul");i.append(s);for(let i of Object.keys(this.options.data)){let e=document.createElement("li");e.style.listStyle="none",e.style.borderLeft="20px solid "+this.colors[t%this.colors.length],e.style.padding="5px",e.textContent=i,s.append(e),t++}},this.draw=function(){this.drawSlices(),this.drawLabels(),this.drawTitle(),this.drawLegend()}}