chartjs-plugin-piechart-outlabels
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -10,2 +10,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e(t.Chart)}(this,function(t){"use strict";function e(t,e){var i=t.outlabels,s={};return i===!1?null:(i===!0&&(i={}),o.merge(s,[e,i]))}t=t&&t.hasOwnProperty("default")?t["default"]:t;var i={LABEL_KEY:"$outlabels",backgroundColor:function(t){return t.dataset.backgroundColor},borderColor:function(t){return t.dataset.backgroundColor},lineColor:function(t){return t.dataset.backgroundColor},borderRadius:2,borderWidth:2,lineWidth:2,color:"white",display:!0,font:{family:void 0,size:void 0,style:void 0,weight:null,resizable:!0},lineHeight:1.2,padding:{top:4,right:4,bottom:4,left:4},textAlign:"center",stretch:40,text:"%l %p"},s={center:function(t,e,i){var s=(t.startAngle+t.endAngle)/2,h=Math.cos(s),a=Math.sin(s),r=t.outerRadius,n=r+i;return{x:t.x+h*n,y:t.y+a*n,d:n,arc:t,anchor:{x:t.x+h*r,y:t.y+a*r},copy:{x:t.x+h*n,y:t.y+a*n}}},moveFromAnchor:function(t,e){var i=t.arc,s=t.d,h=(i.startAngle+i.endAngle)/2,a=Math.cos(h),r=Math.sin(h);return s+=e,{x:i.x+a*s,y:i.y+r*s,d:s,arc:i,anchor:t.anchor,copy:{x:i.x+a*s,y:i.y+r*s}}}},h=t.helpers,a=i.LABEL_KEY,r={OutLabel:function(e,r,n,o,l){var d=t.helpers.options.resolve;if(!d([o.display,!0],l,r))return delete this,null;var c=l.dataset.data[r],f=l.dataset.labels[r],u=h.valueOrDefault(o.text,"%v %p");u=u.replace(/%l/gi,f),u=u.replace(/%v/gi,c),u=u.replace(/%p/gi,(100*l.percent).toFixed(1)+"%");var x=u.match(/[^\r\n]+/g);if(!x||!x.length)return null;for(var y=0;y<x.length;++y)x[y]=x[y].trim();this.init=function(t,s){this.encodedText=o.text,this.text=t,this.lines=s,this.label=f,this.value=c,this.ctx=n,this.style={backgroundColor:d([o.backgroundColor,i.backgroundColor,"black"],l,r),borderColor:d([o.borderColor,i.borderColor,"black"],l,r),borderRadius:d([o.borderRadius,0],l,r),borderWidth:d([o.borderWidth,0],l,r),lineWidth:d([o.lineWidth,2],l,r),lineColor:d([o.lineColor,i.lineColor,"black"],l,r),color:d([o.color,"white"],l,r),font:h.parseFont(d([o.font,{resizable:!0}])),padding:h.options.toPadding(d([o.padding,0],l,r)),textAlign:d([o.textAlign,"left"],l,r)},this.stretch=d([o.stretch,40],l,r),this.size=h.textSize(n,this.lines,this.style.font),this.offsetStep=this.size.width/20,this.offset={x:0,y:0},this.predictedOffset=this.offset;var a=-((e._model.startAngle+e._model.endAngle)/2)/Math.PI,u=Math.abs(a-Math.trunc(a));u>.45&&u<.55?this.predictedOffset.x=0:a<=.45&&a>=-.45?this.predictedOffset.x=this.size.width/2:a>=-1.45&&a<=-.55&&(this.predictedOffset.x=-this.size.width/2)},this.init(u,x),this.computeLabelRect=function(){var t=this.textRect.width+2*this.style.borderWidth,e=this.textRect.height+2*this.style.borderWidth,i=this.textRect.x-this.style.padding.left-this.style.borderWidth,s=this.textRect.y-this.style.padding.top-this.style.borderWidth;return t+=this.style.padding.width,e+=this.style.padding.height,{x:i,y:s,width:t,height:e}},this.computeTextRect=function(){return{x:this.center.x-this.size.width/2,y:this.center.y-this.size.height/2,width:this.size.width,height:this.size.height}},this.getPoints=function(){return[{x:this.labelRect.x,y:this.labelRect.y},{x:this.labelRect.x+this.labelRect.width,y:this.labelRect.y},{x:this.labelRect.x+this.labelRect.width,y:this.labelRect.y+this.labelRect.height},{x:this.labelRect.x,y:this.labelRect.y+this.labelRect.height}]},this.containsPoint=function(t,e){return e||(e=5),this.labelRect.x-e<=t.x&&t.x<=this.labelRect.x+this.labelRect.width+e&&this.labelRect.y-e<=t.y&&t.y<=this.labelRect.y+this.labelRect.height+e},this.drawText=function(){var t,e,i,s=this.style.textAlign,h=this.style.font,a=h.lineHeight,r=this.style.color,n=this.lines.length;if(n&&r)for(t=this.textRect.x,e=this.textRect.y+a/2,"center"===s?t+=this.textRect.width/2:"end"!==s&&"right"!==s||(t+=this.textRect.width),this.ctx.font=this.style.font.string,this.ctx.fillStyle=r,this.ctx.textAlign=s,this.ctx.textBaseline="middle",i=0;i<n;++i)this.ctx.fillText(this.lines[i],Math.round(t),Math.round(e),Math.round(this.textRect.width)),e+=a},this.drawLabel=function(){n.beginPath(),h.canvas.roundedRect(this.ctx,Math.round(this.labelRect.x),Math.round(this.labelRect.y),Math.round(this.labelRect.width),Math.round(this.labelRect.height),this.style.borderRadius),this.ctx.closePath(),this.style.backgroundColor&&(this.ctx.fillStyle=this.style.backgroundColor||"black",this.ctx.fill()),this.style.borderColor&&this.style.borderWidth&&(this.ctx.strokeStyle=this.style.borderColor,this.ctx.lineWidth=this.style.borderWidth,this.ctx.lineJoin="miter",this.ctx.stroke())},this.drawLine=function(){this.ctx.save(),this.ctx.strokeStyle=this.style.lineColor,this.ctx.lineWidth=this.style.lineWidth,this.ctx.lineJoin="miter",this.ctx.beginPath(),this.ctx.moveTo(this.center.anchor.x,this.center.anchor.y),this.ctx.lineTo(this.center.copy.x,this.center.copy.y),this.ctx.stroke(),this.ctx.restore()},this.draw=function(){this.drawLabel(),this.drawText()},this.update=function(t,e,i){this.center=s.center(t,"out",this.stretch),this.moveLabelToOffset(),this.center.x+=this.offset.x,this.center.y+=this.offset.y;for(var h=!1;!h;){this.textRect=this.computeTextRect(),this.labelRect=this.computeLabelRect();var r=this.getPoints();h=!0;for(var n=0;n<i;++n){var o=e[n][a];if(o)for(var l=o.getPoints(),d=0;d<r.length;++d){if(o.containsPoint(r[d])){h=!1;break}if(this.containsPoint(l[d])){h=!1;break}}}h||(this.center=s.moveFromAnchor(this.center,1),this.center.x+=this.offset.x,this.center.y+=this.offset.y)}},this.moveLabelToOffset=function(){this.predictedOffset.x<=0&&this.offset.x>this.predictedOffset.x?(this.offset.x-=this.offsetStep,this.offset.x<=this.predictedOffset.x&&(this.offset.x=this.predictedOffset.x)):this.predictedOffset.x>=0&&this.offset.x<this.predictedOffset.x&&(this.offset.x+=this.offsetStep,this.offset.x>=this.predictedOffset.x&&(this.offset.x=this.predictedOffset.x))}}},n=t.helpers,o=n.merge(n,{toFontString:function(t){return!t||n.isNullOrUndef(t.size)||n.isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family},textSize:function(t,e,i){var s,h=[].concat(e),a=h.length,r=t.font,n=0;for(t.font=i.string,s=0;s<a;++s)n=Math.max(t.measureText(h[s]).width,n);return t.font=r,{height:a*i.lineHeight,width:n}},parseFont:function(e){var i=t.defaults.global,s=n.valueOrDefault(e.size,i.defaultFontSize),h={family:n.valueOrDefault(e.family,i.defaultFontFamily),lineHeight:n.options.toLineHeight(e.lineHeight,s),size:s,style:n.valueOrDefault(e.style,i.defaultFontStyle),weight:n.valueOrDefault(e.weight,null),string:""};return h.string=n.toFontString(h),h},isEmptyObj:function(t){for(var e in t)if(e)return!1;return!0}});t.defaults.outlabeledPie=t.defaults.doughnut;var l=t.controllers.doughnut.extend({update:function(e){var i=this,s=i.chart,h=s.chartArea,a=s.options,r=a.elements.arc,n=h.right-h.left-r.borderWidth,o=h.bottom-h.top-r.borderWidth,l=Math.min(n,o),d={x:0,y:0},c=i.getMeta(),f=a.cutoutPercentage,u=a.circumference;if(u<2*Math.PI){var x=a.rotation%(2*Math.PI);x+=2*Math.PI*(x>=Math.PI?-1:x<-Math.PI?1:0);var y=x+u,g={x:Math.cos(x),y:Math.sin(x)},b={x:Math.cos(y),y:Math.sin(y)},p=x<=0&&y>=0||x<=2*Math.PI&&2*Math.PI<=y,R=x<=.5*Math.PI&&.5*Math.PI<=y||x<=2.5*Math.PI&&2.5*Math.PI<=y,v=x<=-Math.PI&&-Math.PI<=y||x<=Math.PI&&Math.PI<=y,m=x<=.5*-Math.PI&&.5*-Math.PI<=y||x<=1.5*Math.PI&&1.5*Math.PI<=y,M=f/100,w={x:v?-1:Math.min(g.x*(g.x<0?1:M),b.x*(b.x<0?1:M)),y:m?-1:Math.min(g.y*(g.y<0?1:M),b.y*(b.y<0?1:M))},P={x:p?1:Math.max(g.x*(g.x>0?1:M),b.x*(b.x>0?1:M)),y:R?1:Math.max(g.y*(g.y>0?1:M),b.y*(b.y>0?1:M))},O={width:.5*(P.x-w.x),height:.5*(P.y-w.y)};l=Math.min(n/O.width,o/O.height),d={x:(P.x+w.x)*-.5,y:(P.y+w.y)*-.5}}s.borderWidth=i.getMaxBorderWidth(c.data),s.outerRadius=Math.max((l-s.borderWidth)/2,0),s.innerRadius=Math.max(f?s.outerRadius/100*f:0,0),s.radiusLength=(s.outerRadius-s.innerRadius)/s.getVisibleDatasetCount(),s.offsetX=d.x*s.outerRadius,s.offsetY=d.y*s.outerRadius,c.total=i.calculateTotal(),i.outerRadius=s.outerRadius-s.radiusLength*i.getRingIndex(i.index),i.innerRadius=Math.max(i.outerRadius-s.radiusLength,0),i.outerRadius*=.5,i.innerRadius*=.5,t.helpers.each(c.data,function(t,s){i.updateElement(t,s,e)})}});t.controllers.outlabeledPie=l,t.defaults.global.plugins.outlabels=i;var d=i.LABEL_KEY;t.plugins.register({id:"outlabels",resize:function(t,e,i){i.font.resizable&&(i.font.size=e.height/100*2.5,i.font.changed=!0)},afterInit:function(t,e){var i=t.canvas.style;e.font.resizable&&(e.font.size=i.height.slice(0,-2)/100*2.5)},afterDatasetUpdate:function(t,i,s){var h,a,n,l,c=t.data.datasets[i.index],f=e(c,s),u=f&&f.display,x=i.meta.data||[],y=t.ctx;y.save();for(var g=0;g<x.length;++g)h=x[g],a=h[d],n=c.data[g]/i.meta.total,l=u&&h&&!h.hidden?new r.OutLabel(h,g,y,f,{chart:t,dataIndex:g,dataset:c,datasetIndex:i.index,percent:n}):null,l=o.isEmptyObj(l)?null:l,a&&l&&!s.font.changed&&a.label===l.label&&a.encodedText===l.encodedText&&(l.offset=a.offset),h[d]=l;y.restore(),s.font.changed&&(s.font.changed=!1)},afterDatasetDraw:function(t,e){for(var i,s,h,a=e.meta.data||[],r=t.ctx,n=0;n<2*a.length;++n)h=n<a.length?n:n-a.length,i=a[h],s=i[d],s&&(n<a.length?(s.update(i._view,a,n),s.drawLine(r)):s.draw(r))}})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e(t.Chart)}(this,function(t){"use strict";function e(t,e){var i=t.outlabels,s={};return i===!1?null:(i===!0&&(i={}),o.merge(s,[e,i]))}t=t&&t.hasOwnProperty("default")?t["default"]:t;var i={LABEL_KEY:"$outlabels",backgroundColor:function(t){return t.dataset.backgroundColor},borderColor:function(t){return t.dataset.backgroundColor},lineColor:function(t){return t.dataset.backgroundColor},borderRadius:2,borderWidth:2,lineWidth:2,color:"white",display:!0,font:{family:void 0,size:void 0,style:void 0,weight:null,resizable:!0},lineHeight:1.2,padding:{top:4,right:4,bottom:4,left:4},textAlign:"center",stretch:40,text:"%l %p"},s={center:function(t,e,i){var s=(t.startAngle+t.endAngle)/2,h=Math.cos(s),a=Math.sin(s),r=t.outerRadius,n=r+i;return{x:t.x+h*n,y:t.y+a*n,d:n,arc:t,anchor:{x:t.x+h*r,y:t.y+a*r},copy:{x:t.x+h*n,y:t.y+a*n}}},moveFromAnchor:function(t,e){var i=t.arc,s=t.d,h=(i.startAngle+i.endAngle)/2,a=Math.cos(h),r=Math.sin(h);return s+=e,{x:i.x+a*s,y:i.y+r*s,d:s,arc:i,anchor:t.anchor,copy:{x:i.x+a*s,y:i.y+r*s}}}},h=t.helpers,a=i.LABEL_KEY,r={OutLabel:function(e,r,n,o,l){var d=t.helpers.options.resolve;if(!d([o.display,!0],l,r))return delete this,null;var c=l.dataset.data[r],f=l.labels[r],u=h.valueOrDefault(o.text,"%v %p");u=u.replace(/%l/gi,f),u=u.replace(/%v/gi,c),u=u.replace(/%p/gi,(100*l.percent).toFixed(1)+"%");var x=u.match(/[^\r\n]+/g);if(!x||!x.length)return null;for(var y=0;y<x.length;++y)x[y]=x[y].trim();this.init=function(t,s){this.encodedText=o.text,this.text=t,this.lines=s,this.label=f,this.value=c,this.ctx=n,this.style={backgroundColor:d([o.backgroundColor,i.backgroundColor,"black"],l,r),borderColor:d([o.borderColor,i.borderColor,"black"],l,r),borderRadius:d([o.borderRadius,0],l,r),borderWidth:d([o.borderWidth,0],l,r),lineWidth:d([o.lineWidth,2],l,r),lineColor:d([o.lineColor,i.lineColor,"black"],l,r),color:d([o.color,"white"],l,r),font:h.parseFont(d([o.font,{resizable:!0}])),padding:h.options.toPadding(d([o.padding,0],l,r)),textAlign:d([o.textAlign,"left"],l,r)},this.stretch=d([o.stretch,40],l,r),this.size=h.textSize(n,this.lines,this.style.font),this.offsetStep=this.size.width/20,this.offset={x:0,y:0},this.predictedOffset=this.offset;var a=-((e._model.startAngle+e._model.endAngle)/2)/Math.PI,u=Math.abs(a-Math.trunc(a));u>.45&&u<.55?this.predictedOffset.x=0:a<=.45&&a>=-.45?this.predictedOffset.x=this.size.width/2:a>=-1.45&&a<=-.55&&(this.predictedOffset.x=-this.size.width/2)},this.init(u,x),this.computeLabelRect=function(){var t=this.textRect.width+2*this.style.borderWidth,e=this.textRect.height+2*this.style.borderWidth,i=this.textRect.x-this.style.padding.left-this.style.borderWidth,s=this.textRect.y-this.style.padding.top-this.style.borderWidth;return t+=this.style.padding.width,e+=this.style.padding.height,{x:i,y:s,width:t,height:e}},this.computeTextRect=function(){return{x:this.center.x-this.size.width/2,y:this.center.y-this.size.height/2,width:this.size.width,height:this.size.height}},this.getPoints=function(){return[{x:this.labelRect.x,y:this.labelRect.y},{x:this.labelRect.x+this.labelRect.width,y:this.labelRect.y},{x:this.labelRect.x+this.labelRect.width,y:this.labelRect.y+this.labelRect.height},{x:this.labelRect.x,y:this.labelRect.y+this.labelRect.height}]},this.containsPoint=function(t,e){return e||(e=5),this.labelRect.x-e<=t.x&&t.x<=this.labelRect.x+this.labelRect.width+e&&this.labelRect.y-e<=t.y&&t.y<=this.labelRect.y+this.labelRect.height+e},this.drawText=function(){var t,e,i,s=this.style.textAlign,h=this.style.font,a=h.lineHeight,r=this.style.color,n=this.lines.length;if(n&&r)for(t=this.textRect.x,e=this.textRect.y+a/2,"center"===s?t+=this.textRect.width/2:"end"!==s&&"right"!==s||(t+=this.textRect.width),this.ctx.font=this.style.font.string,this.ctx.fillStyle=r,this.ctx.textAlign=s,this.ctx.textBaseline="middle",i=0;i<n;++i)this.ctx.fillText(this.lines[i],Math.round(t),Math.round(e),Math.round(this.textRect.width)),e+=a},this.drawLabel=function(){n.beginPath(),h.canvas.roundedRect(this.ctx,Math.round(this.labelRect.x),Math.round(this.labelRect.y),Math.round(this.labelRect.width),Math.round(this.labelRect.height),this.style.borderRadius),this.ctx.closePath(),this.style.backgroundColor&&(this.ctx.fillStyle=this.style.backgroundColor||"black",this.ctx.fill()),this.style.borderColor&&this.style.borderWidth&&(this.ctx.strokeStyle=this.style.borderColor,this.ctx.lineWidth=this.style.borderWidth,this.ctx.lineJoin="miter",this.ctx.stroke())},this.drawLine=function(){this.ctx.save(),this.ctx.strokeStyle=this.style.lineColor,this.ctx.lineWidth=this.style.lineWidth,this.ctx.lineJoin="miter",this.ctx.beginPath(),this.ctx.moveTo(this.center.anchor.x,this.center.anchor.y),this.ctx.lineTo(this.center.copy.x,this.center.copy.y),this.ctx.stroke(),this.ctx.restore()},this.draw=function(){this.drawLabel(),this.drawText()},this.update=function(t,e,i){this.center=s.center(t,"out",this.stretch),this.moveLabelToOffset(),this.center.x+=this.offset.x,this.center.y+=this.offset.y;for(var h=!1;!h;){this.textRect=this.computeTextRect(),this.labelRect=this.computeLabelRect();var r=this.getPoints();h=!0;for(var n=0;n<i;++n){var o=e[n][a];if(o)for(var l=o.getPoints(),d=0;d<r.length;++d){if(o.containsPoint(r[d])){h=!1;break}if(this.containsPoint(l[d])){h=!1;break}}}h||(this.center=s.moveFromAnchor(this.center,1),this.center.x+=this.offset.x,this.center.y+=this.offset.y)}},this.moveLabelToOffset=function(){this.predictedOffset.x<=0&&this.offset.x>this.predictedOffset.x?(this.offset.x-=this.offsetStep,this.offset.x<=this.predictedOffset.x&&(this.offset.x=this.predictedOffset.x)):this.predictedOffset.x>=0&&this.offset.x<this.predictedOffset.x&&(this.offset.x+=this.offsetStep,this.offset.x>=this.predictedOffset.x&&(this.offset.x=this.predictedOffset.x))}}},n=t.helpers,o=n.merge(n,{toFontString:function(t){return!t||n.isNullOrUndef(t.size)||n.isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family},textSize:function(t,e,i){var s,h=[].concat(e),a=h.length,r=t.font,n=0;for(t.font=i.string,s=0;s<a;++s)n=Math.max(t.measureText(h[s]).width,n);return t.font=r,{height:a*i.lineHeight,width:n}},parseFont:function(e){var i=t.defaults.global,s=n.valueOrDefault(e.size,i.defaultFontSize),h={family:n.valueOrDefault(e.family,i.defaultFontFamily),lineHeight:n.options.toLineHeight(e.lineHeight,s),size:s,style:n.valueOrDefault(e.style,i.defaultFontStyle),weight:n.valueOrDefault(e.weight,null),string:""};return h.string=n.toFontString(h),h},isEmptyObj:function(t){for(var e in t)if(e)return!1;return!0}});t.defaults.outlabeledPie=t.defaults.doughnut;var l=t.controllers.doughnut.extend({update:function(e){var i=this,s=i.chart,h=s.chartArea,a=s.options,r=a.elements.arc,n=h.right-h.left-r.borderWidth,o=h.bottom-h.top-r.borderWidth,l=Math.min(n,o),d={x:0,y:0},c=i.getMeta(),f=a.cutoutPercentage,u=a.circumference;if(u<2*Math.PI){var x=a.rotation%(2*Math.PI);x+=2*Math.PI*(x>=Math.PI?-1:x<-Math.PI?1:0);var y=x+u,g={x:Math.cos(x),y:Math.sin(x)},b={x:Math.cos(y),y:Math.sin(y)},p=x<=0&&y>=0||x<=2*Math.PI&&2*Math.PI<=y,R=x<=.5*Math.PI&&.5*Math.PI<=y||x<=2.5*Math.PI&&2.5*Math.PI<=y,v=x<=-Math.PI&&-Math.PI<=y||x<=Math.PI&&Math.PI<=y,m=x<=.5*-Math.PI&&.5*-Math.PI<=y||x<=1.5*Math.PI&&1.5*Math.PI<=y,M=f/100,w={x:v?-1:Math.min(g.x*(g.x<0?1:M),b.x*(b.x<0?1:M)),y:m?-1:Math.min(g.y*(g.y<0?1:M),b.y*(b.y<0?1:M))},P={x:p?1:Math.max(g.x*(g.x>0?1:M),b.x*(b.x>0?1:M)),y:R?1:Math.max(g.y*(g.y>0?1:M),b.y*(b.y>0?1:M))},O={width:.5*(P.x-w.x),height:.5*(P.y-w.y)};l=Math.min(n/O.width,o/O.height),d={x:(P.x+w.x)*-.5,y:(P.y+w.y)*-.5}}s.borderWidth=i.getMaxBorderWidth(c.data),s.outerRadius=Math.max((l-s.borderWidth)/2,0),s.innerRadius=Math.max(f?s.outerRadius/100*f:0,0),s.radiusLength=(s.outerRadius-s.innerRadius)/s.getVisibleDatasetCount(),s.offsetX=d.x*s.outerRadius,s.offsetY=d.y*s.outerRadius,c.total=i.calculateTotal(),i.outerRadius=s.outerRadius-s.radiusLength*i.getRingIndex(i.index),i.innerRadius=Math.max(i.outerRadius-s.radiusLength,0),i.outerRadius*=.5,i.innerRadius*=.5,t.helpers.each(c.data,function(t,s){i.updateElement(t,s,e)})}});t.controllers.outlabeledPie=l,t.defaults.global.plugins.outlabels=i;var d=i.LABEL_KEY;t.plugins.register({id:"outlabels",resize:function(t,e,i){i.font.resizable&&(i.font.size=e.height/100*2.5,i.font.changed=!0)},afterInit:function(t,e){var i=t.canvas.style;e.font.resizable&&(e.font.size=i.height.slice(0,-2)/100*2.5)},afterDatasetUpdate:function(t,i,s){var h,a,n,l,c=t.config.data.labels,f=t.data.datasets[i.index],u=e(f,s),x=u&&u.display,y=i.meta.data||[],g=t.ctx;g.save();for(var b=0;b<y.length;++b)h=y[b],a=h[d],n=f.data[b]/i.meta.total,l=x&&h&&!h.hidden?new r.OutLabel(h,b,g,u,{chart:t,dataIndex:b,dataset:f,labels:c,datasetIndex:i.index,percent:n}):null,l=o.isEmptyObj(l)?null:l,a&&l&&!s.font.changed&&a.label===l.label&&a.encodedText===l.encodedText&&(l.offset=a.offset),h[d]=l;g.restore(),s.font.changed&&(s.font.changed=!1)},afterDatasetDraw:function(t,e){for(var i,s,h,a=e.meta.data||[],r=t.ctx,n=0;n<2*a.length;++n)h=n<a.length?n:n-a.length,i=a[h],s=i[d],s&&(n<a.length?(s.update(i._view,a,n),s.drawLine(r)):s.draw(r))}})}); |
@@ -193,3 +193,3 @@ /*! | ||
var value = context.dataset.data[index]; | ||
var label = context.dataset.labels[index]; | ||
var label = context.labels[index]; | ||
var text = helpers.valueOrDefault(config.text, '%v %p'); | ||
@@ -630,2 +630,3 @@ text = text.replace(/%l/gi, label); | ||
afterDatasetUpdate: function(chart, args, options) { | ||
var labels = chart.config.data.labels; | ||
var dataset = chart.data.datasets[args.index]; | ||
@@ -654,2 +655,3 @@ var config = configure(dataset, options); | ||
dataset: dataset, | ||
labels: labels, | ||
datasetIndex: args.index, | ||
@@ -656,0 +658,0 @@ percent: percent |
@@ -5,3 +5,3 @@ { | ||
"description": "Chart.js plugin to display float data labels on pie/doughnut chart outside the border.", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "dist/chartjs-plugin-piechart-outlabels.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30596
604
0