Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

2 wiersze
52 KiB

  1. "use strict";function __$styleInject(t,e){if("undefined"==typeof document)return e;t=t||"";var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");return a.type="text/css",i.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t)),e}function $$1(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function offset(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function isElementInViewport(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function getElementContentWidth(t){var e=window.getComputedStyle(t),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-i}function floatTwo(t){return parseFloat(t.toFixed(2))}function fillArray(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(i=a?t[0]:t[t.length-1]);var n=new Array(Math.abs(e)).fill(i);return t=a?n.concat(t):t.concat(n)}function getStringWidth(t,e){return(t+"").length*e}function getXLineProps(t,e){var i=t+6,a=void 0,n=void 0,s="";return"span"===e?(i=-7,a=t+15,n=t+25):"tick"===e&&(i=t,a=6,n=9,s="x-axis-label"),[i,a,n,s]}function getYLineProps(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2])return[t,t+5,"specific-value",0];var i=void 0,a="",n=0;return"span"===e?(i=t+6,n=-6):"tick"===e&&(i=-6,a="y-axis-label"),[i,-9,a,n]}function getBarHeightAndYAttr(t,e,i){var a=void 0,n=void 0;return t<=e?(n=t,0===(a=e-t)&&(n-=a=i*MIN_BAR_PERCENT_HEIGHT)):(n=e,0===(a=t-e)&&(a=i*MIN_BAR_PERCENT_HEIGHT)),[a,n]}function equilizeNoOfElements(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length-t.length;return i>0?t=fillArray(t,i):e=fillArray(e,i),[t,e]}function $$2(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function createSVG(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);for(var a in e){var n=e[a];if("inside"===a)$$2(n).appendChild(i);else if("around"===a){var s=$$2(n);s.parentNode.insertBefore(i,s),i.appendChild(s)}else"styles"===a?"object"===(void 0===n?"undefined":_typeof(n))&&Object.keys(n).map(function(t){i.style[t]=n[t]}):("className"===a&&(a="class"),"innerHTML"===a?i.textContent=n:i.setAttribute(a,n))}return i}function renderVerticalGradient(t,e){return createSVG("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function setGradientStop(t,e,i,a){return createSVG("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":a})}function makeSVGContainer(t,e,i,a){return createSVG("svg",{className:e,inside:t,width:i,height:a})}function makeSVGDefs(t){return createSVG("defs",{inside:t})}function makeSVGGroup(t,e){return createSVG("g",{className:e,inside:t,transform:arguments.length>2&&void 0!==arguments[2]?arguments[2]:""})}function makePath(t){return createSVG("path",{className:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",d:t,styles:{stroke:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"none",fill:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none"}})}function makeGradient(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a="path-fill-gradient-"+e,n=renderVerticalGradient(t,a),s=[1,.6,.2];return i&&(s=[.4,.2,0]),setGradientStop(n,"0%",e,s[0]),setGradientStop(n,"50%",e,s[1]),setGradientStop(n,"100%",e,s[2]),a}function makeHeatSquare(t,e,i,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"none",s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r={className:t,x:e,y:i,width:a,height:a,fill:n};return Object.keys(s).map(function(t){r[t]=s[t]}),createSVG("rect",r)}function makeText(t,e,i,a){return createSVG("text",{className:t,x:e,y:i,dy:".32em",innerHTML:a})}function makeXLine(t,e,i,a,n,s,r){var o=createSVG("line",{x1:0,x2:0,y1:e,y2:i}),l=createSVG("text",{className:s,x:0,y:a,dy:".71em",innerHTML:n}),h=createSVG("g",{className:"tick "+X_AXIS_LINE_CLASS,transform:"translate("+t+", 0)"});return h.appendChild(o),h.appendChild(l),h}function makeYLine(t,e,i,a,n,s,r){var o=arguments.length>7&&void 0!==arguments[7]&&arguments[7],l=createSVG("line",{className:"dashed"===(arguments.length>8&&void 0!==arguments[8]?arguments[8]:"")?"dashed":"",x1:t,x2:e,y1:0,y2:0}),h=createSVG("text",{className:n,x:i,y:0,dy:".32em",innerHTML:a+""}),c=createSVG("g",{className:"tick "+s,transform:"translate(0, "+r+")","stroke-opacity":1});return o&&(l.style.stroke="rgba(27, 31, 35, 0.6)"),c.appendChild(l),c.appendChild(h),c}function animateSVGElement(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"linear",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){var h=void 0;h="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var c=s[l]||t.getAttribute(l),u=e[l],p={attributeName:l,from:c,to:u,begin:"0s",dur:i/1e3+"s",values:c+";"+u,keySplines:EASING[a],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};n&&(p.type=n);for(var d in p)h.setAttribute(d,p[d]);r.appendChild(h),n?o.setAttribute(l,"translate("+u+")"):o.setAttribute(l,u)}return[r,o]}function transform(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function animateSVG(t,e){var i=[],a=[];e.map(function(t){var e=t[0],n=e.unit.parentNode,s=void 0,r=void 0;t[0]=e.unit;var o=animateSVGElement.apply(void 0,toConsumableArray(t)),l=slicedToArray(o,2);s=l[0],r=l[1],i.push(r),a.push([s,n]),n.replaceChild(s,e.unit),e.array?e.array[e.index]=r:e.object[e.key]=r});var n=t.cloneNode(!0);return a.map(function(t,a){t[1].replaceChild(i[a],t[0]),e[a][0]=i[a]}),n}function runSMILAnimation(t,e,i){if(0!==i.length){var a=animateSVG(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(a)),setTimeout(function(){a.parentNode==t&&(t.removeChild(a),t.appendChild(e))},REPLACE_ALL_NEW_DUR)}}function normalize(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var i=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,i)),i]}function getRangeIntervals(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),a=Math.floor(e),n=i-a,s=n,r=1;n>5&&(n%2!=0&&(n=++i-a),s=n/2,r=2),n<=2&&(r=n/(s=4)),0===n&&(s=5,r=1);for(var o=[],l=0;l<=s;l++)o.push(a+r*l);return o}function getIntervals(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=normalize(t),a=slicedToArray(i,2),n=a[0],s=a[1],r=e?e/Math.pow(10,s):0,o=getRangeIntervals(n=n.toFixed(6),r);return o=o.map(function(t){return t*Math.pow(10,s)})}function calcIntervals(t){function e(t,e){for(var i=getIntervals(t),a=i[1]-i[0],n=0,s=1;n<e;s++)n+=a,i.unshift(-1*n);return i}var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=Math.max.apply(Math,toConsumableArray(t)),n=Math.min.apply(Math,toConsumableArray(t)),s=[];if(a>=0&&n>=0)normalize(a)[1],s=i?getIntervals(a,n):getIntervals(a);else if(a>0&&n<0){var r=Math.abs(n);a>=r?(normalize(a)[1],s=e(a,r)):(normalize(r)[1],s=e(r,a).map(function(t){return-1*t}))}else if(a<=0&&n<=0){var o=Math.abs(n),l=Math.abs(a);normalize(o)[1],s=(s=i?getIntervals(o,l):getIntervals(o)).reverse().map(function(t){return-1*t})}return s}function calcDistribution(t,e){for(var i=Math.max.apply(Math,toConsumableArray(t)),a=1/(e-1),n=[],s=0;s<e;s++){var r=i*(a*s);n.push(r)}return n}function getMaxCheckpoint(t,e){return e.filter(function(e){return e<t}).length}function limitColor(t){return t>255?255:t<0?0:t}function lightenDarkenColor(t,e){var i=getColor(t),a=!1;"#"==i[0]&&(i=i.slice(1),a=!0);var n=parseInt(i,16),s=limitColor((n>>16)+e),r=limitColor((n>>8&255)+e),o=limitColor((255&n)+e);return(a?"#":"")+(o|r<<8|s<<16).toString(16)}function isValidColor(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}function treatAsUtc(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function getDdMmYyyy(t){var e=t.getDate(),i=t.getMonth()+1;return[(e>9?"":"0")+e,(i>9?"":"0")+i,t.getFullYear()].join("-")}function getWeeksBetween(t,e){return Math.ceil(getDaysBetween(t,e)/7)}function getDaysBetween(t,e){return(treatAsUtc(e)-treatAsUtc(t))/864e5}function addDays(t,e){t.setDate(t.getDate()+e)}function getChartByType(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1];return chartTypes[t]?new chartTypes[t](e):new LineChart(e)}__$styleInject('.chart-container{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .graph-focus-margin{margin:0 5%}.chart-container>.title{margin-top:25px;margin-left:25px;text-align:left;font-weight:400;font-size:12px;color:#6c7680}.chart-container .graphics{margin-top:10px;padding-top:10px;padding-bottom:10px;position:relative}.chart-container .graph-stats-group{-ms-flex-pack:distribute;-webkit-box-flex:1;-ms-flex:1;flex:1}.chart-container .graph-stats-container,.chart-container .graph-stats-group{display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:space-around}.chart-container .graph-stats-container{-ms-flex-pack:distribute;padding-top:10px}.chart-container .graph-stats-container .stats{padding-bottom:15px}.chart-container .graph-stats-container .stats-title{color:#8d99a6}.chart-container .graph-stats-container .stats-value{font-size:20px;font-weight:300}.chart-container .graph-stats-container .stats-description{font-size:12px;color:#8d99a6}.chart-container .graph-stats-container .graph-data .stats-value{color:#98d85b}.chart-container .axis,.chart-container .chart-label{font-size:11px;fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .percentage-graph .progress{margin-bottom:0}.chart-container .data-points circle{stroke:#fff;stroke-width:2}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .tick.x-axis-label{display:block}.chart-container .tick .specific-value{text-anchor:start}.chart-container .tick .y-value-text{text-anchor:end}.chart-container .tick .x-value-text{text-anchor:middle}.chart-container .progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.chart-container .progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#36414c;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;transition:width .6s ease}.chart-container .graph-svg-tip{position:absolute;z-index:1;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.chart-container .graph-svg-tip ol,.chart-container .graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.chart-container .graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.chart-container .graph-svg-tip strong{color:#dfe2e5;font-weight:600}.chart-container .graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.chart-container .graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.chart-container .graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.chart-container .graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.chart-container .graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}.chart-container .indicator,.chart-container .indicator-right{background:none;font-size:12px;vertical-align:middle;font-weight:700;color:#6c7680}.chart-container .indicator i{content:"";display:inline-block;height:8px;width:8px;border-radius:8px}.chart-container .indicator:before,.chart-container .indicator i{margin:0 4px 0 0}.chart-container .indicator-right:after{margin:0 0 0 4px}',void 0);var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},asyncGenerator=function(){function t(t){this.value=t}function e(e){function i(t,e){return new Promise(function(i,n){var o={key:t,arg:e,resolve:i,reject:n,next:null};r?r=r.next=o:(s=r=o,a(t,e))})}function a(i,s){try{var r=e[i](s),o=r.value;o instanceof t?Promise.resolve(o.value).then(function(t){a("next",t)},function(t){a("throw",t)}):n(r.done?"return":"normal",r.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":s.resolve({value:e,done:!0});break;case"throw":s.reject(e);break;default:s.resolve({value:e,done:!1})}(s=s.next)?a(s.key,s.arg):r=null}var s,r;this._invoke=i,"function"!=typeof e.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new e(t.apply(this,arguments))}},await:function(e){return new t(e)}}}(),classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}return function(e,i,a){return i&&t(e.prototype,i),a&&t(e,a),e}}(),get=function t(e,i,a){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,i);if(void 0===n){var s=Object.getPrototypeOf(e);return null===s?void 0:t(s,i,a)}if("value"in n)return n.value;var r=n.get;if(void 0!==r)return r.call(a)},inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},possibleConstructorReturn=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},slicedToArray=function(){function t(t,e){var i=[],a=!0,n=!1,s=void 0;try{for(var r,o=t[Symbol.iterator]();!(a=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){n=!0,s=t}finally{try{!a&&o.return&&o.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),toConsumableArray=function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)};$$1.create=function(t,e){var i=document.createElement(t);for(var a in e){var n=e[a];if("inside"===a)$$1(n).appendChild(i);else if("around"===a){var s=$$1(n);s.parentNode.insertBefore(i,s),i.appendChild(s)}else"styles"===a?"object"===(void 0===n?"undefined":_typeof(n))&&Object.keys(n).map(function(t){i.style[t]=n[t]}):a in i?i[a]=n:i.setAttribute(a,n)}return i},$$1.bind=function(t,e){if(t)for(var i in e){var a=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,a)})}},$$1.unbind=function(t,e){if(t)for(var i in e){var a=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,a)})}},$$1.fire=function(t,e,i){var a=document.createEvent("HTMLEvents");a.initEvent(e,!0,!0);for(var n in i)a[n]=i[n];return t.dispatchEvent(a)};var MIN_BAR_PERCENT_HEIGHT=.01,X_AXIS_LINE_CLASS="x-value-text",UnitRenderer=function(){var t=function(t,e,i){this.totalHeight=t,this.zeroLine=e,this.avgUnitWidth=i};return t.prototype={bar:function(t,e,i,a,n,s,r){var o=this.avgUnitWidth-i.spaceWidth,l=o/r,h=t-o/2+l*s,c=getBarHeightAndYAttr(e,this.zeroLine,this.totalHeight),u=slicedToArray(c,2),p=u[0];return createSVG("rect",{className:"bar mini",style:"fill: "+a,"data-point-index":n,x:h,y:u[1],width:l,height:p})},dot:function(t,e,i,a,n){return createSVG("circle",{style:"fill: "+a,"data-point-index":n,cx:t,cy:e,r:i.radius})}},t}(),UNIT_ANIM_DUR=350,PATH_ANIM_DUR=650,MARKER_LINE_ANIM_DUR=UNIT_ANIM_DUR,REPLACE_ALL_NEW_DUR=250,STD_EASING="easein",Animator=function(){var t=function(t,e,i,a){this.totalHeight=t,this.totalWidth=e,this.avgUnitWidth=a,this.zeroLine=i};return t.prototype={bar:function(t,e,i,a,n){var s=e-this.avgUnitWidth/4,r=this.avgUnitWidth/2/n,o=getBarHeightAndYAttr(i,this.zeroLine,this.totalHeight),l=slicedToArray(o,2);return e=s+r*a,[t,{width:r,height:l[0],x:e,y:l[1]},UNIT_ANIM_DUR,STD_EASING]},dot:function(t,e,i){return[t,{cx:e,cy:i},UNIT_ANIM_DUR,STD_EASING]},path:function(t,e){var i=[],a=[{unit:t.path,object:t,key:"path"},{d:"M"+e},PATH_ANIM_DUR,STD_EASING];if(i.push(a),t.regionPath){var n="0,"+this.zeroLine+"L",s="L"+this.totalWidth+", "+this.zeroLine,r=[{unit:t.regionPath,object:t,key:"regionPath"},{d:"M"+n+e+s},PATH_ANIM_DUR,STD_EASING];i.push(r)}return i},translate:function(t,e,i,a){return[{unit:t,array:[0],index:0},{transform:i.join(", ")},a,STD_EASING,"translate",{transform:e.join(", ")}]},verticalLine:function(t,e,i){return this.translate(t,[i,0],[e,0],MARKER_LINE_ANIM_DUR)},horizontalLine:function(t,e,i){return this.translate(t,[0,i],[0,e],MARKER_LINE_ANIM_DUR)}},t}(),EASING={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"},SvgTip=function(){function t(e){var i=e.parent,a=void 0===i?null:i,n=e.colors,s=void 0===n?[]:n;classCallCheck(this,t),this.parent=a,this.colors=s,this.title_name="",this.title_value="",this.list_values=[],this.title_value_first=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}return createClass(t,[{key:"setup",value:function(){this.make_tooltip()}},{key:"refresh",value:function(){this.fill(),this.calc_position()}},{key:"make_tooltip",value:function(){var t=this;this.container=$$1.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'<span class="title"></span>\n\t\t\t\t<ul class="data-point-list"></ul>\n\t\t\t\t<div class="svg-pointer"></div>'}),this.hide_tip(),this.title=this.container.querySelector(".title"),this.data_point_list=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",function(){t.hide_tip()})}},{key:"fill",value:function(){var t=this,e=void 0;e=this.title_value_first?"<strong>"+this.title_value+"</strong>"+this.title_name:this.title_name+"<strong>"+this.title_value+"</strong>",this.title.innerHTML=e,this.data_point_list.innerHTML="",this.list_values.map(function(e,i){var a=t.colors[i]||"black",n=$$1.create("li",{styles:{"border-top":"3px solid "+a},innerHTML:'<strong style="display: block;">'+(0===e.value||e.value?e.value:"")+"</strong>\n\t\t\t\t\t"+(e.title?e.title:"")});t.data_point_list.appendChild(n)})}},{key:"calc_position",value:function(){var t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight,this.left=this.x-t/2;var e=this.parent.offsetWidth-t,i=this.container.querySelector(".svg-pointer");if(this.left<0)i.style.left="calc(50% - "+-1*this.left+"px)",this.left=0;else if(this.left>e){var a="calc(50% + "+(this.left-e)+"px)";i.style.left=a,this.left=e}else i.style.left="50%"}},{key:"set_values",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.title_name=i,this.title_value=a,this.list_values=n,this.x=t,this.y=e,this.title_value_first=s,this.refresh()}},{key:"hide_tip",value:function(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}},{key:"show_tip",value:function(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}]),t}(),PRESET_COLOR_MAP={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"},DEFAULT_COLORS=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta"],getColor=function(t){return PRESET_COLOR_MAP[t]||t},ALL_CHART_TYPES=["line","scatter","bar","percentage","heatmap","pie"],COMPATIBLE_CHARTS={bar:["line","scatter","percentage","pie"],line:["scatter","bar","percentage","pie"],pie:["line","scatter","percentage","bar"],scatter:["line","bar","percentage","pie"],percentage:["bar","line","scatter","pie"],heatmap:[]},COLOR_COMPATIBLE_CHARTS={bar:["line","scatter"],line:["scatter","bar"],pie:["percentage"],scatter:["line","bar"],percentage:["pie"],heatmap:[]},BaseChart=function(){function t(e){e.height;var i=e.title,a=void 0===i?"":i,n=e.subtitle,s=void 0===n?"":n,r=(e.colors,e.is_navigable),o=void 0===r?0:r,l=(e.type,e.parent),h=e.data;classCallCheck(this,t),this.raw_chart_args=arguments[0],this.parent="string"==typeof l?document.querySelector(l):l,this.title=a,this.subtitle=s,this.data=h,this.is_navigable=o,this.is_navigable&&(this.current_index=0),this.setupConfiguration(arguments[0])}return createClass(t,[{key:"setupConfiguration",value:function(t){this.setColors(t.colors,t.type),this.set_margins(t.height),this.config={showTooltip:1,showLegend:1,isNavigable:0}}},{key:"setColors",value:function(t,e){this.colors=t;var i="percentage"===e||"pie"===e?this.data.labels:this.data.datasets;(!this.colors||i&&this.colors.length<i.length)&&(this.colors=DEFAULT_COLORS),this.colors=this.colors.map(function(t){return getColor(t)})}},{key:"set_margins",value:function(t){this.baseHeight=t,this.height=t-40,this.translate_x=60,this.translate_y=10}},{key:"validate",value:function(){return this.parent?!!this.validateAndPrepareData():(console.error("No parent element to render on was provided."),!1)}},{key:"validateAndPrepareData",value:function(){return!0}},{key:"setup",value:function(){this.validate()&&this._setup()}},{key:"_setup",value:function(){this.bindWindowEvents(),this.setupConstants(),this.makeContainer(),this.makeTooltip(),this.draw(!0)}},{key:"draw",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.setWidth(),this.setupEmptyValues(),this.setupComponents(),this.makeChartArea(),this.makeLayers(),this.renderComponents(),this.renderLegend(),this.setupNavigation(t),t&&this.update(this.data)}},{key:"update",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.oldData=Object.assign({},this.data),this.data=this.prepareNewData(t),this.calculateValues(),this.updateComponents(e)}},{key:"prepareNewData",value:function(t){return t}},{key:"bindWindowEvents",value:function(){var t=this;window.addEventListener("resize",function(){return t.draw()}),window.addEventListener("orientationchange",function(){return t.draw()})}},{key:"setWidth",value:function(){var t=0;this.specific_values.map(function(e){var i=getStringWidth(e.title+"",8);i>t&&(t=i-40)}),this.base_width=getElementContentWidth(this.parent)-t,this.width=this.base_width-2*this.translate_x}},{key:"setupConstants",value:function(){}},{key:"setupEmptyValues",value:function(){}},{key:"setupComponents",value:function(){this.components=[]}},{key:"makeContainer",value:function(){this.container=$$1.create("div",{className:"chart-container",innerHTML:'<h6 class="title">'+this.title+'</h6>\n\t\t\t\t<h6 class="sub-title uppercase">'+this.subtitle+'</h6>\n\t\t\t\t<div class="frappe-chart graphics"></div>\n\t\t\t\t<div class="graph-stats-container"></div>'}),this.parent.innerHTML="",this.parent.appendChild(this.container),this.chart_wrapper=this.container.querySelector(".frappe-chart"),this.stats_wrapper=this.container.querySelector(".graph-stats-container")}},{key:"makeChartArea",value:function(){this.svg=makeSVGContainer(this.chart_wrapper,"chart",this.baseWidth,this.baseHeight),this.svg_defs=makeSVGDefs(this.svg),this.drawArea=makeSVGGroup(this.svg,this.type+"-chart","translate("+this.translate_x+", "+this.translate_y+")")}},{key:"makeLayers",value:function(){var t=this;this.components.forEach(function(e){e.layer=t.makeLayer(e.layerClass)})}},{key:"calculateValues",value:function(){}},{key:"renderComponents",value:function(){this.components.forEach(function(t){t.store=t.make.apply(t,toConsumableArray(t.makeArgs)),t.layer.textContent="",t.store.forEach(function(e){t.layer.appendChild(e)})})}},{key:"updateComponents",value:function(){}},{key:"makeTooltip",value:function(){this.tip=new SvgTip({parent:this.chart_wrapper,colors:this.colors}),this.bind_tooltip()}},{key:"show_summary",value:function(){}},{key:"show_custom_summary",value:function(){var t=this;this.summary.map(function(e){var i=$$1.create("div",{className:"stats",innerHTML:'<span class="indicator">\n\t\t\t\t\t<i style="background:'+e.color+'"></i>\n\t\t\t\t\t'+e.title+": "+e.value+"\n\t\t\t\t</span>"});t.stats_wrapper.appendChild(i)})}},{key:"renderLegend",value:function(){}},{key:"setupNavigation",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.is_navigable||(this.make_overlay(),e&&(this.bind_overlay(),document.addEventListener("keydown",function(e){isElementInViewport(t.chart_wrapper)&&("37"==(e=e||window.event).keyCode?t.on_left_arrow():"39"==e.keyCode?t.on_right_arrow():"38"==e.keyCode?t.on_up_arrow():"40"==e.keyCode?t.on_down_arrow():"13"==e.keyCode&&t.on_enter_key())})))}},{key:"make_overlay",value:function(){}},{key:"bind_overlay",value:function(){}},{key:"bind_units",value:function(){}},{key:"on_left_arrow",value:function(){}},{key:"on_right_arrow",value:function(){}},{key:"on_up_arrow",value:function(){}},{key:"on_down_arrow",value:function(){}},{key:"on_enter_key",value:function(){}},{key:"getDataPoint",value:function(){}},{key:"updateCurrentDataPoint",value:function(){}},{key:"makeLayer",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return makeSVGGroup(this.drawArea,t,e)}},{key:"get_different_chart",value:function(t){if(t!==this.type){ALL_CHART_TYPES.includes(t)||console.error("'"+t+"' is not a valid chart type."),COMPATIBLE_CHARTS[this.type].includes(t)||console.error("'"+this.type+"' chart cannot be converted to a '"+t+"' chart.");var e=COLOR_COMPATIBLE_CHARTS[this.type].includes(t);return new Chart({parent:this.raw_chart_args.parent,title:this.title,data:this.raw_chart_args.data,type:t,height:this.raw_chart_args.height,colors:e?this.colors:void 0})}}}]),t}(),AxisChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.is_series=t.is_series,i.format_tooltip_y=t.format_tooltip_y,i.format_tooltip_x=t.format_tooltip_x,i.zero_line=i.height,i}return inherits(e,t),createClass(e,[{key:"validateAndPrepareData",value:function(){return this.xAxisLabels=this.data.labels||[],this.y=this.data.datasets||[],this.y.forEach(function(t,e){t.index=e},this),!0}},{key:"setupEmptyValues",value:function(){this.yAxisPositions=[this.height,this.height/2,0],this.yAxisLabels=["0","5","10"],this.xPositions=[0,this.width/2,this.width],this.xAxisLabels=["0","5","10"]}},{key:"setupComponents",value:function(){var t=this;this.yAxis={layerClass:"y axis",layer:void 0,make:t.makeYLines,makeArgs:[t.yAxisPositions,t.yAxisLabels,t.width,t.y_axis_mode],store:[],animate:t.animateYLines},this.xAxis={layerClass:"x axis",layer:void 0,make:t.makeXLines,makeArgs:[t.xPositions,t.xAxisLabels,t.height,t.x_axis_mode,200,t.is_series],store:[],animate:t.animateXLines},this.yMarkerLines={},this.xMarkerLines={},this.dataUnits={layerClass:"y marker axis",layer:void 0,indexed:1},this.components=[this.yAxis,this.xAxis]}},{key:"setup_values",value:function(){this.data.datasets.map(function(t){t.values=t.values.map(function(t){return isNaN(t)?0:t})}),this.setup_x(),this.setup_y()}},{key:"setup_x",value:function(){var t=this;this.set_avg_unit_width_and_x_offset(),this.xPositions&&(this.x_old_axis_positions=this.xPositions.slice()),this.xPositions=this.xAxisLabels.map(function(e,i){return floatTwo(t.x_offset+i*t.avg_unit_width)}),this.x_old_axis_positions||(this.x_old_axis_positions=this.xPositions.slice())}},{key:"setup_y",value:function(){var t=this;this.yAxisLabels&&(this.y_old_axis_values=this.yAxisLabels.slice());var e=this.get_all_y_values();this.y_sums&&this.y_sums.length>0&&(e=e.concat(this.y_sums)),this.yAxisLabels=calcIntervals(e,"line"===this.type),this.y_old_axis_values||(this.y_old_axis_values=this.yAxisLabels.slice());var i=this.yAxisLabels,a=i[i.length-1]-i[0];this.multiplier&&(this.old_multiplier=this.multiplier),this.multiplier=this.height/a,this.old_multiplier||(this.old_multiplier=this.multiplier);var n=i[1]-i[0],s=n*this.multiplier,r=void 0;r=i.indexOf(0)>=0?i.indexOf(0):i[0]>0?-1*i[0]/n:-1*i[i.length-1]/n+(i.length-1),this.zero_line&&(this.old_zero_line=this.zero_line),this.zero_line=this.height-r*s,this.old_zero_line||(this.old_zero_line=this.zero_line),this.yAxisPositions&&(this.oldYAxisPositions=this.yAxisPositions),this.yAxisPositions=this.yAxisLabels.map(function(e){return t.zero_line-e*t.multiplier}),this.oldYAxisPositions||(this.oldYAxisPositions=this.yAxisPositions)}},{key:"makeXLines",value:function(t,e,i,a,n,s){var r=getXLineProps(i,a),o=slicedToArray(r,4),l=o[0],h=o[1],c=o[2],u=o[3],p=1.5*n,d=p/8;return e.map(function(e,i){var a=getStringWidth(e,8)+2;if(a>p)if(s){for(var n=1;a/n*2>p;)n++;if(i%n!=0)return}else e=e.slice(0,d-3)+" ...";return makeXLine(t[i],l,h,c,e,"x-value-text",u)})}},{key:"makeYLines",value:function(t,e,i,a){var n=getYLineProps(i,a),s=slicedToArray(n,4),r=s[0],o=s[1],l=s[2],h=s[3];return e.map(function(e,i){return makeYLine(h,r,o,e,"y-value-text",l,t[i],0===e&&0!==i)})}},{key:"draw_graph",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.raw_chart_args.hasOwnProperty("init")&&!this.raw_chart_args.init?void this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,t.xPositions,e.yUnitPositions,t.colors[i]),t.makeUnits(e),t.calcYDependencies()}):e?void this.draw_new_graph_and_animate():void this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,t.xPositions,e.yUnitPositions,t.colors[i]),t.makeUnits(e)})}},{key:"draw_new_graph_and_animate",value:function(){var t=this,e=[];this.y.map(function(i,a){i.yUnitPositions=new Array(i.values.length).fill(t.zero_line),e.push({values:i.values}),i.svg_units=[],t.make_path&&t.make_path(i,t.xPositions,i.yUnitPositions,t.colors[a]),t.makeUnits(i)}),setTimeout(function(){t.updateData(e)},350)}},{key:"setupNavigation",value:function(t){var i=this;t?setTimeout(function(){get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setupNavigation",i).call(i,t)},500):get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setupNavigation",this).call(this,t)}},{key:"makeUnits",value:function(t){this.makeDatasetUnits(this.xPositions,t.yUnitPositions,this.colors[t.index],t.index,this.y.length)}},{key:"makeDatasetUnits",value:function(t,e,i,a,n,s,r,o){s||(s=this.svg_units_groups[a]),r||(r=this.y[a].svg_units),o||(o=this.unit_args),s.textContent="",r.length=0;var l=new UnitRenderer(this.height,this.zero_line,this.avg_unit_width);e.map(function(e,h){var c=l[o.type](t[h],e,o.args,i,h,a,n);s.appendChild(c),r.push(c)}),this.is_navigable&&this.bind_units(r)}},{key:"bind_tooltip",value:function(){var t=this;this.chart_wrapper.addEventListener("mousemove",function(e){var i=offset(t.chart_wrapper),a=e.pageX-i.left-t.translate_x;e.pageY-i.top-t.translate_y<t.height+2*t.translate_y?t.mapTooltipXPosition(a):t.tip.hide_tip()})}},{key:"mapTooltipXPosition",value:function(t){var e=this;if(this.y_min_tops){var i=this.xAxisLabels;this.format_tooltip_x&&this.format_tooltip_x(this.xAxisLabels[0])&&(i=this.xAxisLabels.map(function(t){return e.format_tooltip_x(t)}));for(var a=this.format_tooltip_y&&this.format_tooltip_y(this.y[0].values[0]),n=this.xPositions.length-1;n>=0;n--){var s=this.xPositions[n];if(t>s-this.avg_unit_width/2){var r=s+this.translate_x,o=this.y_min_tops[n]+this.translate_y,l=i[n],h=this.y.map(function(t,i){return{title:t.title,value:a?e.format_tooltip_y(t.values[n]):t.values[n],color:e.colors[i]}});this.tip.set_values(r,o,l,"",h),this.tip.show_tip();break}}}}},{key:"updateData",value:function(t,e){e||(e=this.xAxisLabels),this.updating=!0,this.old_x_values=this.xAxisLabels.slice(),this.old_y_axis_tops=this.y.map(function(t){return t.yUnitPositions.slice()}),this.old_y_values=this.y.map(function(t){return t.values}),t&&this.y.map(function(e){e.values=t[e.index].values}),e&&(this.xAxisLabels=e),this.setup_x(),this.setup_y(),this.calcYDependencies(),this.animator=new Animator(this.height,this.width,this.zero_line,this.avg_unit_width),this.animate_graphs(),this.updating=!1}},{key:"animate_graphs",value:function(){var t=this;this.elements_to_animate=[];var e=equilizeNoOfElements(this.x_old_axis_positions.slice(),this.xPositions.slice()),i=slicedToArray(e,2),a=i[0],n=i[1],s=equilizeNoOfElements(this.oldYAxisPositions.slice(),this.yAxisPositions.slice()),r=slicedToArray(s,2),o=r[0],l=r[1],h=this.xAxisLabels.slice(),c=this.yAxisLabels.slice(),u=this.xPositions.slice().length-this.x_old_axis_positions.slice().length;u>0&&this.makeXLines(a,h),this.makeYLines(o,c),0!==u&&this.animateXLines(a,n),this.animateYLines(o,l),this.y.map(function(e){var i=equilizeNoOfElements(t.old_y_axis_tops[e.index].slice(),e.yUnitPositions.slice()),s=slicedToArray(i,2),r=s[0],o=s[1];u>0&&(t.make_path&&t.make_path(e,a,r,t.colors[e.index]),t.makeDatasetUnits(a,r,t.colors[e.index],e.index,t.y.length)),e.path&&t.animate_path(e,n,o),t.animate_units(e,n,o)}),runSMILAnimation(this.chart_wrapper,this.svg,this.elements_to_animate),setTimeout(function(){t.y.map(function(e){t.make_path&&t.make_path(e,t.xPositions,e.yUnitPositions,t.colors[e.index]),t.makeUnits(e),t.makeYLines(t.yAxisPositions,t.yAxisLabels),t.makeXLines(t.xPositions,t.xAxisLabels)})},400)}},{key:"animate_path",value:function(t,e,i){var a=i.map(function(t,i){return e[i]+","+t});this.elements_to_animate=this.elements_to_animate.concat(this.animator.path(t,a.join("L")))}},{key:"animate_units",value:function(t,e,i){var a=this,n=this.unit_args.type;t.svg_units.map(function(s,r){void 0!==e[r]&&void 0!==i[r]&&a.elements_to_animate.push(a.animator[n]({unit:s,array:t.svg_units,index:r},e[r],i[r],t.index,a.y.length))})}},{key:"animateXLines",value:function(t,e){var i=this;this.xAxisLines.map(function(a,n){i.elements_to_animate.push(i.animator.verticalLine(a,e[n],t[n]))})}},{key:"animateYLines",value:function(t,e){var i=this;this.yAxisLines.map(function(a,n){i.elements_to_animate.push(i.animator.horizontalLine(a,e[n],t[n]))})}},{key:"animateYAnnotations",value:function(){}},{key:"add_data_point",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.xAxisLabels.length,a=this.y.map(function(t){return{values:t.values}});a.map(function(e,a){e.values.splice(i,0,t[a])});var n=this.xAxisLabels.slice();n.splice(i,0,e),this.updateData(a,n)}},{key:"remove_data_point",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.xAxisLabels.length-1;if(!(this.xAxisLabels.length<3)){var e=this.y.map(function(t){return{values:t.values}});e.map(function(e){e.values.splice(t,1)});var i=this.xAxisLabels.slice();i.splice(t,1),this.updateData(e,i)}}},{key:"getDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.current_index,e={index:t},i=this.y[0];return["svg_units","yUnitPositions","values"].map(function(a){var n=a.slice(0,a.length-1);e[n]=i[a][t]}),e.label=this.xAxisLabels[t],e}},{key:"updateCurrentDataPoint",value:function(t){(t=parseInt(t))<0&&(t=0),t>=this.xAxisLabels.length&&(t=this.xAxisLabels.length-1),t!==this.current_index&&(this.current_index=t,$.fire(this.parent,"data-select",this.getDataPoint()))}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.xAxisLabels.length-1),this.x_offset=0}},{key:"get_all_y_values",value:function(){var t=[];return this.y.map(function(e){t=t.concat(e.values)}),t.concat(this.specific_values.map(function(t){return t.value}))}},{key:"calcYDependencies",value:function(){var t=this;this.y_min_tops=new Array(this.xAxisLabels.length).fill(9999),this.y.map(function(e){e.yUnitPositions=e.values.map(function(e){return floatTwo(t.zero_line-e*t.multiplier)}),e.yUnitPositions.map(function(e,i){e<t.y_min_tops[i]&&(t.y_min_tops[i]=e)})})}}]),e}(BaseChart),BarChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.type="bar",i.x_axis_mode=t.x_axis_mode||"tick",i.y_axis_mode=t.y_axis_mode||"span",i.setup(),i}return inherits(e,t),createClass(e,[{key:"setup_values",value:function(){get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setup_values",this).call(this),this.x_offset=this.avg_unit_width,this.unit_args={type:"bar",args:{spaceWidth:this.avg_unit_width/2}}}},{key:"bind_units",value:function(t){var e=this;t.map(function(t){t.addEventListener("click",function(){var i=t.getAttribute("data-point-index");e.updateCurrentDataPoint(i)})})}},{key:"update_overlay",value:function(t){var e=this,i=[];Object.keys(t.attributes).map(function(e){i.push(t.attributes[e])}),i.filter(function(t){return t.specified}).map(function(t){e.overlay.setAttribute(t.name,t.nodeValue)}),this.overlay.style.fill="#000000",this.overlay.style.opacity="0.4"}},{key:"on_left_arrow",value:function(){this.updateCurrentDataPoint(this.current_index-1)}},{key:"on_right_arrow",value:function(){this.updateCurrentDataPoint(this.current_index+1)}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.xAxisLabels.length+1),this.x_offset=this.avg_unit_width}}]),e}(AxisChart),LineChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.x_axis_mode=t.x_axis_mode||"span",i.y_axis_mode=t.y_axis_mode||"span",t.hasOwnProperty("show_dots")?i.show_dots=t.show_dots:i.show_dots=1,i.region_fill=t.region_fill,Object.getPrototypeOf(i)!==e.prototype?possibleConstructorReturn(i):(i.dot_radius=t.dot_radius||4,i.heatline=t.heatline,i.type="line",i.setup(),i)}return inherits(e,t),createClass(e,[{key:"setupPreUnitLayers",value:function(){var t=this;this.paths_groups=[],this.y.map(function(e,i){t.paths_groups[i]=makeSVGGroup(t.drawArea,"path-group path-group-"+i)})}},{key:"setup_values",value:function(){get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setup_values",this).call(this),this.unit_args={type:"dot",args:{radius:this.dot_radius}}}},{key:"makeDatasetUnits",value:function(t,i,a,n,s,r,o,l){this.show_dots&&get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"makeDatasetUnits",this).call(this,t,i,a,n,s,r,o,l)}},{key:"make_paths",value:function(){var t=this;this.y.map(function(e){t.make_path(e,t.xPositions,e.yUnitPositions,e.color||t.colors[e.index])})}},{key:"make_path",value:function(t,e,i,a){var n=i.map(function(t,i){return e[i]+","+t}).join("L");if(this.paths_groups[t.index].textContent="",t.path=makePath("M"+n,"line-graph-path",a),this.paths_groups[t.index].appendChild(t.path),this.heatline){var s=makeGradient(this.svg_defs,a);t.path.style.stroke="url(#"+s+")"}this.region_fill&&this.fill_region_for_dataset(t,a,n)}},{key:"fill_region_for_dataset",value:function(t,e,i){var a=makeGradient(this.svg_defs,e,!0),n="M0,"+this.zero_line+"L"+i+"L"+this.width+","+this.zero_line;t.regionPath=makePath(n,"region-fill","none","url(#"+a+")"),this.paths_groups[t.index].appendChild(t.regionPath)}}]),e}(AxisChart),ScatterChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.type="scatter",t.dot_radius?i.dot_radius=t.dot_radius:i.dot_radius=8,i.setup(),i}return inherits(e,t),createClass(e,[{key:"setup_values",value:function(){get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setup_values",this).call(this),this.unit_args={type:"dot",args:{radius:this.dot_radius}}}},{key:"make_paths",value:function(){}},{key:"make_path",value:function(){}}]),e}(LineChart),PercentageChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.type="percentage",i.max_slices=10,i.max_legend_points=6,i.setup(),i}return inherits(e,t),createClass(e,[{key:"makeChartArea",value:function(){this.chart_wrapper.className+=" graph-focus-margin",this.chart_wrapper.style.marginTop="45px",this.stats_wrapper.className+=" graph-focus-margin",this.stats_wrapper.style.marginBottom="30px",this.stats_wrapper.style.paddingTop="0px",this.chartDiv=$$1.create("div",{className:"div",inside:this.chart_wrapper}),this.chart=$$1.create("div",{className:"progress-chart",inside:this.chartDiv})}},{key:"setupLayers",value:function(){this.percentageBar=$$1.create("div",{className:"progress",inside:this.chart})}},{key:"setup_values",value:function(){var t=this;this.slice_totals=[];var e=this.data.labels.map(function(e,i){var a=0;return t.data.datasets.map(function(t){a+=t.values[i]}),[a,e]}).filter(function(t){return t[0]>0}),i=e;if(e.length>this.max_slices){e.sort(function(t,e){return e[0]-t[0]}),i=e.slice(0,this.max_slices-1);var a=0;e.slice(this.max_slices-1).map(function(t){a+=t[0]}),i.push([a,"Rest"]),this.colors[this.max_slices-1]="grey"}this.labels=[],i.map(function(e){t.slice_totals.push(e[0]),t.labels.push(e[1])}),this.legend_totals=this.slice_totals.slice(0,this.max_legend_points)}},{key:"renderComponents",value:function(){var t=this;this.grand_total=this.slice_totals.reduce(function(t,e){return t+e},0),this.slices=[],this.slice_totals.map(function(e,i){var a=$$1.create("div",{className:"progress-bar",inside:t.percentageBar,styles:{background:t.colors[i],width:100*e/t.grand_total+"%"}});t.slices.push(a)})}},{key:"bind_tooltip",value:function(){var t=this;this.slices.map(function(e,i){e.addEventListener("mouseenter",function(){var a=offset(t.chart_wrapper),n=offset(e),s=n.left-a.left+e.offsetWidth/2,r=n.top-a.top-6,o=(t.formatted_labels&&t.formatted_labels.length>0?t.formatted_labels[i]:t.labels[i])+": ",l=(100*t.slice_totals[i]/t.grand_total).toFixed(1);t.tip.set_values(s,r,o,l+"%"),t.tip.show_tip()})})}},{key:"renderLegend",value:function(){var t=this,e=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(i,a){i&&($$1.create("div",{className:"stats",inside:t.stats_wrapper}).innerHTML='<span class="indicator">\n\t\t\t\t\t<i style="background: '+t.colors[a]+'"></i>\n\t\t\t\t\t<span class="text-muted">'+e[a]+":</span>\n\t\t\t\t\t"+i+"\n\t\t\t\t</span>")})}}]),e}(BaseChart),ANGLE_RATIO=Math.PI/180,FULL_ANGLE=360,PieChart=function(t){function e(t){classCallCheck(this,e);var i=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.type="pie",i.elements_to_animate=null,i.hoverRadio=t.hoverRadio||.1,i.max_slices=10,i.max_legend_points=6,i.isAnimate=!1,i.startAngle=t.startAngle||0,i.clockWise=t.clockWise||!1,i.mouseMove=i.mouseMove.bind(i),i.mouseLeave=i.mouseLeave.bind(i),i.setup(),i}return inherits(e,t),createClass(e,[{key:"setup_values",value:function(){var t=this;this.centerX=this.width/2,this.centerY=this.height/2,this.radius=this.height>this.width?this.centerX:this.centerY,this.slice_totals=[];var e=this.data.labels.map(function(e,i){var a=0;return t.data.datasets.map(function(t){a+=t.values[i]}),[a,e]}).filter(function(t){return t[0]>0}),i=e;if(e.length>this.max_slices){e.sort(function(t,e){return e[0]-t[0]}),i=e.slice(0,this.max_slices-1);var a=0;e.slice(this.max_slices-1).map(function(t){a+=t[0]}),i.push([a,"Rest"]),this.colors[this.max_slices-1]="grey"}this.labels=[],i.map(function(e){t.slice_totals.push(e[0]),t.labels.push(e[1])}),this.legend_totals=this.slice_totals.slice(0,this.max_legend_points)}},{key:"makeArcPath",value:function(t,e){var i=this.centerX,a=this.centerY,n=this.radius,s=this.clockWise;return"M"+i+" "+a+" L"+(i+t.x)+" "+(a+t.y)+" A "+n+" "+n+" 0 0 "+(s?1:0)+" "+(i+e.x)+" "+(a+e.y)+" z"}},{key:"renderComponents",value:function(t){var i=this,a=this.radius,n=this.clockWise;this.grand_total=this.slice_totals.reduce(function(t,e){return t+e},0);var s=this.slicesProperties||[];this.slices=[],this.elements_to_animate=[],this.slicesProperties=[];var r=180-this.startAngle;this.slice_totals.map(function(o,l){var h=r,c=o/i.grand_total*FULL_ANGLE,u=n?-c:c,p=r+=u,d=e.getPositionByAngle(h,a),_=e.getPositionByAngle(p,a),f=t&&s[l],v=void 0,y=void 0;t?(v=f?f.startPosition:d,y=f?f.endPosition:d):(v=d,y=_);var m=i.makeArcPath(v,y),g=makePath(m,"pie-path","none",i.colors[l]);g.style.transition="transform .3s;",i.drawArea.appendChild(g),i.slices.push(g),i.slicesProperties.push({startPosition:d,endPosition:_,value:o,total:i.grand_total,startAngle:h,endAngle:p,angle:u}),t&&i.elements_to_animate.push([{unit:g,array:i.slices,index:i.slices.length-1},{d:i.makeArcPath(d,_)},650,"easein",null,{d:m}])}),t&&runSMILAnimation(this.chart_wrapper,this.svg,this.elements_to_animate)}},{key:"calTranslateByAngle",value:function(t){var i=this.radius,a=this.hoverRadio,n=e.getPositionByAngle(t.startAngle+t.angle/2,i);return"translate3d("+n.x*a+"px,"+n.y*a+"px,0)"}},{key:"hoverSlice",value:function(t,e,i,a){if(t){var n=this.colors[e];if(i){transform(t,this.calTranslateByAngle(this.slicesProperties[e])),t.style.fill=lightenDarkenColor(n,50);var s=offset(this.svg),r=a.pageX-s.left+10,o=a.pageY-s.top-10,l=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.labels[e])+": ",h=(100*this.slice_totals[e]/this.grand_total).toFixed(1);this.tip.set_values(r,o,l,h+"%"),this.tip.show_tip()}else transform(t,"translate3d(0,0,0)"),this.tip.hide_tip(),t.style.fill=n}}},{key:"mouseMove",value:function(t){for(var e=t.target,i=this.curActiveSliceIndex,a=this.curActiveSlice,n=0;n<this.slices.length;n++)if(e===this.slices[n]){this.hoverSlice(a,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=n,this.hoverSlice(e,n,!0,t);break}}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}},{key:"bind_tooltip",value:function(){this.drawArea.addEventListener("mousemove",this.mouseMove),this.drawArea.addEventListener("mouseleave",this.mouseLeave)}},{key:"renderLegend",value:function(){var t=this,e=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(i,a){var n=t.colors[a];i&&($$1.create("div",{className:"stats",inside:t.stats_wrapper}).innerHTML='<span class="indicator">\n\t\t\t\t\t<i style="background-color:'+n+';"></i>\n\t\t\t\t\t<span class="text-muted">'+e[a]+":</span>\n\t\t\t\t\t"+i+"\n\t\t\t\t</span>")})}}],[{key:"getPositionByAngle",value:function(t,e){return{x:Math.sin(t*ANGLE_RATIO)*e,y:Math.cos(t*ANGLE_RATIO)*e}}}]),e}(BaseChart),Heatmap=function(t){function e(t){var i=t.start,a=void 0===i?"":i,n=t.domain,s=void 0===n?"":n,r=t.subdomain,o=void 0===r?"":r,l=t.data,h=void 0===l?{}:l,c=t.discrete_domains,u=void 0===c?0:c,p=t.count_label,d=void 0===p?"":p,_=t.legend_colors,f=void 0===_?[]:_;classCallCheck(this,e);var v=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,arguments[0]));v.type="heatmap",v.domain=s,v.subdomain=o,v.data=h,v.discrete_domains=u,v.count_label=d;var y=new Date;return v.start=a||addDays(y,365),f=f.slice(0,5),v.legend_colors=v.validate_colors(f)?f:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],v.distribution_size=5,v.translate_x=0,v}return inherits(e,t),createClass(e,[{key:"validate_colors",value:function(t){if(t.length<5)return 0;var e=1;return t.forEach(function(t){isValidColor(t)||(e=0,console.warn('"'+t+'" is not a valid color.'))},this),e}},{key:"setupConstants",value:function(){this.today=new Date,this.start||(this.start=new Date,this.start.setFullYear(this.start.getFullYear()-1)),this.first_week_start=new Date(this.start.toDateString()),this.last_week_start=new Date(this.today.toDateString()),7!==this.first_week_start.getDay()&&addDays(this.first_week_start,-1*this.first_week_start.getDay()),7!==this.last_week_start.getDay()&&addDays(this.last_week_start,-1*this.last_week_start.getDay()),this.no_of_cols=getWeeksBetween(this.first_week_start+"",this.last_week_start+"")+1}},{key:"setWidth",value:function(){this.baseWidth=12*(this.no_of_cols+3),this.discrete_domains&&(this.baseWidth+=144)}},{key:"setupLayers",value:function(){this.domain_label_group=this.makeLayer("domain-label-group chart-label"),this.data_groups=this.makeLayer("data-groups","translate(0, 20)")}},{key:"setup_values",value:function(){var t=this;this.domain_label_group.textContent="",this.data_groups.textContent="";var e=Object.keys(this.data).map(function(e){return t.data[e]});this.distribution=calcDistribution(e,this.distribution_size),this.month_names=["January","February","March","April","May","June","July","August","September","October","November","December"],this.render_all_weeks_and_store_x_values(this.no_of_cols)}},{key:"render_all_weeks_and_store_x_values",value:function(t){var e=new Date(this.first_week_start);this.week_col=0,this.current_month=e.getMonth(),this.months=[this.current_month+""],this.month_weeks={},this.month_start_points=[],this.month_weeks[this.current_month]=0,this.month_start_points.push(13);for(var i=0;i<t;i++){var a=void 0,n=0,s=new Date(e),r=this.get_week_squares_group(s,this.week_col),o=slicedToArray(r,2);a=o[0],n=o[1],this.data_groups.appendChild(a),this.week_col+=1+parseInt(this.discrete_domains&&n),this.month_weeks[this.current_month]++,n&&(this.current_month=(this.current_month+1)%12,this.months.push(this.current_month+""),this.month_weeks[this.current_month]=1),addDays(e,7)}this.render_month_labels()}},{key:"get_week_squares_group",value:function(t,e){for(var i=this.today.getTime(),a=0,n=0,s=makeSVGGroup(this.data_groups,"data-group"),r=0,o=0;o<7;o+=1,r+=12){var l=0,h=0,c=t.getTime()/1e3,u=Math.floor(c-c%86400).toFixed(1);this.data[u]&&(l=this.data[u]),this.data[Math.round(u)]&&(l=this.data[Math.round(u)]),l&&(h=getMaxCheckpoint(l,this.distribution));var p=13+12*(e+n),d={"data-date":getDdMmYyyy(t),"data-value":l,"data-day":t.getDay()},_=makeHeatSquare("day",p,r,10,this.legend_colors[h],d);s.appendChild(_);var f=new Date(t);if(addDays(f,1),f.getTime()>i)break;f.getMonth()-t.getMonth()&&(a=1,this.discrete_domains&&(n=1),this.month_start_points.push(13+12*(e+n))),t=f}return[s,a]}},{key:"render_month_labels",value:function(){var t=this;this.months.shift(),this.month_start_points.shift(),this.months.pop(),this.month_start_points.pop(),this.month_start_points.map(function(e,i){var a=makeText("y-value-text",e+12,10,t.month_names[t.months[i]].substring(0,3));t.domain_label_group.appendChild(a)})}},{key:"renderComponents",value:function(){Array.prototype.slice.call(this.container.querySelectorAll(".graph-stats-container, .sub-title, .title")).map(function(t){t.style.display="None"}),this.chart_wrapper.style.marginTop="0px",this.chart_wrapper.style.paddingTop="0px"}},{key:"bind_tooltip",value:function(){var t=this;Array.prototype.slice.call(document.querySelectorAll(".data-group .day")).map(function(e){e.addEventListener("mouseenter",function(e){var i=e.target.getAttribute("data-value"),a=e.target.getAttribute("data-date").split("-"),n=t.month_names[parseInt(a[1])-1].substring(0,3),s=t.chart_wrapper.getBoundingClientRect(),r=e.target.getBoundingClientRect(),o=parseInt(e.target.getAttribute("width")),l=r.left-s.left+(o+2)/2,h=r.top-s.top-(o+2)/2,c=i+" "+t.count_label,u=" on "+n+" "+a[0]+", "+a[2];t.tip.set_values(l,h,u,c,[],1),t.tip.show_tip()})})}},{key:"update",value:function(t){this.data=t,this.setup_values(),this.bind_tooltip()}}]),e}(BaseChart),chartTypes={line:LineChart,bar:BarChart,scatter:ScatterChart,percentage:PercentageChart,heatmap:Heatmap,pie:PieChart},Chart=function t(e){return classCallCheck(this,t),getChartByType(e.type,arguments[0])};module.exports=Chart;