!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict"; /** * [chartjs-plugin-labels]{@link https://github.com/DavideViolante/chartjs-plugin-labels} * * @version 5.0.1-beta * @author Chen, Yi-Cyuan [emn178@gmail.com], Davide Violante, Yousef Altaher * @copyright Chen, Yi-Cyuan 2017-2018 * @license MIT */!function(){if("undefined"==typeof Chart)return void console.error("Cannot find Chart object.");const t=Chart.helpers;"function"!=typeof Object.assign&&(Object.assign=function(t){if(!t)throw new TypeError("Cannot convert undefined or null to object");const e=Object(t);for(let t=1;ts&&(s=a.width),r.push(a.width);for(let t=0;t100&&(n-=this.totalPercentage-100,n=parseFloat(n.toFixed(this.options.precision))),"bar"===this.chart.config.type&&(this.barTotalPercentage[o]=this.totalPercentage)),this.percentage=n,n},o.prototype.getRenderInfo=function(t,e){return"bar"===this.chart.config.type?this.getBarRenderInfo(t,e):this.options.arc?this.getArcRenderInfo(t,e):this.getBaseRenderInfo(t,e)},o.prototype.getBaseRenderInfo=function(t,e){if("outside"===this.options.position||"border"===this.options.position){let o,n={};const i=t,s=i.startAngle+(i.endAngle-i.startAngle)/2,r=i.outerRadius/2;if("border"===this.options.position?o=(i.outerRadius-r)/2+r:"outside"===this.options.position&&(o=i.outerRadius-r+r+this.options.textMargin),n={x:i.x+Math.cos(s)*o,y:i.y+Math.sin(s)*o},"outside"===this.options.position){const t=this.options.textMargin+this.measureLabel(e).width/2;n.x+=n.x=r.left&&e<=r.right&&o>=r.top&&o<=r.bottom)return!1}a=[[r.left,r.top],[r.left,r.bottom],[r.right,r.top],[r.right,r.bottom]];for(let i=0;i=t&&s<=e&&r>=o&&r<=n)return!1}}return i.push({left:t,right:e,top:o,bottom:n}),!0},o.prototype.measureLabel=function(t){if("object"==typeof t)return{width:t.width,height:t.height};{let e=0;const o=t.split("\n");for(let t=0;te&&(e=n.width)}return{width:e,height:this.options.fontSize*o.length}}},o.prototype.loadImage=function(t){const e=new Image;return e.src=t.src,e.width=t.width,e.height=t.height,e},Chart.register({id:"labels",beforeDatasetsUpdate:function(t,i,s){if(!e[t.config.type]||!n(s))return;s.length||(s=[s]);const r=s.length;t._labels&&r===t._labels.length||(t._labels=s.map((function(){return new o})));let a=!1,h=0;for(let e=0;eh&&(h=t)}}a&&(t.chartArea.top+=h,t.chartArea.bottom-=h)},afterDatasetUpdate:function(t,o,i){e[t.config.type]&&n(i)&&t._labels?.forEach((function(t){t.args[o.index]=o}))},beforeDraw:function(t,o,i){e[t.config.type]&&n(i)&&t._labels?.forEach((function(t){t.barTotalPercentage={}}))},afterDatasetsDraw:function(t,o,i){e[t.config.type]&&n(i)&&t._labels?.forEach((function(t){t.render()}))}})}()}));