27 lines
25 KiB
JavaScript
27 lines
25 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["dashboardActivityConversion~dashboardActivityOrder~dashboardActivityRevenue~dashboardActivityVisit"],{"060a":function(t,e,a){"use strict";a("8e94")},"0812":function(t,e,a){"use strict";var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[t.loading?a("BarChartSkeleton",{key:"chart-skeleton"}):t.loading||t.hasDatas?a("LineChart",{key:"chart",attrs:{labels:t.labels,datasets:t.computedDatasets,color:t.color,"hover-color":t.hoverColor,"is-gradient":t.isGradient,title:t.title,"choice-tab":t.choiceTab,granularity:t.granularity,"short-cut-date":t.shortCutDate,"is-numeric":t.isNumeric,width:740}}):a("NoData",{key:"chart-no-data"})],1)},o=[],i=(a("d81d"),a("99af"),a("c1df")),r=(a("a9e3"),a("b680"),a("b0c0"),a("1fca")),l=a("c583"),s=a("30ef"),d=a.n(s),c=a("a9be"),u=a.n(c);
|
|
/**
|
|
* 2007-2020 PrestaShop and Contributors
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* https://opensource.org/licenses/AFL-3.0
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
*
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
* @copyright 2007-2020 PrestaShop SA and Contributors
|
|
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
*/
|
|
d.a.plugins.unregister(u.a);var h="#FFFFFF",f={aspectRatio:4/3,tooltips:!1,layout:{padding:{bottom:25,right:50,left:25,top:50}},elements:{line:{fill:!1}},hover:{mode:"index",intersect:!1},legend:{display:!0,position:"bottom",align:"start",onClick:function(){}},plugins:{}},b=function(t){var e,a,n,o,i,r,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2?arguments[2]:void 0,d=arguments.length>3?arguments[3]:void 0,c=Math.round(100*s)/100,u=Number(c);return r=null!==(e=d.chart)&&void 0!==e&&null!==(a=e.chart)&&void 0!==a&&null!==(n=a.config)&&void 0!==n&&null!==(o=n.data)&&void 0!==o&&null!==(i=o.labels)&&void 0!==i&&i.lengh?"".concat(d.chart.chart.config.data.labels[d.dataIndex]):"".concat(t[d.dataIndex]),l&&(u="".concat(this.$i18n.n(Number(c).toFixed(2),"currency"))),d.active?"".concat(r,"\n").concat(u):""},p={name:"line-chart",extends:r["c"],props:["labels","datasets","data","color","extraOptions","title","isNumeric"],mounted:function(){this.addPlugin(u.a),this.render()},methods:{updateState:function(t,e){this[e]=t,this.render()},render:function(){var t,e,a,n,o,i,r="#f96332";Object(l["c"])(this.color)&&(this.color=Object(l["d"])(this.color));var s=this.color||r,d=document.getElementById(this.chartId).getContext("2d"),c=d.createLinearGradient(500,0,100,0);c.addColorStop(0,s),c.addColorStop(1,h);var u=d.createLinearGradient(0,170,0,50);u.addColorStop(0,"rgba(128, 182, 244, 0)"),u.addColorStop(1,Object(l["b"])(s,.4));var p=Object.assign(f,this.extraOptions||{});p.plugins.datalabels={backgroundColor:function(t){return t.active?t.dataset.backgroundColor:"white"},borderColor:function(t){return t.dataset.borderColor},borderRadius:function(t){return t.active?0:32},borderWidth:1,color:function(t){return t.active?"white":t.dataset.backgroundColor},font:{weight:"bold"},offset:8,textAlign:"center"};var v=JSON.parse(JSON.stringify(this.datasets));v&&null!==(t=v[0])&&void 0!==t&&null!==(e=t.datalabels)&&void 0!==e&&null!==(a=e.labels)&&void 0!==a&&a.name&&(v[0].datalabels.labels.name.formatter=b.bind(this,this.labels[0],this.isNumeric),v[0].datalabels.labels.name.display=function(t){return t.active}),v&&null!==(n=v[1])&&void 0!==n&&null!==(o=n.datalabels)&&void 0!==o&&null!==(i=o.labels)&&void 0!==i&&i.name&&(v[1].datalabels.labels.name.formatter=b.bind(this,this.labels[1],this.isNumeric),v[1].datalabels.labels.name.display=function(t){return t.active}),this.renderChart({labels:this.labels[0]||[],datasets:v||[{label:this.title||"",borderColor:s,pointBorderColor:"#FFF",pointBackgroundColor:s,pointBorderWidth:2,pointHoverRadius:4,pointHoverBorderWidth:1,pointRadius:4,fill:!0,backgroundColor:u,borderWidth:2,data:this.data||[]}]},p)}},watch:{labels:function(t){this.updateState(t,"labels")},data:function(t){this.updateState(t,"data")},isGradient:function(t){this.updateState(t,"isGradient")},color:function(t){this.updateState(t,"color")},title:function(t){this.updateState(t,"title")},datasets:function(t){this.updateState(t,"datasets")}}},v=a("19a3"),y=a("110c"),g={components:{LineChart:p,BarChartSkeleton:v["a"],NoData:y["a"]},props:{granularity:{type:String,default:"day"},loading:{type:Boolean,default:!0},dataSets:{type:Object,required:!0},keyId:{type:String,default:"revenues"},shortCutDate:{type:String,default:"7days"},choiceTab:{type:String,default:"revenues"},isNumeric:{type:Boolean,default:!1}},methods:{updateData:function(t,e){this[e]=t}},data:function(){return{isGradient:!1,color:"#34219e",title:" ",hoverColor:"#FF0076"}},watch:{loading:function(t){this.updateData(t,"loading")},choiceTab:function(t){this.updateData(t,"choiceTab")}},computed:{labels:function(){var t,e=this;return t=this.dataSets.previous?[this.dataSets.actual[1],this.dataSets.previous[1]]:[this.dataSets.actual[1]],t=t.map((function(t){return"hours"===e.granularity?t.map((function(t){return i(t).format("hh A")})):"weeks"===e.granularity?t.map((function(t){return"".concat(e.$i18n.t("tabsBody.dates.week")," ").concat(t)})):"months"===e.granularity?t.map((function(t){return"".concat(e.$i18n.t("tabsBody.dates.month")," ").concat(t)})):t})),t},computedDatasets:function(){var t={label:"Active period",borderColor:"#34219E",backgroundColor:"#34219E",fill:!1,data:this.dataSets.actual[0],datalabels:{labels:{name:{font:{size:16}}},align:"top",anchor:"top",clamp:!0}},e={label:"Previous period",data:this.dataSets.previous[0],borderColor:"#D2CCF5",backgroundColor:"#D2CCF5",fill:!1,datalabels:{labels:{name:{font:{size:16}}},align:"bottom",anchor:"bottom",clamp:!0}};return this.$store.getters.getCompareMode?[t,e]:[t]},hasDatas:function(){var t=function(t){return t.data.every((function(t){return 0===t}))};return!(!this.computedDatasets[1]&&t(this.computedDatasets[0]))&&!(this.computedDatasets[1]&&t(this.computedDatasets[0])&&t(this.computedDatasets[1]))},hasDatasToCompare:function(t){var e=function(t){return t.data.every((function(t){return 0===t}))};return!t||!e(t)}}},x=g,m=a("2877"),_=Object(m["a"])(x,n,o,!1,null,"62b06693",null);e["a"]=_.exports},"3b95":function(t,e,a){var n=a("24fb");e=n(!1),e.push([t.i,'.bg-horizontal-bar{display:flex;flex-direction:column;align-items:center}.legend{position:relative;top:-200px;left:100%}.legend ul{list-style:none!important}.legend ul li:before{content:"\\2022"!important;color:var(--bubble-color)!important;font-weight:700;display:inline-block;width:1em;font-size:2em;margin-left:-1em;vertical-align:sub}.legend ul li span{margin-left:-10px;vertical-align:text-bottom}.legend ul li i{vertical-align:initial!important}',""]),t.exports=e},"896f":function(t,e,a){"use strict";var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"tw-text-base tw-font-bold tw-text-center tw-py-4"},[t._v(" "+t._s(t.title)+" ")]),t.loading?a("BarChartSkeleton"):!t.loading&&t.data.every((function(t){return 0===t}))?a("NoData"):a("PieChart",{staticStyle:{"margin-top":"2%"},attrs:{title:t.title,labels:t.labels,data:t.data,width:320,height:220,"choice-tab":t.choiceTab,"legend-callback":t.legendCallback,"label-callback":t.labelCallback,"use-inline-label":t.useInlineLabel},on:{generated:t.setLegend}}),t.loading||t.data.every((function(t){return 0===t}))?t._e():a("div",{staticClass:"legend",domProps:{innerHTML:t._s(t.message)}})],1)},o=[],i=(a("13d5"),a("a9e3"),a("99af"),a("a15b"),a("1276"),a("ac1f"),a("b680"),a("1fca")),r=a("c583"),l=a("a9be"),s=a.n(l),d={maintainAspectRatio:!1,legend:{display:!1,position:"right",align:"start",onClick:function(t){return t.stopPropagation()}},tooltips:{bodySpacing:4,xPadding:10,yPadding:10,caretPadding:10},responsive:!0,layout:{padding:{left:0,right:0,top:15,bottom:15}},plugins:{datalabels:{color:"white",display:function(t){var e=t.dataset.data.reduce((function(t,e){return t+Number(e)}),0),a=t.dataset.data[t.dataIndex]/e*100;return a>10},labels:{value:{anchor:"center",color:function(t){return t.dataset.backgroundColor},backgroundColor:"white",borderColor:"white",borderWidth:2,borderRadius:4,font:{weight:"bold"}}}}}},c={name:"pie-chart",extends:i["d"],props:["labels","datasets","data","extraOptions","title","hoverColor","choiceTab","labelCallback","legendCallback","useInlineLabel"],data:function(){return{color:[]}},mounted:function(){this.useInlineLabel&&this.addPlugin(s.a),this.render();var t=this.$data._chart.generateLegend();this.$emit("generated",t)},methods:{render:function(){var t=this;(!this.color||0===this.color.length||this.color.length<this.data.length)&&(this.color=[],this.color=Object(r["a"])(this.data.length));var e=Object.assign(d,this.extraOptions||{}),a=function(e,a){var n=e.index;return"conversion"===t.choiceTab.toLowerCase()?"".concat(t.$t("tabsBody.conversionRate.".concat(a.labels[n].toLowerCase().split(" ").join("_"))),": ").concat(t.$n(a.datasets[0].data[n],"currency")):" ".concat(a.labels[n]," : ").concat(a.datasets[0].data[n])},n=function(e){for(var a=[],n=0,o=0;o<e.data.labels.length;o++)n+=parseInt(e.data.datasets[0].data[o]);a.push("<ul>");for(var i=0;i<e.data.labels.length;i++)a.push('<li style="--bubble-color: '.concat(e.data.datasets[0].backgroundColor[i],';">')),e.data.labels[i]&&("sessions"===t.choiceTab.toLowerCase()?a.push('<span class="tooltip-tab">'.concat(e.data.labels[i]," ").concat(Number(e.data.datasets[0].data[i]/n*100).toFixed(2),' %\n <i class="material-icons info" style="font-size: small!important;">info_outlined</i>\n <span class="tooltip-text-tab">').concat(t.$t("tabsBody.visits.".concat(e.data.labels[i].toLowerCase().split(" ").join("_"))),"</span>\n </span>")):a.push('<span class="tooltip-tab">'.concat(t.$t("tabsBody.conversionRate.".concat(e.data.labels[i].toLowerCase().split(" ").join("_")))," ").concat(t.$n(e.data.datasets[0].data[i],"currency"),'\n <i class="material-icons info" style="font-size: small!important;">info_outlined</i>\n <span class="tooltip-text-tab">').concat(t.$t("tabsBody.conversionRate.".concat(e.data.labels[i].toLowerCase().split(" ").join("_"),"Tooltip")),"</span>\n </span>"))),a.push("</li>");return a.push("</ul>"),a.join("")};this.useInlineLabel,e.tooltips.callbacks={label:this.labelCallback||a},e.legendCallback=this.legendCallback||n;var o={labels:this.labels||[],datasets:this.datasets?this.datasets:[{label:this.title||"",backgroundColor:this.color,hoverBackgroundColor:this.color,borderWidth:1,data:this.data||[]}]};this.renderChart(o,e)},updateState:function(t,e){this[e]=t,this.render()}},watch:{labels:function(t){this.updateState(t,"labels")},data:function(t){this.updateState(t,"data")},title:function(t){this.updateState(t,"title")},hoverColor:function(t){this.updateState(t,"hoverColor")},choiceTab:function(t){this.updateState(t,"choiceTab")}}},u=a("19a3"),h=a("110c"),f={components:{PieChart:c,BarChartSkeleton:u["a"],NoData:h["a"]},props:{loading:{type:Boolean,default:!0},data:{type:Array,default:function(){return[]}},labels:{type:Array,default:function(){return[]}},title:{type:String,default:"Traffic per Channel"},choiceTab:{type:String,default:"visits"},legendCallback:{type:Function,default:null},labelCallback:{type:Function,default:null},useInlineLabel:{type:Boolean,default:!1}},data:function(){return{isGradient:!1,color:"#34219e",hoverColor:"#FF0076",message:""}},methods:{updateData:function(t,e){this[e]=t},setLegend:function(t){this.message=t}},watch:{data:function(t){this.updateData(t,"data")},labels:function(t){this.updateData(t,"labels")}}},b=f,p=(a("060a"),a("2877")),v=Object(p["a"])(b,n,o,!1,null,null,null);e["a"]=v.exports},"8e94":function(t,e,a){var n=a("3b95");n.__esModule&&(n=n.default),"string"===typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);var o=a("499e").default;o("0ad149bc",n,!0,{sourceMap:!1,shadowMode:!1})},a9be:function(t,e,a){
|
|
/*!
|
|
* chartjs-plugin-datalabels v0.7.0
|
|
* https://chartjs-plugin-datalabels.netlify.com
|
|
* (c) 2019 Chart.js Contributors
|
|
* Released under the MIT license
|
|
*/
|
|
(function(e,n){t.exports=n(a("30ef"))})(0,(function(t){"use strict";t=t&&t.hasOwnProperty("default")?t["default"]:t;var e=t.helpers,a=function(){if("undefined"!==typeof window){if(window.devicePixelRatio)return window.devicePixelRatio;var t=window.screen;if(t)return(t.deviceXDPI||1)/(t.logicalXDPI||1)}return 1}(),n={toTextLines:function(t){var a,n=[];t=[].concat(t);while(t.length)a=t.pop(),"string"===typeof a?n.unshift.apply(n,a.split("\n")):Array.isArray(a)?t.push.apply(t,a):e.isNullOrUndef(t)||n.unshift(""+a);return n},toFontString:function(t){return!t||e.isNullOrUndef(t.size)||e.isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family},textSize:function(t,e,a){var n,o=[].concat(e),i=o.length,r=t.font,l=0;for(t.font=a.string,n=0;n<i;++n)l=Math.max(t.measureText(o[n]).width,l);return t.font=r,{height:i*a.lineHeight,width:l}},parseFont:function(a){var o=t.defaults.global,i=e.valueOrDefault(a.size,o.defaultFontSize),r={family:e.valueOrDefault(a.family,o.defaultFontFamily),lineHeight:e.options.toLineHeight(a.lineHeight,i),size:i,style:e.valueOrDefault(a.style,o.defaultFontStyle),weight:e.valueOrDefault(a.weight,null),string:""};return r.string=n.toFontString(r),r},bound:function(t,e,a){return Math.max(t,Math.min(e,a))},arrayDiff:function(t,e){var a,n,o,i,r=t.slice(),l=[];for(a=0,o=e.length;a<o;++a)i=e[a],n=r.indexOf(i),-1===n?l.push([i,1]):r.splice(n,1);for(a=0,o=r.length;a<o;++a)l.push([r[a],-1]);return l},rasterize:function(t){return Math.round(t*a)/a}};function o(t,e){var a=e.x,n=e.y;if(null===a)return{x:0,y:-1};if(null===n)return{x:1,y:0};var o=t.x-a,i=t.y-n,r=Math.sqrt(o*o+i*i);return{x:r?o/r:0,y:r?i/r:-1}}function i(t,e,a,n,o){switch(o){case"center":a=n=0;break;case"bottom":a=0,n=1;break;case"right":a=1,n=0;break;case"left":a=-1,n=0;break;case"top":a=0,n=-1;break;case"start":a=-a,n=-n;break;case"end":break;default:o*=Math.PI/180,a=Math.cos(o),n=Math.sin(o);break}return{x:t,y:e,vx:a,vy:n}}var r=0,l=1,s=2,d=4,c=8;function u(t,e,a){var n=r;return t<a.left?n|=l:t>a.right&&(n|=s),e<a.top?n|=c:e>a.bottom&&(n|=d),n}function h(t,e){var a,n,o,i=t.x0,r=t.y0,h=t.x1,f=t.y1,b=u(i,r,e),p=u(h,f,e);while(1){if(!(b|p)||b&p)break;a=b||p,a&c?(n=i+(h-i)*(e.top-r)/(f-r),o=e.top):a&d?(n=i+(h-i)*(e.bottom-r)/(f-r),o=e.bottom):a&s?(o=r+(f-r)*(e.right-i)/(h-i),n=e.right):a&l&&(o=r+(f-r)*(e.left-i)/(h-i),n=e.left),a===b?(i=n,r=o,b=u(i,r,e)):(h=n,f=o,p=u(h,f,e))}return{x0:i,x1:h,y0:r,y1:f}}function f(t,e){var a,n,o=e.anchor,r=t;return e.clamp&&(r=h(r,e.area)),"start"===o?(a=r.x0,n=r.y0):"end"===o?(a=r.x1,n=r.y1):(a=(r.x0+r.x1)/2,n=(r.y0+r.y1)/2),i(a,n,t.vx,t.vy,e.align)}var b={arc:function(t,e){var a=(t.startAngle+t.endAngle)/2,n=Math.cos(a),o=Math.sin(a),i=t.innerRadius,r=t.outerRadius;return f({x0:t.x+n*i,y0:t.y+o*i,x1:t.x+n*r,y1:t.y+o*r,vx:n,vy:o},e)},point:function(t,e){var a=o(t,e.origin),n=a.x*t.radius,i=a.y*t.radius;return f({x0:t.x-n,y0:t.y-i,x1:t.x+n,y1:t.y+i,vx:a.x,vy:a.y},e)},rect:function(t,e){var a=o(t,e.origin),n=t.x,i=t.y,r=0,l=0;return t.horizontal?(n=Math.min(t.x,t.base),r=Math.abs(t.base-t.x)):(i=Math.min(t.y,t.base),l=Math.abs(t.base-t.y)),f({x0:n,y0:i+l,x1:n+r,y1:i,vx:a.x,vy:a.y},e)},fallback:function(t,e){var a=o(t,e.origin);return f({x0:t.x,y0:t.y,x1:t.x,y1:t.y,vx:a.x,vy:a.y},e)}},p=t.helpers,v=n.rasterize;function y(t){var e=t.borderWidth||0,a=t.padding,n=t.size.height,o=t.size.width,i=-o/2,r=-n/2;return{frame:{x:i-a.left-e,y:r-a.top-e,w:o+a.width+2*e,h:n+a.height+2*e},text:{x:i,y:r,w:o,h:n}}}function g(t){var e=t._model.horizontal,a=t._scale||e&&t._xScale||t._yScale;if(!a)return null;if(void 0!==a.xCenter&&void 0!==a.yCenter)return{x:a.xCenter,y:a.yCenter};var n=a.getBasePixel();return e?{x:n,y:null}:{x:null,y:n}}function x(e){return e instanceof t.elements.Arc?b.arc:e instanceof t.elements.Point?b.point:e instanceof t.elements.Rectangle?b.rect:b.fallback}function m(t,e,a){var n=a.backgroundColor,o=a.borderColor,i=a.borderWidth;(n||o&&i)&&(t.beginPath(),p.canvas.roundedRect(t,v(e.x)+i/2,v(e.y)+i/2,v(e.w)-i,v(e.h)-i,a.borderRadius),t.closePath(),n&&(t.fillStyle=n,t.fill()),o&&i&&(t.strokeStyle=o,t.lineWidth=i,t.lineJoin="miter",t.stroke()))}function _(t,e,a){var n=a.lineHeight,o=t.w,i=t.x,r=t.y+n/2;return"center"===e?i+=o/2:"end"!==e&&"right"!==e||(i+=o),{h:n,w:o,x:i,y:r}}function w(t,e,a){var n=t.shadowBlur,o=a.stroked,i=v(a.x),r=v(a.y),l=v(a.w);o&&t.strokeText(e,i,r,l),a.filled&&(n&&o&&(t.shadowBlur=0),t.fillText(e,i,r,l),n&&o&&(t.shadowBlur=n))}function C(t,e,a,n){var o,i=n.textAlign,r=n.color,l=!!r,s=n.font,d=e.length,c=n.textStrokeColor,u=n.textStrokeWidth,h=c&&u;if(d&&(l||h))for(a=_(a,i,s),t.font=s.string,t.textAlign=i,t.textBaseline="middle",t.shadowBlur=n.textShadowBlur,t.shadowColor=n.textShadowColor,l&&(t.fillStyle=r),h&&(t.lineJoin="round",t.lineWidth=u,t.strokeStyle=c),o=0,d=e.length;o<d;++o)w(t,e[o],{stroked:h,filled:l,w:a.w,x:a.x,y:a.y+a.h*o})}var k=function(t,e,a,n){var o=this;o._config=t,o._index=n,o._model=null,o._rects=null,o._ctx=e,o._el=a};p.extend(k.prototype,{_modelize:function(e,a,o,i){var r=this,l=r._index,s=p.options.resolve,d=n.parseFont(s([o.font,{}],i,l)),c=s([o.color,t.defaults.global.defaultFontColor],i,l);return{align:s([o.align,"center"],i,l),anchor:s([o.anchor,"center"],i,l),area:i.chart.chartArea,backgroundColor:s([o.backgroundColor,null],i,l),borderColor:s([o.borderColor,null],i,l),borderRadius:s([o.borderRadius,0],i,l),borderWidth:s([o.borderWidth,0],i,l),clamp:s([o.clamp,!1],i,l),clip:s([o.clip,!1],i,l),color:c,display:e,font:d,lines:a,offset:s([o.offset,0],i,l),opacity:s([o.opacity,1],i,l),origin:g(r._el),padding:p.options.toPadding(s([o.padding,0],i,l)),positioner:x(r._el),rotation:s([o.rotation,0],i,l)*(Math.PI/180),size:n.textSize(r._ctx,a,d),textAlign:s([o.textAlign,"start"],i,l),textShadowBlur:s([o.textShadowBlur,0],i,l),textShadowColor:s([o.textShadowColor,c],i,l),textStrokeColor:s([o.textStrokeColor,c],i,l),textStrokeWidth:s([o.textStrokeWidth,0],i,l)}},update:function(t){var e,a,o,i=this,r=null,l=null,s=i._index,d=i._config,c=p.options.resolve([d.display,!0],t,s);c&&(e=t.dataset.data[s],a=p.valueOrDefault(p.callback(d.formatter,[e,t]),e),o=p.isNullOrUndef(a)?[]:n.toTextLines(a),o.length&&(r=i._modelize(c,o,d,t),l=y(r))),i._model=r,i._rects=l},geometry:function(){return this._rects?this._rects.frame:{}},rotation:function(){return this._model?this._model.rotation:0},visible:function(){return this._model&&this._model.opacity},model:function(){return this._model},draw:function(t,e){var a,o=this,i=t.ctx,r=o._model,l=o._rects;this.visible()&&(i.save(),r.clip&&(a=r.area,i.beginPath(),i.rect(a.left,a.top,a.right-a.left,a.bottom-a.top),i.clip()),i.globalAlpha=n.bound(0,r.opacity,1),i.translate(v(e.x),v(e.y)),i.rotate(r.rotation),m(i,l.frame,r),C(i,r.lines,l.text,r),i.restore())}});var S=t.helpers,M=Number.MIN_SAFE_INTEGER||-9007199254740991,D=Number.MAX_SAFE_INTEGER||9007199254740991;function O(t,e,a){var n=Math.cos(a),o=Math.sin(a),i=e.x,r=e.y;return{x:i+n*(t.x-i)-o*(t.y-r),y:r+o*(t.x-i)+n*(t.y-r)}}function $(t,e){var a,n,o,i,r,l=D,s=M,d=e.origin;for(a=0;a<t.length;++a)n=t[a],o=n.x-d.x,i=n.y-d.y,r=e.vx*o+e.vy*i,l=Math.min(l,r),s=Math.max(s,r);return{min:l,max:s}}function B(t,e){var a=e.x-t.x,n=e.y-t.y,o=Math.sqrt(a*a+n*n);return{vx:(e.x-t.x)/o,vy:(e.y-t.y)/o,origin:t,ln:o}}var F=function(){this._rotation=0,this._rect={x:0,y:0,w:0,h:0}};function N(t,e,a){var n=e.positioner(t,e),o=n.vx,i=n.vy;if(!o&&!i)return{x:n.x,y:n.y};var r=a.w,l=a.h,s=e.rotation,d=Math.abs(r/2*Math.cos(s))+Math.abs(l/2*Math.sin(s)),c=Math.abs(r/2*Math.sin(s))+Math.abs(l/2*Math.cos(s)),u=1/Math.max(Math.abs(o),Math.abs(i));return d*=o*u,c*=i*u,d+=e.offset*o,c+=e.offset*i,{x:n.x+d,y:n.y+c}}function A(t,e){var a,n,o,i;for(a=t.length-1;a>=0;--a)for(o=t[a].$layout,n=a-1;n>=0&&o._visible;--n)i=t[n].$layout,i._visible&&o._box.intersects(i._box)&&e(o,i);return t}function z(t){var e,a,n,o,i,r;for(e=0,a=t.length;e<a;++e)n=t[e],o=n.$layout,o._visible&&(i=n.geometry(),r=N(n._el._model,n.model(),i),o._box.update(r,i,n.rotation()));return A(t,(function(t,e){var a=t._hidable,n=e._hidable;a&&n||n?e._visible=!1:a&&(t._visible=!1)}))}S.extend(F.prototype,{center:function(){var t=this._rect;return{x:t.x+t.w/2,y:t.y+t.h/2}},update:function(t,e,a){this._rotation=a,this._rect={x:e.x+t.x,y:e.y+t.y,w:e.w,h:e.h}},contains:function(t){var e=this,a=1,n=e._rect;return t=O(t,e.center(),-e._rotation),!(t.x<n.x-a||t.y<n.y-a||t.x>n.x+n.w+2*a||t.y>n.y+n.h+2*a)},intersects:function(t){var e,a,n,o=this._points(),i=t._points(),r=[B(o[0],o[1]),B(o[0],o[3])];for(this._rotation!==t._rotation&&r.push(B(i[0],i[1]),B(i[0],i[3])),e=0;e<r.length;++e)if(a=$(o,r[e]),n=$(i,r[e]),a.max<n.min||n.max<a.min)return!1;return!0},_points:function(){var t=this,e=t._rect,a=t._rotation,n=t.center();return[O({x:e.x,y:e.y},n,a),O({x:e.x+e.w,y:e.y},n,a),O({x:e.x+e.w,y:e.y+e.h},n,a),O({x:e.x,y:e.y+e.h},n,a)]}});var P={prepare:function(t){var e,a,n,o,i,r=[];for(e=0,n=t.length;e<n;++e)for(a=0,o=t[e].length;a<o;++a)i=t[e][a],r.push(i),i.$layout={_box:new F,_hidable:!1,_visible:!0,_set:e,_idx:a};return r.sort((function(t,e){var a=t.$layout,n=e.$layout;return a._idx===n._idx?n._set-a._set:n._idx-a._idx})),this.update(r),r},update:function(t){var e,a,n,o,i,r=!1;for(e=0,a=t.length;e<a;++e)n=t[e],o=n.model(),i=n.$layout,i._hidable=o&&"auto"===o.display,i._visible=n.visible(),r|=i._hidable;r&&z(t)},lookup:function(t,e){var a,n;for(a=t.length-1;a>=0;--a)if(n=t[a].$layout,n&&n._visible&&n._box.contains(e))return t[a];return null},draw:function(t,e){var a,n,o,i,r,l;for(a=0,n=e.length;a<n;++a)o=e[a],i=o.$layout,i._visible&&(r=o.geometry(),l=N(o._el._view,o.model(),r),i._box.update(l,r,o.rotation()),o.draw(t,l))}},I=t.helpers,L=function(t){if(I.isNullOrUndef(t))return null;var e,a,n,o=t;if(I.isObject(t))if(I.isNullOrUndef(t.label))if(I.isNullOrUndef(t.r))for(o="",e=Object.keys(t),n=0,a=e.length;n<a;++n)o+=(0!==n?", ":"")+e[n]+": "+t[e[n]];else o=t.r;else o=t.label;return""+o},R={align:"center",anchor:"center",backgroundColor:null,borderColor:null,borderRadius:0,borderWidth:0,clamp:!1,clip:!1,color:void 0,display:!0,font:{family:void 0,lineHeight:1.2,size:void 0,style:void 0,weight:null},formatter:L,labels:void 0,listeners:{},offset:4,opacity:1,padding:{top:4,right:4,bottom:4,left:4},rotation:0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,textShadowBlur:0,textShadowColor:void 0},T=t.helpers,j="$datalabels",W="$default";function E(t,e){var a,n,o=t.datalabels,i={},r=[];return!1===o?null:(!0===o&&(o={}),e=T.merge({},[e,o]),a=e.labels||{},n=Object.keys(a),delete e.labels,n.length?n.forEach((function(t){a[t]&&r.push(T.merge({},[e,a[t],{_key:t}]))})):r.push(e),i=r.reduce((function(t,e){return T.each(e.listeners||{},(function(a,n){t[n]=t[n]||{},t[n][e._key||W]=a})),delete e.listeners,t}),{}),{labels:r,listeners:i})}function U(t,e,a){if(e){var n,o=a.$context,i=a.$groups;e[i._set]&&(n=e[i._set][i._key],n&&!0===T.callback(n,[o])&&(t[j]._dirty=!0,a.update(o)))}}function G(t,e,a,n){var o,i;(a||n)&&(a?n?a!==n&&(i=o=!0):i=!0:o=!0,i&&U(t,e.leave,a),o&&U(t,e.enter,n))}function H(t,e){var a,n,o=t[j],i=o._listeners;if(i.enter||i.leave){if("mousemove"===e.type)n=P.lookup(o._labels,e);else if("mouseout"!==e.type)return;a=o._hovered,o._hovered=n,G(t,i,a,n)}}function J(t,e){var a=t[j],n=a._listeners.click,o=n&&P.lookup(a._labels,e);o&&U(t,n,o)}function q(e){if(!e.animating){for(var a=t.animationService.animations,n=0,o=a.length;n<o;++n)if(a[n].chart===e)return;e.render({duration:1,lazy:!0})}}t.defaults.global.plugins.datalabels=R;var X={id:"datalabels",beforeInit:function(t){t[j]={_actives:[]}},beforeUpdate:function(t){var e=t[j];e._listened=!1,e._listeners={},e._datasets=[],e._labels=[]},afterDatasetUpdate:function(t,e,a){var n,o,i,r,l,s,d,c,u=e.index,h=t[j],f=h._datasets[u]=[],b=t.isDatasetVisible(u),p=t.data.datasets[u],v=E(p,a),y=e.meta.data||[],g=t.ctx;for(g.save(),n=0,i=y.length;n<i;++n)if(d=y[n],d[j]=[],b&&d&&!d.hidden&&!d._model.skip)for(o=0,r=v.labels.length;o<r;++o)l=v.labels[o],s=l._key,c=new k(l,g,d,n),c.$groups={_set:u,_key:s||W},c.$context={active:!1,chart:t,dataIndex:n,dataset:p,datasetIndex:u},c.update(c.$context),d[j].push(c),f.push(c);g.restore(),T.merge(h._listeners,v.listeners,{merger:function(t,a,n){a[t]=a[t]||{},a[t][e.index]=n[t],h._listened=!0}})},afterUpdate:function(t,e){t[j]._labels=P.prepare(t[j]._datasets,e)},afterDatasetsDraw:function(t){P.draw(t,t[j]._labels)},beforeEvent:function(t,e){if(t[j]._listened)switch(e.type){case"mousemove":case"mouseout":H(t,e);break;case"click":J(t,e);break;default:}},afterEvent:function(t){var e,a,o,i,r,l,s,d=t[j],c=d._actives,u=d._actives=t.lastActive||[],h=n.arrayDiff(c,u);for(e=0,a=h.length;e<a;++e)if(r=h[e],r[1])for(s=r[0][j]||[],o=0,i=s.length;o<i;++o)l=s[o],l.$context.active=1===r[1],l.update(l.$context);(d._dirty||h.length)&&(P.update(d._labels),q(t)),delete d._dirty}};return t.plugins.register(X),X}))}}]); |