frappe-charts
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,1 +0,1 @@ | ||
var Chart=function(){"use strict";function t(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function e(t){return parseFloat(t.toFixed(2))}function i(t,e){if(t.length!==e.length)return!1;var i=!0;return t.map(function(t,a){e[a]!==t&&(i=!1)}),i}function a(t){return t>255?255:t<0?0:t}function s(t,e){var i=!1;"#"==t[0]&&(t=t.slice(1),i=!0);var s=parseInt(t,16),n=a((s>>16)+e),r=a((s>>8&255)+e),o=a((255&s)+e);return(i?"#":"")+(o|r<<8|n<<16).toString(16)}function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1];return N[t]?new N[t](e):new y(e)}!function(t,e){if("undefined"==typeof document)return e;t=t||"";var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",i.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}('.chart-container{font-family:Roboto,Geneva,Tahoma,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}.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}.graph-svg-tip ol,.graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;bottom:-10px;left:50%;width:5px;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}.indicator,.indicator-right{background:none;font-size:12px;vertical-align:middle;font-weight:700;color:#6c7680}.indicator-right:after,.indicator:before,.indicator i{content:"";display:inline-block;height:8px;width:8px;border-radius:8px}.indicator:before,.indicator i{margin:0 4px 0 0}.indicator-right:after{margin:0 0 0 4px}.background.grey,.indicator-right.grey:after,.indicator.grey:before,.indicator.grey i{background:#bdd3e6}.background.light-grey,.indicator-right.light-grey:after,.indicator.light-grey:before,.indicator.light-grey i{background:#f0f4f7}.background.blue,.indicator-right.blue:after,.indicator.blue:before,.indicator.blue i{background:#5e64ff}.background.red,.indicator-right.red:after,.indicator.red:before,.indicator.red i{background:#ff5858}.background.green,.indicator-right.green:after,.indicator.green:before,.indicator.green i{background:#28a745}.background.light-green,.indicator-right.light-green:after,.indicator.light-green:before,.indicator.light-green i{background:#98d85b}.background.orange,.indicator-right.orange:after,.indicator.orange:before,.indicator.orange i{background:#ffa00a}.background.violet,.indicator-right.violet:after,.indicator.violet:before,.indicator.violet i{background:#743ee2}.background.dark-grey,.indicator-right.dark-grey:after,.indicator.dark-grey:before,.indicator.dark-grey i{background:#b8c2cc}.background.black,.indicator-right.black:after,.indicator.black:before,.indicator.black i{background:#36414c}.background.yellow,.indicator-right.yellow:after,.indicator.yellow:before,.indicator.yellow i{background:#feef72}.background.light-blue,.indicator-right.light-blue:after,.indicator.light-blue:before,.indicator.light-blue i{background:#7cd6fd}.background.purple,.indicator-right.purple:after,.indicator.purple:before,.indicator.purple i{background:#b554ff}.background.magenta,.indicator-right.magenta:after,.indicator.magenta:before,.indicator.magenta i{background:#ffa3ef}.stroke.grey{stroke:#bdd3e6}.stroke.light-grey{stroke:#f0f4f7}.stroke.blue{stroke:#5e64ff}.stroke.red{stroke:#ff5858}.stroke.light-green{stroke:#98d85b}.stroke.green{stroke:#28a745}.stroke.orange{stroke:#ffa00a}.stroke.violet{stroke:#743ee2}.stroke.dark-grey{stroke:#b8c2cc}.stroke.black{stroke:#36414c}.stroke.yellow{stroke:#feef72}.stroke.light-blue{stroke:#7cd6fd}.stroke.purple{stroke:#b554ff}.stroke.magenta{stroke:#ffa3ef}.fill.grey{fill:#bdd3e6}.fill.light-grey{fill:#f0f4f7}.fill.blue{fill:#5e64ff}.fill.red{fill:#ff5858}.fill.light-green{fill:#98d85b}.fill.green{fill:#28a745}.fill.orange{fill:#ffa00a}.fill.violet{fill:#743ee2}.fill.dark-grey{fill:#b8c2cc}.fill.black{fill:#36414c}.fill.yellow{fill:#feef72}.fill.light-blue{fill:#7cd6fd}.fill.purple{fill:#b554ff}.fill.magenta{fill:#ffa3ef}.border-top.grey{border-top:3px solid #bdd3e6}.border-top.light-grey{border-top:3px solid #f0f4f7}.border-top.blue{border-top:3px solid #5e64ff}.border-top.red{border-top:3px solid #ff5858}.border-top.light-green{border-top:3px solid #98d85b}.border-top.green{border-top:3px solid #28a745}.border-top.orange{border-top:3px solid #ffa00a}.border-top.violet{border-top:3px solid #743ee2}.border-top.dark-grey{border-top:3px solid #b8c2cc}.border-top.black{border-top:3px solid #36414c}.border-top.yellow{border-top:3px solid #feef72}.border-top.light-blue{border-top:3px solid #7cd6fd}.border-top.purple{border-top:3px solid #b554ff}.border-top.magenta{border-top:3px solid #ffa3ef}.stop-color.grey{stop-color:#bdd3e6}.stop-color.light-grey{stop-color:#f0f4f7}.stop-color.blue{stop-color:#5e64ff}.stop-color.red{stop-color:#ff5858}.stop-color.light-green{stop-color:#98d85b}.stop-color.green{stop-color:#28a745}.stop-color.orange{stop-color:#ffa00a}.stop-color.violet{stop-color:#743ee2}.stop-color.dark-grey{stop-color:#b8c2cc}.stop-color.black{stop-color:#36414c}.stop-color.yellow{stop-color:#feef72}.stop-color.light-blue{stop-color:#7cd6fd}.stop-color.purple{stop-color:#b554ff}.stop-color.magenta{stop-color:#ffa3ef}',void 0);var r="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},o=(function(){function t(t){this.value=t}function e(e){function i(s,n){try{var r=e[s](n),o=r.value;o instanceof t?Promise.resolve(o.value).then(function(t){i("next",t)},function(t){i("throw",t)}):a(r.done?"return":"normal",r.value)}catch(t){a("throw",t)}}function a(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)?i(s.key,s.arg):n=null}var s,n;this._invoke=function(t,e){return new Promise(function(a,r){var o={key:t,arg:e,resolve:a,reject:r,next:null};n?n=n.next=o:(s=n=o,i(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"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)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),l=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}}(),h=function t(e,i,a){null===e&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var n=Object.getPrototypeOf(e);return null===n?void 0:t(n,i,a)}if("value"in s)return s.value;var r=s.get;if(void 0!==r)return r.call(a)},c=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)},u=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},_=function(){function t(t,e){var i=[],a=!0,s=!1,n=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){s=!0,n=t}finally{try{!a&&o.return&&o.return()}finally{if(s)throw n}}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")}}(),p=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)},d={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"};t.findNodeIndex=function(t){for(var e=0;t.previousSibling;)t=t.previousSibling,e++;return e},t.create=function(e,i){var a=document.createElement(e);for(var s in i){var n=i[s];if("inside"===s)t(n).appendChild(a);else if("around"===s){var o=t(n);o.parentNode.insertBefore(a,o),a.appendChild(o)}else"styles"===s?"object"===(void 0===n?"undefined":r(n))&&Object.keys(n).map(function(t){a.style[t]=n[t]}):s in a?a[s]=n:a.setAttribute(s,n)}return a},t.createSVG=function(e,i){var a=document.createElementNS("http://www.w3.org/2000/svg",e);for(var s in i){var n=i[s];if("inside"===s)t(n).appendChild(a);else if("around"===s){var r=t(n);r.parentNode.insertBefore(a,r),a.appendChild(r)}else"className"===s&&(s="class"),"innerHTML"===s?a.textContent=n:a.setAttribute(s,n)}return a},t.runSVGAnimation=function(e,i){var a=[],s=[];i.map(function(e){var i=e[0],n=i.unit.parentNode,r=void 0,o=void 0;e[0]=i.unit;var l=t.animateSVG.apply(t,p(e)),h=_(l,2);r=h[0],o=h[1],a.push(o),s.push([r,n]),n.replaceChild(r,i.unit),i.array?i.array[i.index]=o:i.object[i.key]=o});var n=e.cloneNode(!0);return s.map(function(t,e){t[1].replaceChild(a[e],t[0]),i[e][0]=a[e]}),n},t.transform=function(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e},t.animateSVG=function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"linear",s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,n=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=n[l]||t.getAttribute(l),u=e[l],_={attributeName:l,from:c,to:u,begin:"0s",dur:i/1e3+"s",values:c+";"+u,keySplines:d[a],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};s&&(_.type=s);for(var p in _)h.setAttribute(p,_[p]);r.appendChild(h),s?o.setAttribute(l,"translate("+u+")"):o.setAttribute(l,u)}return[r,o]},t.offset=function(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}},t.isElementInViewport=function(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)},t.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)})}},t.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)})}},t.fire=function(t,e,i){var a=document.createEvent("HTMLEvents");a.initEvent(e,!0,!0);for(var s in i)a[s]=i[s];return t.dispatchEvent(a)};var f=function(){function e(t){var i=t.parent,a=void 0===i?null:i;o(this,e),this.parent=a,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 l(e,[{key:"setup",value:function(){this.make_tooltip()}},{key:"refresh",value:function(){this.fill(),this.calc_position()}},{key:"make_tooltip",value:function(){var e=this;this.container=t.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(){e.hide_tip()})}},{key:"fill",value:function(){var e=this,i=void 0;i=this.title_value_first?"<strong>"+this.title_value+"</strong>"+this.title_name:this.title_name+"<strong>"+this.title_value+"</strong>",this.title.innerHTML=i,this.data_point_list.innerHTML="",this.list_values.map(function(i){var a=t.create("li",{className:"border-top "+(i.color||"black"),innerHTML:'<strong style="display: block;">'+(isNaN(i.value)?"":i.value)+"</strong>\n\t\t\t\t\t"+(i.title?i.title:"")});e.data_point_list.appendChild(a)})}},{key:"calc_position",value:function(){this.top=this.y-this.container.offsetHeight,this.left=this.x-this.container.offsetWidth/2;var t=this.parent.offsetWidth-this.container.offsetWidth,e=this.container.querySelector(".svg-pointer");if(this.left<0)e.style.left="calc(50% - "+-1*this.left+"px)",this.left=0;else if(this.left>t){var i=this.left-t;e.style.left="calc(50% + "+i+"px)",this.left=t}else e.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]:"",s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.title_name=i,this.title_value=a,this.list_values=s,this.x=t,this.y=e,this.title_value_first=n,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"}}]),e}(),v=function(){function e(t){var i=t.height,a=void 0===i?240:i,s=t.title,n=void 0===s?"":s,r=t.subtitle,l=void 0===r?"":r,h=t.format_lambdas,c=void 0===h?{}:h,u=t.summary,_=void 0===u?[]:u,p=t.is_navigable,d=void 0===p?0:p,f=t.has_legend,v=void 0===f?0:f,g=(t.type,t.parent),m=t.data;o(this,e),this.raw_chart_args=arguments[0],this.parent="string"==typeof g?document.querySelector(g):g,this.title=n,this.subtitle=l,this.data=m,this.format_lambdas=c,this.specific_values=m.specific_values||[],this.summary=_,this.is_navigable=d,this.is_navigable&&(this.current_index=0),this.has_legend=v,this.chart_types=["line","scatter","bar","percentage","heatmap","pie"],this.set_margins(a)}return l(e,[{key:"get_different_chart",value:function(t){if(this.chart_types.includes(t)||console.error("'"+t+"' is not a valid chart type."),t!==this.type){return{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:[]}[this.type].includes(t)||console.error("'"+this.type+"' chart cannot be converted to a '"+t+"' chart."),new A({parent:this.raw_chart_args.parent,title:this.title,data:this.raw_chart_args.data,type:t,height:this.raw_chart_args.height})}}},{key:"set_margins",value:function(t){this.base_height=t,this.height=t-40,this.translate_x=60,this.translate_y=10}},{key:"setup",value:function(){this.parent?(this.bind_window_events(),this.refresh(!0)):console.error("No parent element to render on was provided.")}},{key:"bind_window_events",value:function(){var t=this;window.addEventListener("resize",function(){return t.refresh()}),window.addEventListener("orientationchange",function(){return t.refresh()})}},{key:"refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.setup_base_values(),this.set_width(),this.setup_container(),this.setup_components(),this.setup_values(),this.setup_utils(),this.make_graph_components(t),this.make_tooltip(),this.summary.length>0?this.show_custom_summary():this.show_summary(),this.is_navigable&&this.setup_navigation(t)}},{key:"set_width",value:function(){var t=this,e=0;this.specific_values.map(function(i){t.get_strwidth(i.title)>e&&(e=t.get_strwidth(i.title)-40)}),this.base_width=this.parent.offsetWidth-e,this.width=this.base_width-2*this.translate_x}},{key:"setup_base_values",value:function(){}},{key:"setup_container",value:function(){this.container=t.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"),this.make_chart_area(),this.make_draw_area()}},{key:"make_chart_area",value:function(){return this.svg=t.createSVG("svg",{className:"chart",inside:this.chart_wrapper,width:this.base_width,height:this.base_height}),this.svg_defs=t.createSVG("defs",{inside:this.svg}),this.svg}},{key:"make_draw_area",value:function(){this.draw_area=t.createSVG("g",{className:this.type+"-chart",inside:this.svg,transform:"translate("+this.translate_x+", "+this.translate_y+")"})}},{key:"setup_components",value:function(){}},{key:"make_tooltip",value:function(){this.tip=new f({parent:this.chart_wrapper}),this.bind_tooltip()}},{key:"show_summary",value:function(){}},{key:"show_custom_summary",value:function(){var e=this;this.summary.map(function(i){var a=t.create("div",{className:"stats",innerHTML:'<span class="indicator '+i.color+'">'+i.title+": "+i.value+"</span>"});e.stats_wrapper.appendChild(a)})}},{key:"setup_navigation",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.make_overlay(),i&&(this.bind_overlay(),document.addEventListener("keydown",function(i){t.isElementInViewport(e.chart_wrapper)&&("37"==(i=i||window.event).keyCode?e.on_left_arrow():"39"==i.keyCode?e.on_right_arrow():"38"==i.keyCode?e.on_up_arrow():"40"==i.keyCode?e.on_down_arrow():"13"==i.keyCode&&e.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:"get_data_point",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","y_tops","values"].map(function(a){var s=a.slice(0,a.length-1);e[s]=i[a][t]}),e.label=this.x[t],e}},{key:"update_current_data_point",value:function(e){(e=parseInt(e))<0&&(e=0),e>=this.x.length&&(e=this.x.length-1),e!==this.current_index&&(this.current_index=e,t.fire(this.parent,"data-select",this.get_data_point()))}},{key:"get_strwidth",value:function(t){return 8*(t+"").length}},{key:"setup_utils",value:function(){}}]),e}(),g=function(a){function s(t){o(this,s);var e=u(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t));return e.x=e.data.labels,e.y=e.data.datasets,e.is_series=t.is_series,e.get_y_label=e.format_lambdas.y_label,e.get_y_tooltip=e.format_lambdas.y_tooltip,e.get_x_tooltip=e.format_lambdas.x_tooltip,e.colors=["green","blue","violet","red","orange","yellow","light-blue","light-green","purple","magenta"],e.zero_line=e.height,e}return c(s,v),l(s,[{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.x_axis_positions&&(this.x_old_axis_positions=this.x_axis_positions.slice()),this.x_axis_positions=this.x.map(function(i,a){return e(t.x_offset+a*t.avg_unit_width)}),this.x_old_axis_positions||(this.x_old_axis_positions=this.x_axis_positions.slice())}},{key:"setup_y",value:function(){this.y_axis_values&&(this.y_old_axis_values=this.y_axis_values.slice());var t=this.get_all_y_values();this.y_sums&&this.y_sums.length>0&&(t=t.concat(this.y_sums)),this.y_axis_values=this.get_y_axis_points(t),this.y_old_axis_values||(this.y_old_axis_values=this.y_axis_values.slice());var e=this.y_axis_values,i=e[e.length-1]-e[0];this.multiplier&&(this.old_multiplier=this.multiplier),this.multiplier=this.height/i,this.old_multiplier||(this.old_multiplier=this.multiplier);var a=e.indexOf(0),s=(e[1]-e[0])*this.multiplier;this.zero_line&&(this.old_zero_line=this.zero_line),this.zero_line=this.height-a*s,this.old_zero_line||(this.old_zero_line=this.zero_line)}},{key:"setup_components",value:function(){h(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"setup_components",this).call(this),this.setup_marker_components(),this.setup_aggregation_components(),this.setup_graph_components()}},{key:"setup_marker_components",value:function(){this.y_axis_group=t.createSVG("g",{className:"y axis",inside:this.draw_area}),this.x_axis_group=t.createSVG("g",{className:"x axis",inside:this.draw_area}),this.specific_y_group=t.createSVG("g",{className:"specific axis",inside:this.draw_area})}},{key:"setup_aggregation_components",value:function(){this.sum_group=t.createSVG("g",{className:"data-points",inside:this.draw_area}),this.average_group=t.createSVG("g",{className:"chart-area",inside:this.draw_area})}},{key:"setup_graph_components",value:function(){var e=this;this.svg_units_groups=[],this.y.map(function(i,a){e.svg_units_groups[a]=t.createSVG("g",{className:"data-points data-points-"+a,inside:e.draw_area})})}},{key:"make_graph_components",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.make_y_axis(),this.make_x_axis(),this.draw_graph(t),this.make_y_specifics()}},{key:"make_x_axis",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=void 0,a=void 0,s=void 0,n="";if("span"===this.x_axis_mode?(i=-7,a=this.height+15,s=this.height+25):"tick"===this.x_axis_mode&&(i=this.height,a=6,s=9,n="x-axis-label"),this.x_axis_group.setAttribute("transform","translate(0,"+i+")"),e)this.make_anim_x_axis(a,s,n);else{var r=1.5*this.avg_unit_width,o=r/8;this.x_axis_group.textContent="",this.x.map(function(e,i){var l=t.get_strwidth(e)+2;if(l>r)if(t.is_series){for(var h=1;l/h*2>r;)h++;if(i%h!=0)return}else e=e.slice(0,o-3)+" ...";t.x_axis_group.appendChild(t.make_x_line(a,s,e,"x-value-text",n,t.x_axis_positions[i]))})}}},{key:"make_y_axis",value:function(){var t=this;if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return this.make_anim_y_axis(),void this.make_anim_y_specifics();var e=this.get_y_axis_line_props(),i=_(e,4),a=i[0],s=i[1],n=i[2],r=i[3];this.y_axis_group.textContent="",this.y_axis_values.map(function(e,i){t.y_axis_group.appendChild(t.make_y_line(r,a,s,e,"y-value-text",n,t.zero_line-e*t.multiplier,0===e&&0!==i))})}},{key:"get_y_axis_line_props",value:function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return[this.width,this.width+5,"specific-value",0];var t=void 0,e="",i=0;return"span"===this.y_axis_mode?(t=this.width+6,i=-6):"tick"===this.y_axis_mode&&(t=-6,e="y-axis-label"),[t,-9,e,i]}},{key:"draw_graph",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];!this.raw_chart_args.hasOwnProperty("init")||this.raw_chart_args.init?e?this.draw_new_graph_and_animate():this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i)}):this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i),t.calc_y_dependencies()})}},{key:"draw_new_graph_and_animate",value:function(){var t=this,e=[];this.y.map(function(i,a){i.y_tops=new Array(i.values.length).fill(t.zero_line),e.push({values:i.values}),i.svg_units=[],t.make_path&&t.make_path(i,a,t.x_axis_positions,i.y_tops,i.color||t.colors[a]),t.make_new_units(i,a)}),setTimeout(function(){t.update_values(e)},350)}},{key:"setup_navigation",value:function(t){var e=this;t?setTimeout(function(){h(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"setup_navigation",e).call(e,t)},500):h(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"setup_navigation",this).call(this,t)}},{key:"make_new_units",value:function(t,e){this.make_new_units_for_dataset(this.x_axis_positions,t.y_tops,t.color||this.colors[e],e,this.y.length)}},{key:"make_new_units_for_dataset",value:function(t,e,i,a,s,n,r,o){var l=this;n||(n=this.svg_units_groups[a]),r||(r=this.y[a].svg_units),o||(o=this.unit_args),n.textContent="",r.length=0,e.map(function(e,h){var c=l.draw[o.type](t[h],e,o.args,i,h,a,s);n.appendChild(c),r.push(c)}),this.is_navigable&&this.bind_units(r)}},{key:"make_y_specifics",value:function(){var t=this;this.specific_y_group.textContent="",this.specific_values.map(function(e){t.specific_y_group.appendChild(t.make_y_line(0,t.width,t.width+5,e.title.toUpperCase(),"specific-value","specific-value",t.zero_line-e.value*t.multiplier,!1,e.line_type))})}},{key:"bind_tooltip",value:function(){var e=this;this.chart_wrapper.addEventListener("mousemove",function(i){var a=t.offset(e.chart_wrapper),s=i.pageX-a.left-e.translate_x;i.pageY-a.top-e.translate_y<e.height+2*e.translate_y?e.map_tooltip_x_position_and_show(s):e.tip.hide_tip()})}},{key:"map_tooltip_x_position_and_show",value:function(t){var e=this;if(this.y_min_tops)for(var i=this.x_axis_positions.length-1;i>=0;i--){var a=this.x_axis_positions[i];if(t>a-this.avg_unit_width/2){var s=a+this.translate_x,n=this.y_min_tops[i]+this.translate_y,r=this.x.formatted&&this.x.formatted.length>0?this.x.formatted[i]:this.x[i],o=this.y.map(function(t,a){return{title:t.title,value:t.formatted?t.formatted[i]:t.values[i],color:t.color||e.colors[a]}});this.tip.set_values(s,n,r,"",o),this.tip.show_tip();break}}}},{key:"show_sums",value:function(){var t=this;this.updating=!0,this.y_sums=new Array(this.x_axis_positions.length).fill(0),this.y.map(function(e){e.values.map(function(e,i){t.y_sums[i]+=e})}),this.update_values(),this.sum_units=[],this.make_new_units_for_dataset(this.x_axis_positions,this.y_sums.map(function(i){return e(t.zero_line-i*t.multiplier)}),"light-grey",0,1,this.sum_group,this.sum_units),this.updating=!1}},{key:"hide_sums",value:function(){this.updating||(this.y_sums=[],this.sum_group.textContent="",this.sum_units=[],this.update_values())}},{key:"show_averages",value:function(){var t=this;this.old_specific_values=this.specific_values.slice(),this.y.map(function(e,i){var a=0;e.values.map(function(t){a+=t});var s=a/e.values.length;t.specific_values.push({title:"AVG "+(i+1),line_type:"dashed",value:s,auto:1})}),this.update_values()}},{key:"hide_averages",value:function(){var t=this;this.old_specific_values=this.specific_values.slice();var e=[];this.specific_values.map(function(t,i){t.auto&&e.unshift(i)}),e.map(function(e){t.specific_values.splice(e,1)}),this.update_values()}},{key:"update_values",value:function(t,e){var a=this;e||(e=this.x),this.elements_to_animate=[],this.updating=!0,this.old_x_values=this.x.slice(),this.old_y_axis_tops=this.y.map(function(t){return t.y_tops.slice()}),this.old_y_values=this.y.map(function(t){return t.values}),this.no_of_extra_pts=e.length-this.x.length,t&&this.y.map(function(e,i){e.values=t[i].values}),e&&(this.x=e),this.setup_x(),this.setup_y(),i(this.x_old_axis_positions,this.x_axis_positions)||(this.make_x_axis(!0),setTimeout(function(){a.updating||a.make_x_axis()},350)),(!i(this.y_old_axis_values,this.y_axis_values)||this.old_specific_values&&!i(this.old_specific_values,this.specific_values))&&(this.make_y_axis(!0),setTimeout(function(){a.updating||(a.make_y_axis(),a.make_y_specifics())},350)),this.calc_y_dependencies(),this.animate_graphs(),this.run_animation(),this.updating=!1}},{key:"add_data_point",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.x.length,a=this.y.map(function(t){return{values:t.values}});a.map(function(e,a){e.values.splice(i,0,t[a])});var s=this.x.slice();s.splice(i,0,e),this.update_values(a,s)}},{key:"remove_data_point",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.x.length-1;if(!(this.x.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.x.slice();i.splice(t,1),this.update_values(e,i)}}},{key:"run_animation",value:function(){var e=this,i=t.runSVGAnimation(this.svg,this.elements_to_animate);this.svg.parentNode==this.chart_wrapper&&(this.chart_wrapper.removeChild(this.svg),this.chart_wrapper.appendChild(i)),setTimeout(function(){i.parentNode==e.chart_wrapper&&(e.chart_wrapper.removeChild(i),e.chart_wrapper.appendChild(e.svg))},250)}},{key:"animate_graphs",value:function(){var t=this;this.y.map(function(e,i){var a=t.calc_old_and_new_postions(e,i),s=_(a,4),n=s[0],r=s[1],o=s[2],l=s[3];t.no_of_extra_pts>=0&&(t.make_path&&t.make_path(e,i,n,r,e.color||t.colors[i]),t.make_new_units_for_dataset(n,r,e.color||t.colors[i],i,t.y.length)),e.path&&t.animate_path(e,i,n,r,o,l),t.animate_units(e,i,n,r,o,l)}),setTimeout(function(){t.y.map(function(e,i){t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i)})},400)}},{key:"animate_path",value:function(t,e,i,a,s,n){var r=n.map(function(t,e){return s[e]+","+t}).join("L"),o=[{unit:t.path,object:t,key:"path"},{d:"M"+r},350,"easein"];if(this.elements_to_animate.push(o),t.region_path){var l="0,"+this.zero_line+"L",h="L"+this.width+","+this.zero_line,c=[{unit:t.region_path,object:t,key:"region_path"},{d:"M"+l+r+h},350,"easein"];this.elements_to_animate.push(c)}}},{key:"animate_units",value:function(t,e,i,a,s,n){var r=this,o=this.unit_args.type;t.svg_units.map(function(i,a){void 0!==s[a]&&void 0!==n[a]&&r.elements_to_animate.push(r.animate[o]({unit:i,array:t.svg_units,index:a},s[a],n[a],e))})}},{key:"calc_old_and_new_postions",value:function(t,e){var i=this.x_old_axis_positions.slice(),a=this.x_axis_positions.slice(),s=this.old_y_axis_tops[e].slice(),n=t.y_tops.slice(),r=i[i.length-1],o=s[s.length-1],l=a[a.length-1],h=n[n.length-1];if(this.no_of_extra_pts>=0){var c=new Array(Math.abs(this.no_of_extra_pts)).fill(r),u=new Array(Math.abs(this.no_of_extra_pts)).fill(o);i=i.concat(c),s=s.concat(u)}else{var _=new Array(Math.abs(this.no_of_extra_pts)).fill(l),p=new Array(Math.abs(this.no_of_extra_pts)).fill(h);a=a.concat(_),n=n.concat(p)}return[i,s,a,n]}},{key:"make_anim_x_axis",value:function(t,e,i){var a=this,s=this.x_old_axis_positions,n=this.x_axis_positions,r=this.old_x_values,o=this.x,l=s[s.length-1];this.x_axis_group.textContent="",this.make_new_axis_anim_lines(s,n,r,o,l,function(s,n,r){"string"==typeof r&&(r=parseInt(r.substring(0,r.length-1)));var o=a.make_x_line(t,e,s,"x-value-text",i,n);a.x_axis_group.appendChild(o),a.elements_to_animate&&a.elements_to_animate.push([{unit:o,array:[0],index:0},{transform:r+", 0"},350,"easein","translate",{transform:n+", 0"}])})}},{key:"make_anim_y_axis",value:function(){var t=this,e=this.y_old_axis_values.map(function(e){return t.zero_line-e*t.multiplier}),i=this.y_axis_values.map(function(e){return t.zero_line-e*t.multiplier}),a=this.y_old_axis_values,s=this.y_axis_values,n=e[e.length-1];this.y_axis_group.textContent="",this.make_new_axis_anim_lines(e,i,a,s,n,this.add_and_animate_y_line.bind(this),this.y_axis_group)}},{key:"make_anim_y_specifics",value:function(){var t=this;this.specific_y_group.textContent="",this.specific_values.map(function(e){t.add_and_animate_y_line(e.title,t.old_zero_line-e.value*t.old_multiplier,t.zero_line-e.value*t.multiplier,0,t.specific_y_group,e.line_type,!0)})}},{key:"make_new_axis_anim_lines",value:function(t,e,i,a,s,n,r){var o=void 0,l=void 0,h=a.length-i.length;if(h>0)o=e.slice(0,t.length),l=a.slice(0,i.length);else{var c=new Array(Math.abs(h)).fill("");l=a.concat(c);var u=new Array(Math.abs(h)).fill(s+"F");o=e.concat(u)}if(l.map(function(e,i){n(e,t[i],o[i],i,r)}),h>0){var _=a.slice(i.length),p=e.slice(t.length);_.map(function(t,e){n(t,s,p[e],e,r)})}}},{key:"make_x_line",value:function(e,i,a,s,n,r){var o=t.createSVG("line",{x1:0,x2:0,y1:0,y2:e}),l=t.createSVG("text",{className:s,x:0,y:i,dy:".71em",innerHTML:a}),h=t.createSVG("g",{className:"tick "+n,transform:"translate("+r+", 0)"});return h.appendChild(o),h.appendChild(l),h}},{key:"make_y_line",value:function(e,i,a,s,n,r,o){var l=arguments.length>7&&void 0!==arguments[7]&&arguments[7],h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:"",c=t.createSVG("line",{className:"dashed"===h?"dashed":"",x1:e,x2:i,y1:0,y2:0}),u=t.createSVG("text",{className:n,x:a,y:0,dy:".32em",innerHTML:s+""}),_=t.createSVG("g",{className:"tick "+r,transform:"translate(0, "+o+")","stroke-opacity":1});return l&&(c.style.stroke="rgba(27, 31, 35, 0.6)"),_.appendChild(c),_.appendChild(u),_}},{key:"add_and_animate_y_line",value:function(t,e,i,a,s,n){var r=arguments.length>6&&void 0!==arguments[6]&&arguments[6],o=!1;"string"==typeof i&&(i=parseInt(i.substring(0,i.length-1)),o=!0);var l={transform:"0, "+i},h={transform:"0, "+e};o&&(l["stroke-opacity"]=0);var c=this.get_y_axis_line_props(r),u=_(c,4),p=u[0],d=u[1],f=u[2],v=u[3],g=r?"specific-value":"y-value-text";t=r?(t+"").toUpperCase():t;var m=this.make_y_line(v,p,d,t,g,f,e,0===t&&0!==a,n);s.appendChild(m),this.elements_to_animate&&this.elements_to_animate.push([{unit:m,array:[0],index:0},l,350,"easein","translate",h])}},{key:"get_y_axis_points",value:function(t){var e=this,i=void 0,a=void 0,s=void 0,n=void 0,r=parseInt(Math.max.apply(Math,p(t))),o=parseInt(Math.min.apply(Math,p(t)));o>=0&&(o=0);var l=function(t,i){var a=void 0,s=void 0,n=void 0,r=void 0,o=void 0;if((t+"").length<=1)a=10,n=5;else{var l=e.calc_upper_bound_and_no_of_parts(t),h=_(l,2);a=h[0],n=h[1]}return o=a/n,r=e.calc_no_of_parts(i,o),s=r*o,[a,s,n,r,o]},h=-1*o;if(h<=r){var c=l(r,h),u=_(c,5);i=u[1],a=u[2],s=u[3],n=u[4],0===h&&(i=0,s=0)}else{var d=l(h,r),f=_(d,5);i=f[0],s=f[2],a=f[3],n=f[4]}a%2!=0&&s>0&&a++,s%2!=0&&(s++,i+=n);var v=a+s;return v>5&&(v/=2,n*=2,a/=2),r<(a-1)*n&&v--,this.get_intervals(-1*i,n,v)}},{key:"get_intervals",value:function(t,e,i){for(var a=[],s=0;s<=i;s++)a.push(t),t+=e;return a}},{key:"calc_upper_bound_and_no_of_parts",value:function(t){var e=Math.pow(10,(t+"").length-1),i=this.calc_no_of_parts(t,e);return[e*i,i]}},{key:"calc_no_of_parts",value:function(t,e){var i=Math.ceil(t/e);return i%2!=0&&i++,i}},{key:"get_optimal_no_of_parts",value:function(t){return t<5?t:t/2}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.x.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:"calc_y_dependencies",value:function(){var t=this;this.y_min_tops=new Array(this.x_axis_positions.length).fill(9999),this.y.map(function(i){i.y_tops=i.values.map(function(i){return e(t.zero_line-i*t.multiplier)}),i.y_tops.map(function(e,i){e<t.y_min_tops[i]&&(t.y_min_tops[i]=e)})})}},{key:"get_bar_height_and_y_attr",value:function(t){var e=void 0,i=void 0;return t<=this.zero_line?(i=t,0===(e=this.zero_line-t)&&(i-=e=.01*this.height)):(e=t-this.zero_line,i=this.zero_line,0===e&&(e=.01*this.height)),[e,i]}},{key:"setup_utils",value:function(){var e=this;this.draw={bar:function(i,a,s,n,r,o,l){var h=e.avg_unit_width-s.space_width,c=h/l,u=i-h/2+c*o,p=e.get_bar_height_and_y_attr(a),d=_(p,2),f=d[0],v=d[1];return t.createSVG("rect",{className:"bar mini fill "+n,"data-point-index":r,x:u,y:v,width:c,height:f})},dot:function(e,i,a,s,n){return t.createSVG("circle",{className:"fill "+s,"data-point-index":n,cx:e,cy:i,r:a.radius})}},this.animate={bar:function(t,i,a,s){var n=i-e.avg_unit_width/4,r=e.avg_unit_width/2/e.y.length,o=e.get_bar_height_and_y_attr(a),l=_(o,2);return i=n+r*s,[t,{width:r,height:l[0],x:i,y:l[1]},350,"easein"]},dot:function(t,e,i){return[t,{cx:e,cy:i},350,"easein"]}}}}]),s}(),m=function(t){function e(t){o(this,e);var i=u(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 c(e,g),l(e,[{key:"setup_values",value:function(){h(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:{space_width:this.avg_unit_width/2}}}},{key:"make_overlay",value:function(){var t=this.x.length-1,e=this.y[0].svg_units[t];this.update_current_data_point(t),this.overlay&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=e.cloneNode(),this.overlay.style.fill="#000000",this.overlay.style.opacity="0.4",this.draw_area.appendChild(this.overlay)}},{key:"bind_overlay",value:function(){var t=this;this.parent.addEventListener("data-select",function(e){t.update_overlay(e.svg_unit)})}},{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.update_current_data_point(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)})}},{key:"on_left_arrow",value:function(){this.update_current_data_point(this.current_index-1)}},{key:"on_right_arrow",value:function(){this.update_current_data_point(this.current_index+1)}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.x.length+1),this.x_offset=this.avg_unit_width}}]),e}(),y=function(e){function i(t){o(this,i);var e=u(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.x_axis_mode=t.x_axis_mode||"span",e.y_axis_mode=t.y_axis_mode||"span",t.hasOwnProperty("show_dots")?e.show_dots=t.show_dots:e.show_dots=1,e.region_fill=t.region_fill,Object.getPrototypeOf(e)!==i.prototype?u(e):(e.dot_radius=t.dot_radius||4,e.heatline=t.heatline,e.type="line",e.setup(),e)}return c(i,g),l(i,[{key:"setup_graph_components",value:function(){this.setup_path_groups(),h(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_graph_components",this).call(this)}},{key:"setup_path_groups",value:function(){var e=this;this.paths_groups=[],this.y.map(function(i,a){e.paths_groups[a]=t.createSVG("g",{className:"path-group path-group-"+a,inside:e.draw_area})})}},{key:"setup_values",value:function(){h(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_values",this).call(this),this.unit_args={type:"dot",args:{radius:this.dot_radius}}}},{key:"make_new_units_for_dataset",value:function(t,e,a,s,n,r,o,l){this.show_dots&&h(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"make_new_units_for_dataset",this).call(this,t,e,a,s,n,r,o,l)}},{key:"make_paths",value:function(){var t=this;this.y.map(function(e,i){t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i])})}},{key:"make_path",value:function(e,i,a,s,n){var r=s.map(function(t,e){return a[e]+","+t}).join("L");if(this.paths_groups[i].textContent="",e.path=t.createSVG("path",{inside:this.paths_groups[i],className:"stroke "+n,d:"M"+r}),this.heatline){var o=this.make_gradient(n);e.path.style.stroke="url(#"+o+")"}this.region_fill&&this.fill_region_for_dataset(e,i,n,r)}},{key:"fill_region_for_dataset",value:function(e,i,a,s){var n=this.make_gradient(a,!0);e.region_path=t.createSVG("path",{inside:this.paths_groups[i],className:"region-fill",d:"M0,"+this.zero_line+"L"+s+"L"+this.width+","+this.zero_line}),e.region_path.style.stroke="none",e.region_path.style.fill="url(#"+n+")"}},{key:"make_gradient",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a="path-fill-gradient-"+e,s=t.createSVG("linearGradient",{inside:this.svg_defs,id:a,x1:0,x2:0,y1:0,y2:1}),n=function(e,i,a,s){t.createSVG("stop",{className:"stop-color "+a,inside:e,offset:i,"stop-opacity":s})},r=[1,.6,.2];return i&&(r=[.4,.2,0]),n(s,"0%",e,r[0]),n(s,"50%",e,r[1]),n(s,"100%",e,r[2]),a}}]),i}(),b=function(t){function e(t){o(this,e);var i=u(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 c(e,y),l(e,[{key:"setup_graph_components",value:function(){this.setup_path_groups(),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setup_graph_components",this).call(this)}},{key:"setup_path_groups",value:function(){}},{key:"setup_values",value:function(){h(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}(),x=function(e){function i(t){o(this,i);var e=u(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.type="percentage",e.get_y_label=e.format_lambdas.y_label,e.get_x_tooltip=e.format_lambdas.x_tooltip,e.get_y_tooltip=e.format_lambdas.y_tooltip,e.max_slices=10,e.max_legend_points=6,e.colors=t.colors,(!e.colors||e.colors.length<e.data.labels.length)&&(e.colors=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta"]),e.setup(),e}return c(i,v),l(i,[{key:"make_chart_area",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"}},{key:"make_draw_area",value:function(){this.chart_div=t.create("div",{className:"div",inside:this.chart_wrapper}),this.chart=t.create("div",{className:"progress-chart",inside:this.chart_div})}},{key:"setup_components",value:function(){this.percentage_bar=t.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:"setup_utils",value:function(){}},{key:"make_graph_components",value:function(){var e=this;this.grand_total=this.slice_totals.reduce(function(t,e){return t+e},0),this.slices=[],this.slice_totals.map(function(i,a){var s=t.create("div",{className:"progress-bar background "+e.colors[a],inside:e.percentage_bar,styles:{width:100*i/e.grand_total+"%"}});e.slices.push(s)})}},{key:"bind_tooltip",value:function(){var e=this;this.slices.map(function(i,a){i.addEventListener("mouseenter",function(){var s=t.offset(e.chart_wrapper),n=t.offset(i),r=n.left-s.left+i.offsetWidth/2,o=n.top-s.top-6,l=(e.formatted_labels&&e.formatted_labels.length>0?e.formatted_labels[a]:e.labels[a])+": ",h=(100*e.slice_totals[a]/e.grand_total).toFixed(1);e.tip.set_values(r,o,l,h+"%"),e.tip.show_tip()})})}},{key:"show_summary",value:function(){var e=this,i=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(a,s){a&&(t.create("div",{className:"stats",inside:e.stats_wrapper}).innerHTML='<span class="indicator '+e.colors[s]+'">\n\t\t\t\t\t<span class="text-muted">'+i[s]+":</span>\n\t\t\t\t\t"+a+"\n\t\t\t\t</span>")})}}]),i}(),k=Math.PI/180,w=function(e){function i(t){o(this,i);var e=u(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.type="pie",e.get_y_label=e.format_lambdas.y_label,e.get_x_tooltip=e.format_lambdas.x_tooltip,e.get_y_tooltip=e.format_lambdas.y_tooltip,e.elements_to_animate=null,e.hoverRadio=t.hoverRadio||.1,e.max_slices=10,e.max_legend_points=6,e.isAnimate=!1,e.colors=t.colors,e.startAngle=t.startAngle||0,e.clockWise=t.clockWise||!1,(!e.colors||e.colors.length<e.data.labels.length)&&(e.colors=["#7cd6fd","#5e64ff","#743ee2","#ff5858","#ffa00a","#FEEF72","#28a745","#98d85b","#b554ff","#ffa3ef"]),e.mouseMove=e.mouseMove.bind(e),e.mouseLeave=e.mouseLeave.bind(e),e.setup(),e}return c(i,v),l(i,[{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:"setup_utils",value:function(){}},{key:"makeArcPath",value:function(t,e){var i=this.centerX,a=this.centerY,s=this.radius,n=this.clockWise;return"M"+i+" "+a+" L"+(i+t.x)+" "+(a+t.y)+" A "+s+" "+s+" 0 0 "+(n?1:0)+" "+(i+e.x)+" "+(a+e.y)+" z"}},{key:"make_graph_components",value:function(e){var a=this,s=this.radius,n=this.clockWise;this.grand_total=this.slice_totals.reduce(function(t,e){return t+e},0);var r=this.slicesProperties||[];this.slices=[],this.elements_to_animate=[],this.slicesProperties=[];var o=180-this.startAngle;this.slice_totals.map(function(l,h){var c=o,u=l/a.grand_total*360,_=n?-u:u,p=o+=_,d=i.getPositionByAngle(c,s),f=i.getPositionByAngle(p,s),v=e&&r[h],g=void 0,m=void 0;e?(g=v?v.startPosition:d,m=v?v.endPosition:d):(g=d,m=f);var y=a.makeArcPath(g,m),b=t.createSVG("path",{inside:a.draw_area,className:"pie-path",style:"transition:transform .3s;",d:y,fill:a.colors[h]});a.slices.push(b),a.slicesProperties.push({startPosition:d,endPosition:f,value:l,total:a.grand_total,startAngle:c,endAngle:p,angle:_}),e&&a.elements_to_animate.push([{unit:b,array:a.slices,index:a.slices.length-1},{d:a.makeArcPath(d,f)},650,"easein",null,{d:y}])}),e&&this.run_animation()}},{key:"run_animation",value:function(){var e=this;if(this.elements_to_animate&&0!==this.elements_to_animate.length){var i=t.runSVGAnimation(this.svg,this.elements_to_animate);this.svg.parentNode==this.chart_wrapper&&(this.chart_wrapper.removeChild(this.svg),this.chart_wrapper.appendChild(i)),setTimeout(function(){i.parentNode==e.chart_wrapper&&(e.chart_wrapper.removeChild(i),e.chart_wrapper.appendChild(e.svg))},650)}}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,a=this.hoverRadio,s=i.getPositionByAngle(t.startAngle+t.angle/2,e);return"translate3d("+s.x*a+"px,"+s.y*a+"px,0)"}},{key:"hoverSlice",value:function(e,i,a,n){if(e)if(a){t.transform(e,this.calTranslateByAngle(this.slicesProperties[i])),e.setAttribute("fill",s(this.colors[i],50));var r=t.offset(this.svg),o=n.pageX-r.left+10,l=n.pageY-r.top-10,h=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.labels[i])+": ",c=(100*this.slice_totals[i]/this.grand_total).toFixed(1);this.tip.set_values(o,l,h,c+"%"),this.tip.show_tip()}else t.transform(e,"translate3d(0,0,0)"),this.tip.hide_tip(),e.setAttribute("fill",this.colors[i])}},{key:"mouseMove",value:function(t){for(var e=t.target,i=this.curActiveSliceIndex,a=this.curActiveSlice,s=0;s<this.slices.length;s++)if(e===this.slices[s]){this.hoverSlice(a,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=s,this.hoverSlice(e,s,!0,t);break}}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}},{key:"bind_tooltip",value:function(){this.draw_area.addEventListener("mousemove",this.mouseMove),this.draw_area.addEventListener("mouseleave",this.mouseLeave)}},{key:"show_summary",value:function(){var e=this,i=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(a,s){a&&(t.create("div",{className:"stats",inside:e.stats_wrapper}).innerHTML='<span class="indicator">\n\t\t\t\t\t<i style="background-color:'+e.colors[s]+';"></i>\n\t\t\t\t\t<span class="text-muted">'+i[s]+":</span>\n\t\t\t\t\t"+a+"\n\t\t\t\t</span>")})}}],[{key:"getPositionByAngle",value:function(t,e){return{x:Math.sin(t*k)*e,y:Math.cos(t*k)*e}}}]),i}(),S=function(e){function i(t){var e=t.start,a=void 0===e?"":e,s=t.domain,n=void 0===s?"":s,r=t.subdomain,l=void 0===r?"":r,h=t.data,c=void 0===h?{}:h,_=t.discrete_domains,p=void 0===_?0:_,d=t.count_label,f=void 0===d?"":d;o(this,i);var v=u(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,arguments[0]));v.type="heatmap",v.domain=n,v.subdomain=l,v.data=c,v.discrete_domains=p,v.count_label=f;var g=new Date;return v.start=a||v.add_days(g,365),v.legend_colors=["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],v.translate_x=0,v.setup(),v}return c(i,v),l(i,[{key:"setup_base_values",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()&&this.add_days(this.first_week_start,-1*this.first_week_start.getDay()),7!==this.last_week_start.getDay()&&this.add_days(this.last_week_start,-1*this.last_week_start.getDay()),this.no_of_cols=this.get_weeks_between(this.first_week_start+"",this.last_week_start+"")+1}},{key:"set_width",value:function(){this.base_width=12*(this.no_of_cols+3),this.discrete_domains&&(this.base_width+=144)}},{key:"setup_components",value:function(){this.domain_label_group=t.createSVG("g",{className:"domain-label-group chart-label",inside:this.draw_area}),this.data_groups=t.createSVG("g",{className:"data-groups",inside:this.draw_area,transform:"translate(0, 20)"})}},{key:"setup_values",value:function(){this.domain_label_group.textContent="",this.data_groups.textContent="",this.distribution=this.get_distribution(this.data,this.legend_colors),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,s=0,n=new Date(e),r=this.get_week_squares_group(n,this.week_col),o=_(r,2);a=o[0],s=o[1],this.data_groups.appendChild(a),this.week_col+=1+parseInt(this.discrete_domains&&s),this.month_weeks[this.current_month]++,s&&(this.current_month=(this.current_month+1)%12,this.months.push(this.current_month+""),this.month_weeks[this.current_month]=1),this.add_days(e,7)}this.render_month_labels()}},{key:"get_week_squares_group",value:function(e,i){for(var a=0,s=0,n=t.createSVG("g",{className:"data-group",inside:this.data_groups}),r=0,o=0;o<7;o+=1,r+=12){var l=0,h=0,c=e.getTime()/1e3,u=Math.floor(c-c%86400).toFixed(1);this.data[u]&&(l=this.data[u],h=this.get_max_checkpoint(l,this.distribution)),this.data[Math.round(u)]&&(l=this.data[Math.round(u)],h=this.get_max_checkpoint(l,this.distribution)),t.createSVG("rect",{className:"day",inside:n,x:13+12*(i+s),y:r,width:10,height:10,fill:this.legend_colors[h],"data-date":this.get_dd_mm_yyyy(e),"data-value":l,"data-day":e.getDay()});var _=new Date(e);this.add_days(_,1),_.getMonth()-e.getMonth()&&(a=1,this.discrete_domains&&(s=1),this.month_start_points.push(13+12*(i+s))),e=_}return[n,a]}},{key:"render_month_labels",value:function(){var e=this;this.months.shift(),this.month_start_points.shift(),this.months.pop(),this.month_start_points.pop(),this.month_start_points.map(function(i,a){var s=e.month_names[e.months[a]].substring(0,3);t.createSVG("text",{className:"y-value-text",inside:e.domain_label_group,x:i+12,y:10,dy:".32em",innerHTML:s})})}},{key:"make_graph_components",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("-"),s=t.month_names[parseInt(a[1])-1].substring(0,3),n=t.chart_wrapper.getBoundingClientRect(),r=e.target.getBoundingClientRect(),o=parseInt(e.target.getAttribute("width")),l=r.left-n.left+(o+2)/2,h=r.top-n.top-(o+2)/2,c=i+" "+t.count_label,u=" on "+s+" "+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()}},{key:"get_distribution",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1],i=Object.keys(t).map(function(e){return t[e]}),a=Math.max.apply(Math,p(i)),s=1/(e.length-1),n=[];return e.map(function(t,e){var i=a*(s*e);n.push(i)}),n}},{key:"get_max_checkpoint",value:function(t,e){return e.filter(function(i,a){return 1===a?e[0]<t:i<=t}).length-1}},{key:"treat_as_utc",value:function(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}},{key:"get_dd_mm_yyyy",value:function(t){var e=t.getDate(),i=t.getMonth()+1;return[(e>9?"":"0")+e,(i>9?"":"0")+i,t.getFullYear()].join("-")}},{key:"get_weeks_between",value:function(t,e){return Math.ceil(this.get_days_between(t,e)/7)}},{key:"get_days_between",value:function(t,e){return(this.treat_as_utc(e)-this.treat_as_utc(t))/864e5}},{key:"add_days",value:function(t,e){t.setDate(t.getDate()+e)}},{key:"get_month_name",value:function(){}}]),i}(),N={line:y,bar:m,scatter:b,percentage:x,heatmap:S,pie:w},A=function t(e){return o(this,t),n(e.type,arguments[0])};return A}(); | ||
var Chart=function(){"use strict";function t(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function e(e,i,a,n,r,s){var o=t.createSVG("line",{x1:0,x2:0,y1:0,y2:e}),l=t.createSVG("text",{className:n,x:0,y:i,dy:".71em",innerHTML:a}),c=t.createSVG("g",{className:"tick "+r,transform:"translate("+s+", 0)"});return c.appendChild(o),c.appendChild(l),c}function i(e,i,a,n,r,s,o){var l=arguments.length>7&&void 0!==arguments[7]&&arguments[7],c=arguments.length>8&&void 0!==arguments[8]?arguments[8]:"",h=t.createSVG("line",{className:"dashed"===c?"dashed":"",x1:e,x2:i,y1:0,y2:0}),u=t.createSVG("text",{className:r,x:a,y:0,dy:".32em",innerHTML:n+""}),p=t.createSVG("g",{className:"tick "+s,transform:"translate(0, "+o+")","stroke-opacity":1});return l&&(h.style.stroke="rgba(27, 31, 35, 0.6)"),p.appendChild(h),p.appendChild(u),p}function a(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,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){var c=void 0;c="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var h=r[l]||t.getAttribute(l),u=e[l],p={attributeName:l,from:h,to:u,begin:"0s",dur:i/1e3+"s",values:h+";"+u,keySplines:j[a],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};n&&(p.type=n);for(var _ in p)c.setAttribute(_,p[_]);s.appendChild(c),n?o.setAttribute(l,"translate("+u+")"):o.setAttribute(l,u)}return[s,o]}function n(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function r(t,e){var i=[],n=[];e.map(function(t){var e=t[0],r=e.unit.parentNode,s=void 0,o=void 0;t[0]=e.unit;var l=a.apply(void 0,z(t)),c=P(l,2);s=c[0],o=c[1],i.push(o),n.push([s,r]),r.replaceChild(s,e.unit),e.array?e.array[e.index]=o:e.object[e.key]=o});var r=t.cloneNode(!0);return n.map(function(t,a){t[1].replaceChild(i[a],t[0]),e[a][0]=i[a]}),r}function s(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 o(t,e){return t}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),a=Math.floor(e),n=i-a,r=n,s=1;n>5&&(n%2!=0&&(n=++i-a),r=n/2,s=2),n<=2&&(s=n/(r=4));for(var o=[],l=0;l<=r;l++)o.push(a+s*l);return o}function c(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=s(t),a=P(i,2),n=a[0],r=a[1],o=e?e/Math.pow(10,r):0,c=l(n=n.toFixed(6),o);return c=c.map(function(t){return t*Math.pow(10,r)})}function h(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=Math.max.apply(Math,z(t)),a=Math.min.apply(Math,z(t)),n=0,r=[];if(i>=0&&a>=0&&(n=s(i)[1],r=e?c(i,a):c(i)),i>0&&a<0){var l=function(t,e){for(var i=c(t),a=i[1]-i[0],n=0,r=1;n<e;r++)n+=a,i.unshift(-1*n);return i},h=Math.abs(a);i>=h?(n=s(i)[1],r=l(i,h)):(n=s(h)[1],r=l(h,i).map(function(t){return-1*t}))}if(i<=0&&a<=0){var u=Math.abs(a),p=Math.abs(i);n=s(u)[1],r=(r=e?c(u,p):c(u)).reverse().map(function(t){return-1*t})}return r=r.map(function(t){return o(t,n)})}function u(t,e){for(var i=Math.max.apply(Math,z(t)),a=1/(e-1),n=[],r=0;r<e;r++){var s=i*(a*r);n.push(s)}return n}function p(t,e){return e.filter(function(e){return e<t}).length}function _(t){return parseFloat(t.toFixed(2))}function d(t,e){if(t.length!==e.length)return!1;var i=!0;return t.map(function(t,a){e[a]!==t&&(i=!1)}),i}function f(t,e){return(t+"").length*e}function v(t){return t>255?255:t<0?0:t}function g(t,e){var i=!1;"#"==t[0]&&(t=t.slice(1),i=!0);var a=parseInt(t,16),n=v((a>>16)+e),r=v((a>>8&255)+e),s=v((255&a)+e);return(i?"#":"")+(s|r<<8|n<<16).toString(16)}function m(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}function y(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function x(t){var e=t.getDate(),i=t.getMonth()+1;return[(e>9?"":"0")+e,(i>9?"":"0")+i,t.getFullYear()].join("-")}function b(t,e){return Math.ceil(k(t,e)/7)}function k(t,e){return(y(e)-y(t))/864e5}function w(t,e){t.setDate(t.getDate()+e)}function S(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1];return W[t]?new W[t](e):new F(e)}!function(t,e){if("undefined"==typeof document)return e;t=t||"";var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",i.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}('.chart-container{font-family:Roboto,Geneva,Tahoma,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;bottom:-10px;left:50%;width:5px;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-right:after,.chart-container .indicator:before,.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}.chart-container .background.grey,.chart-container .indicator-right.grey:after,.chart-container .indicator.grey:before,.chart-container .indicator.grey i{background:#bdd3e6}.chart-container .background.light-grey,.chart-container .indicator-right.light-grey:after,.chart-container .indicator.light-grey:before,.chart-container .indicator.light-grey i{background:#f0f4f7}.chart-container .background.blue,.chart-container .indicator-right.blue:after,.chart-container .indicator.blue:before,.chart-container .indicator.blue i{background:#5e64ff}.chart-container .background.red,.chart-container .indicator-right.red:after,.chart-container .indicator.red:before,.chart-container .indicator.red i{background:#ff5858}.chart-container .background.green,.chart-container .indicator-right.green:after,.chart-container .indicator.green:before,.chart-container .indicator.green i{background:#28a745}.chart-container .background.light-green,.chart-container .indicator-right.light-green:after,.chart-container .indicator.light-green:before,.chart-container .indicator.light-green i{background:#98d85b}.chart-container .background.orange,.chart-container .indicator-right.orange:after,.chart-container .indicator.orange:before,.chart-container .indicator.orange i{background:#ffa00a}.chart-container .background.violet,.chart-container .indicator-right.violet:after,.chart-container .indicator.violet:before,.chart-container .indicator.violet i{background:#743ee2}.chart-container .background.dark-grey,.chart-container .indicator-right.dark-grey:after,.chart-container .indicator.dark-grey:before,.chart-container .indicator.dark-grey i{background:#b8c2cc}.chart-container .background.black,.chart-container .indicator-right.black:after,.chart-container .indicator.black:before,.chart-container .indicator.black i{background:#36414c}.chart-container .background.yellow,.chart-container .indicator-right.yellow:after,.chart-container .indicator.yellow:before,.chart-container .indicator.yellow i{background:#feef72}.chart-container .background.light-blue,.chart-container .indicator-right.light-blue:after,.chart-container .indicator.light-blue:before,.chart-container .indicator.light-blue i{background:#7cd6fd}.chart-container .background.purple,.chart-container .indicator-right.purple:after,.chart-container .indicator.purple:before,.chart-container .indicator.purple i{background:#b554ff}.chart-container .background.magenta,.chart-container .indicator-right.magenta:after,.chart-container .indicator.magenta:before,.chart-container .indicator.magenta i{background:#ffa3ef}.chart-container .stroke.grey{stroke:#bdd3e6}.chart-container .stroke.light-grey{stroke:#f0f4f7}.chart-container .stroke.blue{stroke:#5e64ff}.chart-container .stroke.red{stroke:#ff5858}.chart-container .stroke.light-green{stroke:#98d85b}.chart-container .stroke.green{stroke:#28a745}.chart-container .stroke.orange{stroke:#ffa00a}.chart-container .stroke.violet{stroke:#743ee2}.chart-container .stroke.dark-grey{stroke:#b8c2cc}.chart-container .stroke.black{stroke:#36414c}.chart-container .stroke.yellow{stroke:#feef72}.chart-container .stroke.light-blue{stroke:#7cd6fd}.chart-container .stroke.purple{stroke:#b554ff}.chart-container .stroke.magenta{stroke:#ffa3ef}.chart-container .fill.grey{fill:#bdd3e6}.chart-container .fill.light-grey{fill:#f0f4f7}.chart-container .fill.blue{fill:#5e64ff}.chart-container .fill.red{fill:#ff5858}.chart-container .fill.light-green{fill:#98d85b}.chart-container .fill.green{fill:#28a745}.chart-container .fill.orange{fill:#ffa00a}.chart-container .fill.violet{fill:#743ee2}.chart-container .fill.dark-grey{fill:#b8c2cc}.chart-container .fill.black{fill:#36414c}.chart-container .fill.yellow{fill:#feef72}.chart-container .fill.light-blue{fill:#7cd6fd}.chart-container .fill.purple{fill:#b554ff}.chart-container .fill.magenta{fill:#ffa3ef}.chart-container .border-top.grey{border-top:3px solid #bdd3e6}.chart-container .border-top.light-grey{border-top:3px solid #f0f4f7}.chart-container .border-top.blue{border-top:3px solid #5e64ff}.chart-container .border-top.red{border-top:3px solid #ff5858}.chart-container .border-top.light-green{border-top:3px solid #98d85b}.chart-container .border-top.green{border-top:3px solid #28a745}.chart-container .border-top.orange{border-top:3px solid #ffa00a}.chart-container .border-top.violet{border-top:3px solid #743ee2}.chart-container .border-top.dark-grey{border-top:3px solid #b8c2cc}.chart-container .border-top.black{border-top:3px solid #36414c}.chart-container .border-top.yellow{border-top:3px solid #feef72}.chart-container .border-top.light-blue{border-top:3px solid #7cd6fd}.chart-container .border-top.purple{border-top:3px solid #b554ff}.chart-container .border-top.magenta{border-top:3px solid #ffa3ef}.chart-container .stop-color.grey{stop-color:#bdd3e6}.chart-container .stop-color.light-grey{stop-color:#f0f4f7}.chart-container .stop-color.blue{stop-color:#5e64ff}.chart-container .stop-color.red{stop-color:#ff5858}.chart-container .stop-color.light-green{stop-color:#98d85b}.chart-container .stop-color.green{stop-color:#28a745}.chart-container .stop-color.orange{stop-color:#ffa00a}.chart-container .stop-color.violet{stop-color:#743ee2}.chart-container .stop-color.dark-grey{stop-color:#b8c2cc}.chart-container .stop-color.black{stop-color:#36414c}.chart-container .stop-color.yellow{stop-color:#feef72}.chart-container .stop-color.light-blue{stop-color:#7cd6fd}.chart-container .stop-color.purple{stop-color:#b554ff}.chart-container .stop-color.magenta{stop-color:#ffa3ef}',void 0);var N="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},M=(function(){function t(t){this.value=t}function e(e){function i(n,r){try{var s=e[n](r),o=s.value;o instanceof t?Promise.resolve(o.value).then(function(t){i("next",t)},function(t){i("throw",t)}):a(s.done?"return":"normal",s.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}var n,r;this._invoke=function(t,e){return new Promise(function(a,s){var o={key:t,arg:e,resolve:a,reject:s,next:null};r?r=r.next=o:(n=r=o,i(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"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)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),A=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}}(),C=function t(e,i,a){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,i);if(void 0===n){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,a)}if("value"in n)return n.value;var s=n.get;if(void 0!==s)return s.call(a)},O=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)},T=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},P=function(){function t(t,e){var i=[],a=!0,n=!1,r=void 0;try{for(var s,o=t[Symbol.iterator]();!(a=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);a=!0);}catch(t){n=!0,r=t}finally{try{!a&&o.return&&o.return()}finally{if(n)throw r}}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")}}(),z=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)};t.findNodeIndex=function(t){for(var e=0;t.previousSibling;)t=t.previousSibling,e++;return e},t.create=function(e,i){var a=document.createElement(e);for(var n in i){var r=i[n];if("inside"===n)t(r).appendChild(a);else if("around"===n){var s=t(r);s.parentNode.insertBefore(a,s),a.appendChild(s)}else"styles"===n?"object"===(void 0===r?"undefined":N(r))&&Object.keys(r).map(function(t){a.style[t]=r[t]}):n in a?a[n]=r:a.setAttribute(n,r)}return a},t.createSVG=function(e,i){var a=document.createElementNS("http://www.w3.org/2000/svg",e);for(var n in i){var r=i[n];if("inside"===n)t(r).appendChild(a);else if("around"===n){var s=t(r);s.parentNode.insertBefore(a,s),a.appendChild(s)}else"className"===n&&(n="class"),"innerHTML"===n?a.textContent=r:a.setAttribute(n,r)}return a},t.offset=function(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}},t.isElementInViewport=function(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)},t.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)})}},t.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)})}},t.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 L=function(){function e(t,e,i){var a=void 0,n=void 0;return t<=e?(n=t,0===(a=e-t)&&(n-=a=.01*i)):(n=e,0===(a=t-e)&&(a=.01*i)),[a,n]}var i=function(t,e,i){this.total_height=t,this.zero_line=e,this.avg_unit_width=i};return i.prototype={draw_bar:function(i,a,n,r,s,o,l){var c=this.avg_unit_width-n.space_width,h=c/l,u=i-c/2+h*o,p=e(a,this.zero_line,this.total_height),_=P(p,2),d=_[0],f=_[1];return t.createSVG("rect",{className:"bar mini fill "+r,"data-point-index":s,x:u,y:f,width:h,height:d})},draw_dot:function(e,i,a,n,r){return t.createSVG("circle",{className:"fill "+n,"data-point-index":r,cx:e,cy:i,r:a.radius})},animate_bar:function(t,i,a,n,r){var s=i-this.avg_unit_width/4,o=this.avg_unit_width/2/r,l=e(a,this.zero_line,this.total_height),c=P(l,2);return i=s+o*n,[t,{width:o,height:c[0],x:i,y:c[1]},350,"easein"]},animate_dot:function(t,e,i){return[t,{cx:e,cy:i},350,"easein"]}},i}(),j={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"},E=function(){function e(t){var i=t.parent,a=void 0===i?null:i;M(this,e),this.parent=a,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 A(e,[{key:"setup",value:function(){this.make_tooltip()}},{key:"refresh",value:function(){this.fill(),this.calc_position()}},{key:"make_tooltip",value:function(){var e=this;this.container=t.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(){e.hide_tip()})}},{key:"fill",value:function(){var e=this,i=void 0;i=this.title_value_first?"<strong>"+this.title_value+"</strong>"+this.title_name:this.title_name+"<strong>"+this.title_value+"</strong>",this.title.innerHTML=i,this.data_point_list.innerHTML="",this.list_values.map(function(i){var a=t.create("li",{className:"border-top "+(i.color||"black"),innerHTML:'<strong style="display: block;">'+(0===i.value||i.value?i.value:"")+"</strong>\n\t\t\t\t\t"+(i.title?i.title:"")});e.data_point_list.appendChild(a)})}},{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]:[],r=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=r,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"}}]),e}(),V=function(){function e(t){var i=t.height,a=void 0===i?240:i,n=t.title,r=void 0===n?"":n,s=t.subtitle,o=void 0===s?"":s,l=t.colors,c=void 0===l?[]:l,h=t.summary,u=void 0===h?[]:h,p=t.is_navigable,_=void 0===p?0:p,d=t.has_legend,f=void 0===d?0:d,v=(t.type,t.parent),g=t.data;M(this,e),this.raw_chart_args=arguments[0],this.parent="string"==typeof v?document.querySelector(v):v,this.title=r,this.subtitle=o,this.data=g,this.specific_values=g.specific_values||[],this.summary=u,this.is_navigable=_,this.is_navigable&&(this.current_index=0),this.has_legend=f,this.colors=c,(!this.colors||this.data.labels&&this.colors.length<this.data.labels.length)&&(this.colors=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta"]),this.chart_types=["line","scatter","bar","percentage","heatmap","pie"],this.set_margins(a)}return A(e,[{key:"get_different_chart",value:function(t){if(this.chart_types.includes(t)||console.error("'"+t+"' is not a valid chart type."),t!==this.type){return{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:[]}[this.type].includes(t)||console.error("'"+this.type+"' chart cannot be converted to a '"+t+"' chart."),new Y({parent:this.raw_chart_args.parent,title:this.title,data:this.raw_chart_args.data,type:t,height:this.raw_chart_args.height})}}},{key:"set_margins",value:function(t){this.base_height=t,this.height=t-40,this.translate_x=60,this.translate_y=10}},{key:"setup",value:function(){this.parent?(this.bind_window_events(),this.refresh(!0)):console.error("No parent element to render on was provided.")}},{key:"bind_window_events",value:function(){var t=this;window.addEventListener("resize",function(){return t.refresh()}),window.addEventListener("orientationchange",function(){return t.refresh()})}},{key:"refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.setup_base_values(),this.set_width(),this.setup_container(),this.setup_components(),this.setup_values(),this.setup_utils(),this.make_graph_components(t),this.make_tooltip(),this.summary.length>0?this.show_custom_summary():this.show_summary(),this.is_navigable&&this.setup_navigation(t)}},{key:"set_width",value:function(){var t=0;this.specific_values.map(function(e){var i=f(e.title+"",8);i>t&&(t=i-40)}),this.base_width=this.parent.offsetWidth-t,this.width=this.base_width-2*this.translate_x}},{key:"setup_base_values",value:function(){}},{key:"setup_container",value:function(){this.container=t.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"),this.make_chart_area(),this.make_draw_area()}},{key:"make_chart_area",value:function(){return this.svg=t.createSVG("svg",{className:"chart",inside:this.chart_wrapper,width:this.base_width,height:this.base_height}),this.svg_defs=t.createSVG("defs",{inside:this.svg}),this.svg}},{key:"make_draw_area",value:function(){this.draw_area=t.createSVG("g",{className:this.type+"-chart",inside:this.svg,transform:"translate("+this.translate_x+", "+this.translate_y+")"})}},{key:"setup_components",value:function(){}},{key:"make_tooltip",value:function(){this.tip=new E({parent:this.chart_wrapper}),this.bind_tooltip()}},{key:"show_summary",value:function(){}},{key:"show_custom_summary",value:function(){var e=this;this.summary.map(function(i){var a=t.create("div",{className:"stats",innerHTML:'<span class="indicator '+i.color+'">'+i.title+": "+i.value+"</span>"});e.stats_wrapper.appendChild(a)})}},{key:"setup_navigation",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.make_overlay(),i&&(this.bind_overlay(),document.addEventListener("keydown",function(i){t.isElementInViewport(e.chart_wrapper)&&("37"==(i=i||window.event).keyCode?e.on_left_arrow():"39"==i.keyCode?e.on_right_arrow():"38"==i.keyCode?e.on_up_arrow():"40"==i.keyCode?e.on_down_arrow():"13"==i.keyCode&&e.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:"get_data_point",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","y_tops","values"].map(function(a){var n=a.slice(0,a.length-1);e[n]=i[a][t]}),e.label=this.x[t],e}},{key:"update_current_data_point",value:function(e){(e=parseInt(e))<0&&(e=0),e>=this.x.length&&(e=this.x.length-1),e!==this.current_index&&(this.current_index=e,t.fire(this.parent,"data-select",this.get_data_point()))}},{key:"setup_utils",value:function(){}}]),e}(),G=function(a){function n(t){M(this,n);var e=T(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t));return e.x=e.data.labels,e.y=e.data.datasets,e.is_series=t.is_series,e.format_tooltip_y=t.format_tooltip_y,e.format_tooltip_x=t.format_tooltip_x,e.zero_line=e.height,e.old_values={},e}return O(n,V),A(n,[{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.x_axis_positions&&(this.x_old_axis_positions=this.x_axis_positions.slice()),this.x_axis_positions=this.x.map(function(e,i){return _(t.x_offset+i*t.avg_unit_width)}),this.x_old_axis_positions||(this.x_old_axis_positions=this.x_axis_positions.slice())}},{key:"setup_y",value:function(){this.y_axis_values&&(this.y_old_axis_values=this.y_axis_values.slice());var t=this.get_all_y_values();this.y_sums&&this.y_sums.length>0&&(t=t.concat(this.y_sums)),this.y_axis_values=h(t,"line"===this.type),this.y_old_axis_values||(this.y_old_axis_values=this.y_axis_values.slice());var e=this.y_axis_values,i=e[e.length-1]-e[0];this.multiplier&&(this.old_multiplier=this.multiplier),this.multiplier=this.height/i,this.old_multiplier||(this.old_multiplier=this.multiplier);var a=e[1]-e[0],n=a*this.multiplier,r=void 0;r=e.indexOf(0)>=0?e.indexOf(0):e[0]>0?-1*e[0]/a:-1*e[e.length-1]/a+(e.length-1),this.zero_line&&(this.old_zero_line=this.zero_line),this.zero_line=this.height-r*n,this.old_zero_line||(this.old_zero_line=this.zero_line)}},{key:"setup_components",value:function(){C(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_components",this).call(this),this.setup_marker_components(),this.setup_aggregation_components(),this.setup_graph_components()}},{key:"setup_marker_components",value:function(){this.y_axis_group=t.createSVG("g",{className:"y axis",inside:this.draw_area}),this.x_axis_group=t.createSVG("g",{className:"x axis",inside:this.draw_area}),this.specific_y_group=t.createSVG("g",{className:"specific axis",inside:this.draw_area})}},{key:"setup_aggregation_components",value:function(){this.sum_group=t.createSVG("g",{className:"data-points",inside:this.draw_area}),this.average_group=t.createSVG("g",{className:"chart-area",inside:this.draw_area})}},{key:"setup_graph_components",value:function(){var e=this;this.svg_units_groups=[],this.y.map(function(i,a){e.svg_units_groups[a]=t.createSVG("g",{className:"data-points data-points-"+a,inside:e.draw_area})})}},{key:"make_graph_components",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.make_y_axis(),this.make_x_axis(),this.draw_graph(t),this.make_y_specifics()}},{key:"make_x_axis",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=void 0,n=void 0,r=void 0,s="";if("span"===this.x_axis_mode?(a=-7,n=this.height+15,r=this.height+25):"tick"===this.x_axis_mode&&(a=this.height,n=6,r=9,s="x-axis-label"),this.x_axis_group.setAttribute("transform","translate(0,"+a+")"),i)this.make_anim_x_axis(n,r,s);else{var o=1.5*this.avg_unit_width,l=o/8;this.x_axis_group.textContent="",this.x.map(function(i,a){var c=f(i,8)+2;if(c>o)if(t.is_series){for(var h=1;c/h*2>o;)h++;if(a%h!=0)return}else i=i.slice(0,l-3)+" ...";t.x_axis_group.appendChild(e(n,r,i,"x-value-text",s,t.x_axis_positions[a]))})}}},{key:"make_y_axis",value:function(){var t=this;if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return this.make_anim_y_axis(),void this.make_anim_y_specifics();var e=this.get_y_axis_line_props(),a=P(e,4),n=a[0],r=a[1],s=a[2],o=a[3];this.y_axis_group.textContent="",this.y_axis_values.map(function(e,a){t.y_axis_group.appendChild(i(o,n,r,e,"y-value-text",s,t.zero_line-e*t.multiplier,0===e&&0!==a))})}},{key:"get_y_axis_line_props",value:function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return[this.width,this.width+5,"specific-value",0];var t=void 0,e="",i=0;return"span"===this.y_axis_mode?(t=this.width+6,i=-6):"tick"===this.y_axis_mode&&(t=-6,e="y-axis-label"),[t,-9,e,i]}},{key:"draw_graph",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];!this.raw_chart_args.hasOwnProperty("init")||this.raw_chart_args.init?e?this.draw_new_graph_and_animate():this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i)}):this.y.map(function(e,i){e.svg_units=[],t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i),t.calc_y_dependencies()})}},{key:"draw_new_graph_and_animate",value:function(){var t=this,e=[];this.y.map(function(i,a){i.y_tops=new Array(i.values.length).fill(t.zero_line),e.push({values:i.values}),i.svg_units=[],t.make_path&&t.make_path(i,a,t.x_axis_positions,i.y_tops,i.color||t.colors[a]),t.make_new_units(i,a)}),setTimeout(function(){t.update_values(e)},350)}},{key:"setup_navigation",value:function(t){var e=this;t?setTimeout(function(){C(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_navigation",e).call(e,t)},500):C(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_navigation",this).call(this,t)}},{key:"make_new_units",value:function(t,e){this.make_new_units_for_dataset(this.x_axis_positions,t.y_tops,t.color||this.colors[e],e,this.y.length)}},{key:"make_new_units_for_dataset",value:function(t,e,i,a,n,r,s,o){r||(r=this.svg_units_groups[a]),s||(s=this.y[a].svg_units),o||(o=this.unit_args),r.textContent="",s.length=0;var l=new L(this.height,this.zero_line,this.avg_unit_width);e.map(function(e,c){var h=l["draw_"+o.type](t[c],e,o.args,i,c,a,n);r.appendChild(h),s.push(h)}),this.is_navigable&&this.bind_units(s)}},{key:"make_y_specifics",value:function(){var t=this;this.specific_y_group.textContent="",this.specific_values.map(function(e){t.specific_y_group.appendChild(i(0,t.width,t.width+5,e.title.toUpperCase(),"specific-value","specific-value",t.zero_line-e.value*t.multiplier,!1,e.line_type))})}},{key:"bind_tooltip",value:function(){var e=this;this.chart_wrapper.addEventListener("mousemove",function(i){var a=t.offset(e.chart_wrapper),n=i.pageX-a.left-e.translate_x;i.pageY-a.top-e.translate_y<e.height+2*e.translate_y?e.map_tooltip_x_position_and_show(n):e.tip.hide_tip()})}},{key:"map_tooltip_x_position_and_show",value:function(t){var e=this;if(this.y_min_tops){var i=this.x;this.format_tooltip_x&&this.format_tooltip_x(this.x[0])&&(i=this.x.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.x_axis_positions.length-1;n>=0;n--){var r=this.x_axis_positions[n];if(t>r-this.avg_unit_width/2){var s=r+this.translate_x,o=this.y_min_tops[n]+this.translate_y,l=i[n],c=this.y.map(function(t,i){return{title:t.title,value:a?e.format_tooltip_y(t.values[n]):t.values[n],color:t.color||e.colors[i]}});this.tip.set_values(s,o,l,"",c),this.tip.show_tip();break}}}}},{key:"show_sums",value:function(){var t=this;this.updating=!0,this.y_sums=new Array(this.x_axis_positions.length).fill(0),this.y.map(function(e){e.values.map(function(e,i){t.y_sums[i]+=e})}),this.update_values(),this.sum_units=[],this.make_new_units_for_dataset(this.x_axis_positions,this.y_sums.map(function(e){return _(t.zero_line-e*t.multiplier)}),"light-grey",0,1,this.sum_group,this.sum_units),this.updating=!1}},{key:"hide_sums",value:function(){this.updating||(this.y_sums=[],this.sum_group.textContent="",this.sum_units=[],this.update_values())}},{key:"show_averages",value:function(){var t=this;this.old_specific_values=this.specific_values.slice(),this.y.map(function(e,i){var a=0;e.values.map(function(t){a+=t});var n=a/e.values.length;t.specific_values.push({title:"AVG "+(i+1),line_type:"dashed",value:n,auto:1})}),this.update_values()}},{key:"hide_averages",value:function(){var t=this;this.old_specific_values=this.specific_values.slice();var e=[];this.specific_values.map(function(t,i){t.auto&&e.unshift(i)}),e.map(function(e){t.specific_values.splice(e,1)}),this.update_values()}},{key:"update_values",value:function(t,e){var i=this;e||(e=this.x),this.elements_to_animate=[],this.updating=!0,this.old_x_values=this.x.slice(),this.old_y_axis_tops=this.y.map(function(t){return t.y_tops.slice()}),this.old_y_values=this.y.map(function(t){return t.values}),this.no_of_extra_pts=e.length-this.x.length,t&&this.y.map(function(e,i){e.values=t[i].values}),e&&(this.x=e),this.setup_x(),this.setup_y(),d(this.x_old_axis_positions,this.x_axis_positions)||(this.make_x_axis(!0),setTimeout(function(){i.updating||i.make_x_axis()},350)),(!d(this.y_old_axis_values,this.y_axis_values)||this.old_specific_values&&!d(this.old_specific_values,this.specific_values))&&(this.make_y_axis(!0),setTimeout(function(){i.updating||(i.make_y_axis(),i.make_y_specifics())},350)),this.calc_y_dependencies(),this.animate_graphs(),this.run_animation(),this.updating=!1}},{key:"add_data_point",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.x.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.x.slice();n.splice(i,0,e),this.update_values(a,n)}},{key:"remove_data_point",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.x.length-1;if(!(this.x.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.x.slice();i.splice(t,1),this.update_values(e,i)}}},{key:"run_animation",value:function(){var t=this,e=r(this.svg,this.elements_to_animate);this.svg.parentNode==this.chart_wrapper&&(this.chart_wrapper.removeChild(this.svg),this.chart_wrapper.appendChild(e)),setTimeout(function(){e.parentNode==t.chart_wrapper&&(t.chart_wrapper.removeChild(e),t.chart_wrapper.appendChild(t.svg))},250)}},{key:"animate_graphs",value:function(){var t=this;this.y.map(function(e,i){var a=t.calc_old_and_new_postions(e,i),n=P(a,4),r=n[0],s=n[1],o=n[2],l=n[3];t.no_of_extra_pts>=0&&(t.make_path&&t.make_path(e,i,r,s,e.color||t.colors[i]),t.make_new_units_for_dataset(r,s,e.color||t.colors[i],i,t.y.length)),e.path&&t.animate_path(e,i,r,s,o,l),t.animate_units(e,i,r,s,o,l)}),setTimeout(function(){t.y.map(function(e,i){t.make_path&&t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i]),t.make_new_units(e,i)})},400)}},{key:"animate_path",value:function(t,e,i,a,n,r){var s=r.map(function(t,e){return n[e]+","+t}).join("L"),o=[{unit:t.path,object:t,key:"path"},{d:"M"+s},350,"easein"];if(this.elements_to_animate.push(o),t.region_path){var l="0,"+this.zero_line+"L",c="L"+this.width+","+this.zero_line,h=[{unit:t.region_path,object:t,key:"region_path"},{d:"M"+l+s+c},350,"easein"];this.elements_to_animate.push(h)}}},{key:"animate_units",value:function(t,e,i,a,n,r){var s=this,o=this.unit_args.type,l=new L(this.height,this.zero_line,this.avg_unit_width);t.svg_units.map(function(i,a){void 0!==n[a]&&void 0!==r[a]&&s.elements_to_animate.push(l["animate_"+o]({unit:i,array:t.svg_units,index:a},n[a],r[a],e,s.y.length))})}},{key:"calc_old_and_new_postions",value:function(t,e){var i=this.x_old_axis_positions.slice(),a=this.x_axis_positions.slice(),n=this.old_y_axis_tops[e].slice(),r=t.y_tops.slice(),s=i[i.length-1],o=n[n.length-1],l=a[a.length-1],c=r[r.length-1];if(this.no_of_extra_pts>=0){var h=new Array(Math.abs(this.no_of_extra_pts)).fill(s),u=new Array(Math.abs(this.no_of_extra_pts)).fill(o);i=i.concat(h),n=n.concat(u)}else{var p=new Array(Math.abs(this.no_of_extra_pts)).fill(l),_=new Array(Math.abs(this.no_of_extra_pts)).fill(c);a=a.concat(p),r=r.concat(_)}return[i,n,a,r]}},{key:"make_anim_x_axis",value:function(t,i,a){var n=this,r=this.x_old_axis_positions,s=this.x_axis_positions,o=this.old_x_values,l=this.x,c=r[r.length-1];this.x_axis_group.textContent="",this.make_new_axis_anim_lines(r,s,o,l,c,function(r,s,o){"string"==typeof o&&(o=parseInt(o.substring(0,o.length-1)));var l=e(t,i,r,"x-value-text",a,s);n.x_axis_group.appendChild(l),n.elements_to_animate&&n.elements_to_animate.push([{unit:l,array:[0],index:0},{transform:o+", 0"},350,"easein","translate",{transform:s+", 0"}])})}},{key:"make_anim_y_axis",value:function(){var t=this,e=this.y_old_axis_values.map(function(e){return t.zero_line-e*t.multiplier}),i=this.y_axis_values.map(function(e){return t.zero_line-e*t.multiplier}),a=this.y_old_axis_values,n=this.y_axis_values,r=e[e.length-1];this.y_axis_group.textContent="",this.make_new_axis_anim_lines(e,i,a,n,r,this.add_and_animate_y_line.bind(this),this.y_axis_group)}},{key:"make_anim_y_specifics",value:function(){var t=this;this.specific_y_group.textContent="",this.specific_values.map(function(e){t.add_and_animate_y_line(e.title,t.old_zero_line-e.value*t.old_multiplier,t.zero_line-e.value*t.multiplier,0,t.specific_y_group,e.line_type,!0)})}},{key:"make_new_axis_anim_lines",value:function(t,e,i,a,n,r,s){var o=void 0,l=void 0,c=a.length-i.length;if(c>0)o=e.slice(0,t.length),l=a.slice(0,i.length);else{var h=new Array(Math.abs(c)).fill("");l=a.concat(h);var u=new Array(Math.abs(c)).fill(n+"F");o=e.concat(u)}if(l.map(function(e,i){r(e,t[i],o[i],i,s)}),c>0){var p=a.slice(i.length),_=e.slice(t.length);p.map(function(t,e){r(t,n,_[e],e,s)})}}},{key:"add_and_animate_y_line",value:function(t,e,a,n,r,s){var o=arguments.length>6&&void 0!==arguments[6]&&arguments[6],l=!1;"string"==typeof a&&(a=parseInt(a.substring(0,a.length-1)),l=!0);var c={transform:"0, "+a},h={transform:"0, "+e};l&&(c["stroke-opacity"]=0);var u=this.get_y_axis_line_props(o),p=P(u,4),_=p[0],d=p[1],f=p[2],v=p[3],g=o?"specific-value":"y-value-text",m=i(v,_,d,t=o?(t+"").toUpperCase():t,g,f,e,0===t&&0!==n,s);r.appendChild(m),this.elements_to_animate&&this.elements_to_animate.push([{unit:m,array:[0],index:0},c,350,"easein","translate",h])}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.x.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:"calc_y_dependencies",value:function(){var t=this;this.y_min_tops=new Array(this.x_axis_positions.length).fill(9999),this.y.map(function(e){e.y_tops=e.values.map(function(e){return _(t.zero_line-e*t.multiplier)}),e.y_tops.map(function(e,i){e<t.y_min_tops[i]&&(t.y_min_tops[i]=e)})})}}]),n}(),D=function(t){function e(t){M(this,e);var i=T(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 O(e,G),A(e,[{key:"setup_values",value:function(){C(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:{space_width:this.avg_unit_width/2}}}},{key:"make_overlay",value:function(){var t=this.x.length-1,e=this.y[0].svg_units[t];this.update_current_data_point(t),this.overlay&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=e.cloneNode(),this.overlay.style.fill="#000000",this.overlay.style.opacity="0.4",this.draw_area.appendChild(this.overlay)}},{key:"bind_overlay",value:function(){var t=this;this.parent.addEventListener("data-select",function(e){t.update_overlay(e.svg_unit)})}},{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.update_current_data_point(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)})}},{key:"on_left_arrow",value:function(){this.update_current_data_point(this.current_index-1)}},{key:"on_right_arrow",value:function(){this.update_current_data_point(this.current_index+1)}},{key:"set_avg_unit_width_and_x_offset",value:function(){this.avg_unit_width=this.width/(this.x.length+1),this.x_offset=this.avg_unit_width}}]),e}(),F=function(e){function i(t){M(this,i);var e=T(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.x_axis_mode=t.x_axis_mode||"span",e.y_axis_mode=t.y_axis_mode||"span",t.hasOwnProperty("show_dots")?e.show_dots=t.show_dots:e.show_dots=1,e.region_fill=t.region_fill,Object.getPrototypeOf(e)!==i.prototype?T(e):(e.dot_radius=t.dot_radius||4,e.heatline=t.heatline,e.type="line",e.setup(),e)}return O(i,G),A(i,[{key:"setup_graph_components",value:function(){this.setup_path_groups(),C(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_graph_components",this).call(this)}},{key:"setup_path_groups",value:function(){var e=this;this.paths_groups=[],this.y.map(function(i,a){e.paths_groups[a]=t.createSVG("g",{className:"path-group path-group-"+a,inside:e.draw_area})})}},{key:"setup_values",value:function(){C(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_values",this).call(this),this.unit_args={type:"dot",args:{radius:this.dot_radius}}}},{key:"make_new_units_for_dataset",value:function(t,e,a,n,r,s,o,l){this.show_dots&&C(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"make_new_units_for_dataset",this).call(this,t,e,a,n,r,s,o,l)}},{key:"make_paths",value:function(){var t=this;this.y.map(function(e,i){t.make_path(e,i,t.x_axis_positions,e.y_tops,e.color||t.colors[i])})}},{key:"make_path",value:function(e,i,a,n,r){var s=n.map(function(t,e){return a[e]+","+t}).join("L");if(this.paths_groups[i].textContent="",e.path=t.createSVG("path",{inside:this.paths_groups[i],className:"stroke "+r,d:"M"+s}),this.heatline){var o=this.make_gradient(r);e.path.style.stroke="url(#"+o+")"}this.region_fill&&this.fill_region_for_dataset(e,i,r,s)}},{key:"fill_region_for_dataset",value:function(e,i,a,n){var r=this.make_gradient(a,!0);e.region_path=t.createSVG("path",{inside:this.paths_groups[i],className:"region-fill",d:"M0,"+this.zero_line+"L"+n+"L"+this.width+","+this.zero_line}),e.region_path.style.stroke="none",e.region_path.style.fill="url(#"+r+")"}},{key:"make_gradient",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a="path-fill-gradient-"+e,n=t.createSVG("linearGradient",{inside:this.svg_defs,id:a,x1:0,x2:0,y1:0,y2:1}),r=function(e,i,a,n){t.createSVG("stop",{className:"stop-color "+a,inside:e,offset:i,"stop-opacity":n})},s=[1,.6,.2];return i&&(s=[.4,.2,0]),r(n,"0%",e,s[0]),r(n,"50%",e,s[1]),r(n,"100%",e,s[2]),a}}]),i}(),H=function(t){function e(t){M(this,e);var i=T(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 O(e,F),A(e,[{key:"setup_graph_components",value:function(){this.setup_path_groups(),C(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setup_graph_components",this).call(this)}},{key:"setup_path_groups",value:function(){}},{key:"setup_values",value:function(){C(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}(),I=function(e){function i(t){M(this,i);var e=T(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.type="percentage",e.max_slices=10,e.max_legend_points=6,e.setup(),e}return O(i,V),A(i,[{key:"make_chart_area",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"}},{key:"make_draw_area",value:function(){this.chart_div=t.create("div",{className:"div",inside:this.chart_wrapper}),this.chart=t.create("div",{className:"progress-chart",inside:this.chart_div})}},{key:"setup_components",value:function(){this.percentage_bar=t.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:"make_graph_components",value:function(){var e=this;this.grand_total=this.slice_totals.reduce(function(t,e){return t+e},0),this.slices=[],this.slice_totals.map(function(i,a){var n=t.create("div",{className:"progress-bar background "+e.colors[a],inside:e.percentage_bar,styles:{width:100*i/e.grand_total+"%"}});e.slices.push(n)})}},{key:"bind_tooltip",value:function(){var e=this;this.slices.map(function(i,a){i.addEventListener("mouseenter",function(){var n=t.offset(e.chart_wrapper),r=t.offset(i),s=r.left-n.left+i.offsetWidth/2,o=r.top-n.top-6,l=(e.formatted_labels&&e.formatted_labels.length>0?e.formatted_labels[a]:e.labels[a])+": ",c=(100*e.slice_totals[a]/e.grand_total).toFixed(1);e.tip.set_values(s,o,l,c+"%"),e.tip.show_tip()})})}},{key:"show_summary",value:function(){var e=this,i=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(a,n){a&&(t.create("div",{className:"stats",inside:e.stats_wrapper}).innerHTML='<span class="indicator '+e.colors[n]+'">\n\t\t\t\t\t<span class="text-muted">'+i[n]+":</span>\n\t\t\t\t\t"+a+"\n\t\t\t\t</span>")})}}]),i}(),B=Math.PI/180,q=function(e){function i(t){M(this,i);var e=T(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.type="pie",e.elements_to_animate=null,e.hoverRadio=t.hoverRadio||.1,e.max_slices=10,e.max_legend_points=6,e.isAnimate=!1,e.colors=t.colors,e.startAngle=t.startAngle||0,e.clockWise=t.clockWise||!1,(!e.colors||e.colors.length<e.data.labels.length)&&(e.colors=["#7cd6fd","#5e64ff","#743ee2","#ff5858","#ffa00a","#FEEF72","#28a745","#98d85b","#b554ff","#ffa3ef"]),e.mouseMove=e.mouseMove.bind(e),e.mouseLeave=e.mouseLeave.bind(e),e.setup(),e}return O(i,V),A(i,[{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,r=this.clockWise;return"M"+i+" "+a+" L"+(i+t.x)+" "+(a+t.y)+" A "+n+" "+n+" 0 0 "+(r?1:0)+" "+(i+e.x)+" "+(a+e.y)+" z"}},{key:"make_graph_components",value:function(e){var a=this,n=this.radius,r=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 o=180-this.startAngle;this.slice_totals.map(function(l,c){var h=o,u=l/a.grand_total*360,p=r?-u:u,_=o+=p,d=i.getPositionByAngle(h,n),f=i.getPositionByAngle(_,n),v=e&&s[c],g=void 0,m=void 0;e?(g=v?v.startPosition:d,m=v?v.endPosition:d):(g=d,m=f);var y=a.makeArcPath(g,m),x=t.createSVG("path",{inside:a.draw_area,className:"pie-path",style:"transition:transform .3s;",d:y,fill:a.colors[c]});a.slices.push(x),a.slicesProperties.push({startPosition:d,endPosition:f,value:l,total:a.grand_total,startAngle:h,endAngle:_,angle:p}),e&&a.elements_to_animate.push([{unit:x,array:a.slices,index:a.slices.length-1},{d:a.makeArcPath(d,f)},650,"easein",null,{d:y}])}),e&&this.run_animation()}},{key:"run_animation",value:function(){var t=this;if(this.elements_to_animate&&0!==this.elements_to_animate.length){var e=r(this.svg,this.elements_to_animate);this.svg.parentNode==this.chart_wrapper&&(this.chart_wrapper.removeChild(this.svg),this.chart_wrapper.appendChild(e)),setTimeout(function(){e.parentNode==t.chart_wrapper&&(t.chart_wrapper.removeChild(e),t.chart_wrapper.appendChild(t.svg))},650)}}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,a=this.hoverRadio,n=i.getPositionByAngle(t.startAngle+t.angle/2,e);return"translate3d("+n.x*a+"px,"+n.y*a+"px,0)"}},{key:"hoverSlice",value:function(e,i,a,r){if(e)if(a){n(e,this.calTranslateByAngle(this.slicesProperties[i])),e.setAttribute("fill",g(this.colors[i],50));var s=t.offset(this.svg),o=r.pageX-s.left+10,l=r.pageY-s.top-10,c=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.labels[i])+": ",h=(100*this.slice_totals[i]/this.grand_total).toFixed(1);this.tip.set_values(o,l,c,h+"%"),this.tip.show_tip()}else n(e,"translate3d(0,0,0)"),this.tip.hide_tip(),e.setAttribute("fill",this.colors[i])}},{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.draw_area.addEventListener("mousemove",this.mouseMove),this.draw_area.addEventListener("mouseleave",this.mouseLeave)}},{key:"show_summary",value:function(){var e=this,i=this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels:this.labels;this.legend_totals.map(function(a,n){a&&(t.create("div",{className:"stats",inside:e.stats_wrapper}).innerHTML='<span class="indicator">\n\t\t\t\t\t<i style="background-color:'+e.colors[n]+';"></i>\n\t\t\t\t\t<span class="text-muted">'+i[n]+":</span>\n\t\t\t\t\t"+a+"\n\t\t\t\t</span>")})}}],[{key:"getPositionByAngle",value:function(t,e){return{x:Math.sin(t*B)*e,y:Math.cos(t*B)*e}}}]),i}(),R=function(e){function i(t){var e=t.start,a=void 0===e?"":e,n=t.domain,r=void 0===n?"":n,s=t.subdomain,o=void 0===s?"":s,l=t.data,c=void 0===l?{}:l,h=t.discrete_domains,u=void 0===h?0:h,p=t.count_label,_=void 0===p?"":p,d=t.legend_colors,f=void 0===d?[]:d;M(this,i);var v=T(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,arguments[0]));v.type="heatmap",v.domain=r,v.subdomain=o,v.data=c,v.discrete_domains=u,v.count_label=_;var g=new Date;return v.start=a||w(g,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.setup(),v}return O(i,V),A(i,[{key:"validate_colors",value:function(t){if(t.length<5)return 0;var e=1;return t.forEach(function(t){m(t)||(e=0,console.warn('"'+t+'" is not a valid color.'))},this),e}},{key:"setup_base_values",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()&&w(this.first_week_start,-1*this.first_week_start.getDay()),7!==this.last_week_start.getDay()&&w(this.last_week_start,-1*this.last_week_start.getDay()),this.no_of_cols=b(this.first_week_start+"",this.last_week_start+"")+1}},{key:"set_width",value:function(){this.base_width=12*(this.no_of_cols+3),this.discrete_domains&&(this.base_width+=144)}},{key:"setup_components",value:function(){this.domain_label_group=t.createSVG("g",{className:"domain-label-group chart-label",inside:this.draw_area}),this.data_groups=t.createSVG("g",{className:"data-groups",inside:this.draw_area,transform:"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=u(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,r=new Date(e),s=this.get_week_squares_group(r,this.week_col),o=P(s,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),w(e,7)}this.render_month_labels()}},{key:"get_week_squares_group",value:function(e,i){for(var a=this.today.getTime(),n=0,r=0,s=t.createSVG("g",{className:"data-group",inside:this.data_groups}),o=0,l=0;l<7;l+=1,o+=12){var c=0,h=0,u=e.getTime()/1e3,_=Math.floor(u-u%86400).toFixed(1);this.data[_]&&(c=this.data[_]),this.data[Math.round(_)]&&(c=this.data[Math.round(_)]),c&&(h=p(c,this.distribution));var d=13+12*(i+r);t.createSVG("rect",{className:"day",inside:s,x:d,y:o,width:10,height:10,fill:this.legend_colors[h],"data-date":x(e),"data-value":c,"data-day":e.getDay()});var f=new Date(e);if(w(f,1),f.getTime()>a)break;f.getMonth()-e.getMonth()&&(n=1,this.discrete_domains&&(r=1),this.month_start_points.push(13+12*(i+r))),e=f}return[s,n]}},{key:"render_month_labels",value:function(){var e=this;this.months.shift(),this.month_start_points.shift(),this.months.pop(),this.month_start_points.pop(),this.month_start_points.map(function(i,a){var n=e.month_names[e.months[a]].substring(0,3);t.createSVG("text",{className:"y-value-text",inside:e.domain_label_group,x:i+12,y:10,dy:".32em",innerHTML:n})})}},{key:"make_graph_components",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),r=t.chart_wrapper.getBoundingClientRect(),s=e.target.getBoundingClientRect(),o=parseInt(e.target.getAttribute("width")),l=s.left-r.left+(o+2)/2,c=s.top-r.top-(o+2)/2,h=i+" "+t.count_label,u=" on "+n+" "+a[0]+", "+a[2];t.tip.set_values(l,c,u,h,[],1),t.tip.show_tip()})})}},{key:"update",value:function(t){this.data=t,this.setup_values(),this.bind_tooltip()}}]),i}(),W={line:F,bar:D,scatter:H,percentage:I,heatmap:R,pie:q},Y=function t(e){return M(this,t),S(e.type,arguments[0])};return Y}(); |
{ | ||
"name": "frappe-charts", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "https://frappe.github.io/charts", | ||
@@ -5,0 +5,0 @@ "main": "dist/frappe-charts.min.cjs.js", |
@@ -44,3 +44,3 @@ <div align="center"> | ||
```html | ||
<script src="https://unpkg.com/frappe-charts@0.0.3/dist/frappe-charts.min.iife.js"></script> | ||
<script src="https://unpkg.com/frappe-charts@0.0.4/dist/frappe-charts.min.iife.js"></script> | ||
``` | ||
@@ -57,4 +57,3 @@ | ||
title: "Some Data", | ||
color: "light-blue", // or 'green', 'blue', 'violet', 'red', 'orange', 'yellow', | ||
// 'light-green', 'purple', 'magenta', 'grey', 'dark-grey' | ||
color: "light-blue", | ||
values: [25, 40, 30, 35, 8, 52, 17, -4] | ||
@@ -71,3 +70,3 @@ }, | ||
const chart = new Chart({ | ||
parent: '#chart', | ||
parent: '#chart', // or a DOM element | ||
title: "My Awesome Chart", | ||
@@ -91,3 +90,4 @@ data: data, | ||
------------------ | ||
Made with ♥ by [pratu16x7](https://github.com/pratu16x7). Awesome logo by [raghukamath](https://github.com/raghukamath). | ||
Project maintained by [frappe](https://github.com/frappe). | ||
Project maintained by [Frappe](https://frappe.io). | ||
Used in [ERPNext](https://erpnext.com). Read the [blog post](https://medium.com/@pratu16x7/so-we-decided-to-create-our-own-charts-a95cb5032c97). | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
258917
5808