!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("chart.js")):"function"==typeof define&&define.amd?define(["exports","react","chart.js"],e):e(t.ReactChartjs2={},t.React,t.Chart)}(this,function(t,e,r){"use strict";function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function o(t){return function(){return t}}function a(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=0&&(r==e.length-1?e.pop():w.call(e,r,1),--this.size,!0)},a.prototype.get=function(t){var e=this.__data__,r=O(e,t);return 0>r?void 0:e[r][1]},a.prototype.has=function(t){return O(this.__data__,t)>-1},a.prototype.set=function(t,e){var r=this.__data__,n=O(r,t);return 0>n?(++this.size,r.push([t,e])):r[n][1]=e,this};var E=a,P="object"==typeof l&&l&&l.Object===Object&&l,A="object"==typeof self&&self&&self.Object===Object&&self,I=P||A||Function("return this")(),C=I.Symbol,D=Object.prototype,z=D.hasOwnProperty,k=D.toString,S=C?C.toStringTag:void 0,T=function(t){var e=z.call(t,S),r=t[S];try{t[S]=void 0;var n=!0}catch(t){}var o=k.call(t);return n&&(e?t[S]=r:delete t[S]),o},x=Object.prototype.toString,R=function(t){return x.call(t)},B="[object Null]",M="[object Undefined]",F=C?C.toStringTag:void 0,L=function(t){return null==t?void 0===t?M:B:F&&F in Object(t)?T(t):R(t)},U=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},K="[object AsyncFunction]",$="[object Function]",q="[object GeneratorFunction]",W="[object Proxy]",V=function(t){if(!U(t))return!1;var e=L(t);return e==$||e==q||e==K||e==W},N=I["__core-js_shared__"],H=function(){var t=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),G=function(t){return!!H&&H in t},Y=Function.prototype.toString,J=function(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Q=/[\\^$.*+?()[\]{}|]/g,X=/^\[object .+?Constructor\]$/,Z=Function.prototype,tt=Object.prototype,et=Z.toString,rt=tt.hasOwnProperty,nt=RegExp("^"+et.call(rt).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ot=function(t){return!(!U(t)||G(t))&&(V(t)?nt:X).test(J(t))},at=function(t,e){return null==t?void 0:t[e]},it=function(t,e){var r=at(t,e);return ot(r)?r:void 0},ut=it(I,"Map"),ct=it(Object,"create"),st="__lodash_hash_undefined__",ft=Object.prototype.hasOwnProperty,pt=Object.prototype.hasOwnProperty,ht="__lodash_hash_undefined__";i.prototype.clear=function(){this.__data__=ct?ct(null):{},this.size=0},i.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},i.prototype.get=function(t){var e=this.__data__;if(ct){var r=e[t];return r===st?void 0:r}return ft.call(e,t)?e[t]:void 0},i.prototype.has=function(t){var e=this.__data__;return ct?void 0!==e[t]:pt.call(e,t)},i.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ct&&void 0===e?ht:e,this};var lt=i,dt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t},yt=function(t,e){var r=t.__data__;return dt(e)?r["string"==typeof e?"string":"hash"]:r.map};u.prototype.clear=function(){this.size=0,this.__data__={hash:new lt,map:new(ut||E),string:new lt}},u.prototype.delete=function(t){var e=yt(this,t).delete(t);return this.size-=e?1:0,e},u.prototype.get=function(t){return yt(this,t).get(t)},u.prototype.has=function(t){return yt(this,t).has(t)},u.prototype.set=function(t,e){var r=yt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var vt=u,bt=200;c.prototype.clear=function(){this.__data__=new E,this.size=0},c.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},c.prototype.get=function(t){return this.__data__.get(t)},c.prototype.has=function(t){return this.__data__.has(t)},c.prototype.set=function(t,e){var r=this.__data__;if(r instanceof E){var n=r.__data__;if(!ut||bt-1>n.length)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new vt(n)}return r.set(t,e),this.size=r.size,this};var _t=c,gt="__lodash_hash_undefined__";s.prototype.add=s.prototype.push=function(t){return this.__data__.set(t,gt),this},s.prototype.has=function(t){return this.__data__.has(t)};var jt=s,mt=function(t,e){for(var r=-1,n=null==t?0:t.length;++ru))return!1;var s=a.get(t);if(s&&a.get(e))return s==e;var f=-1,p=!0,h=r&Et?new jt:void 0;for(a.set(t,e),a.set(e,t);++f-1&&t%1==0&&e>t},pe=9007199254740991,he=function(t){return"number"==typeof t&&t>-1&&t%1==0&&pe>=t},le={};le["[object Float32Array]"]=le["[object Float64Array]"]=le["[object Int8Array]"]=le["[object Int16Array]"]=le["[object Int32Array]"]=le["[object Uint8Array]"]=le["[object Uint8ClampedArray]"]=le["[object Uint16Array]"]=le["[object Uint32Array]"]=!0,le["[object Arguments]"]=le["[object Array]"]=le["[object ArrayBuffer]"]=le["[object Boolean]"]=le["[object DataView]"]=le["[object Date]"]=le["[object Error]"]=le["[object Function]"]=le["[object Map]"]=le["[object Number]"]=le["[object Object]"]=le["[object RegExp]"]=le["[object Set]"]=le["[object String]"]=le["[object WeakMap]"]=!1;var de=function(t){return function(e){return t(e)}},ye=n(function(t,e){var r=e&&!e.nodeType&&e,n=r&&!0&&t&&!t.nodeType&&t,o=n&&n.exports===r&&P.process,a=function(){try{var t=n&&n.require&&n.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}),ve=ye&&ye.isTypedArray,be=ve?de(ve):function(t){return Zt(t)&&he(t.length)&&!!le[L(t)]},_e=Object.prototype.hasOwnProperty,ge=function(t,e){var r=Nt(t),n=!r&&ae(t),o=!r&&!n&&ue(t),a=!r&&!n&&!o&&be(t),i=r||n||o||a,u=i?Xt(t.length,String):[],c=u.length;for(var s in t)!e&&!_e.call(t,s)||i&&("length"==s||o&&("offset"==s||"parent"==s)||a&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||fe(s,c))||u.push(s);return u},je=Object.prototype,me=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||je)},Oe=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),we=Object.prototype.hasOwnProperty,Ee=function(t){if(!me(t))return Oe(t);var e=[];for(var r in Object(t))we.call(t,r)&&"constructor"!=r&&e.push(r);return e},Pe=function(t){return null!=t&&he(t.length)&&!V(t)},Ae=function(t){return Pe(t)?ge(t):Ee(t)},Ie=function(t){return Ht(t,Ae,Qt)},Ce=1,De=Object.prototype.hasOwnProperty,ze=function(t,e,r,n,o,a){var i=r&Ce,u=Ie(t),c=u.length;if(c!=Ie(e).length&&!i)return!1;for(var s=c;s--;){var f=u[s];if(!(i?f in e:De.call(e,f)))return!1}var p=a.get(t);if(p&&a.get(e))return p==e;var h=!0;a.set(t,e),a.set(e,t);for(var l=i;++sr;)t=t[Cr(e[r++])];return r&&r==n?t:void 0},zr=function(t,e,r){var n=null==t?void 0:Dr(t,e);return void 0===n?r:n},kr=function(t,e){return null!=t&&e in Object(t)},Sr=function(t,e,r){for(var n=-1,o=(e=Ar(e,t)).length,a=!1;++ne;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Vr=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)},Nr=function(t,e){var r={};for(var n in t)0>e.indexOf(n)&&Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n]);return r},Hr=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},Gr="undefined"!=typeof process&&process.env&&"production",Yr=function(t){function n(){qr(this,n);var e=Hr(this,t.call(this));return e.handleOnClick=function(t){var r=e.chartInstance,n=e.props,o=n.getDatasetAtEvent,a=n.getElementAtEvent,i=n.getElementsAtEvent,u=n.onElementsClick;o&&o(r.getDatasetAtEvent(t),t),a&&a(r.getElementAtEvent(t),t),i&&i(r.getElementsAtEvent(t),t),u&&u(r.getElementsAtEvent(t),t)},e.ref=function(t){e.element=t},e.chartInstance=void 0,e}return Vr(n,t),n.prototype.componentDidMount=function(){this.renderChart()},n.prototype.componentDidUpdate=function(){if(this.props.redraw)return this.destroyChart(),void this.renderChart();this.updateChart()},n.prototype.shouldComponentUpdate=function(t){var e=this.props,r=e.type,n=e.options,o=e.plugins,a=e.legend,i=e.height,u=e.width;if(!0===t.redraw)return!0;if(i!==t.height||u!==t.width)return!0;if(r!==t.type)return!0;if(!Ye(a,t.legend))return!0;if(!Ye(n,t.options))return!0;var c=this.transformDataProp(t);return!Ye(this.shadowDataProp,c)||!Ye(o,t.plugins)},n.prototype.componentWillUnmount=function(){this.destroyChart()},n.prototype.transformDataProp=function(t){var e=t.data;return"function"==typeof e?e(this.element):e},n.prototype.memoizeDataProps=function(){if(this.props.data){var t=this.transformDataProp(this.props);return this.shadowDataProp=Wr({},t,{datasets:t.datasets&&t.datasets.map(function(t){return Wr({},t)})}),this.saveCurrentDatasets(),t}},n.prototype.checkDatasets=function(t){var e="production"!==Gr&&"prod"!==Gr,r=this.props.datasetKeyProvider!==n.getLabelAsKey,o=t.length>1;if(e&&o&&!r){var a=!1;t.forEach(function(t){t.label||(a=!0)}),a&&console.error('[react-chartjs-2] Warning: Each dataset needs a unique key. By default, the "label" property on each dataset is used. Alternatively, you may provide a "datasetKeyProvider" as a prop that returns a unique key.')}},n.prototype.getCurrentDatasets=function(){return this.chartInstance&&this.chartInstance.config.data&&this.chartInstance.config.data.datasets||[]},n.prototype.saveCurrentDatasets=function(){var t=this;this.datasets=this.datasets||{},this.getCurrentDatasets().forEach(function(e){t.datasets[t.props.datasetKeyProvider(e)]=e})},n.prototype.updateChart=function(){var t=this,e=this.props.options,n=this.memoizeDataProps(this.props);if(this.chartInstance){e&&(this.chartInstance.options=r.helpers.configMerge(this.chartInstance.options,e));var o=this.getCurrentDatasets(),a=n.datasets||[];this.checkDatasets(o);var i=$r(o,this.props.datasetKeyProvider);this.chartInstance.config.data.datasets=a.map(function(e){var r=i[t.props.datasetKeyProvider(e)];if(r&&r.type===e.type&&e.data){r.data.splice(e.data.length),e.data.forEach(function(t,n){r.data[n]=e.data[n]});var n=Nr(e,["data"]);return Wr({},r,n)}return e});var u=Nr(n,["datasets"]);this.chartInstance.config.data=Wr({},this.chartInstance.config.data,u),this.chartInstance.update()}},n.prototype.renderChart=function(){var t=this.props,e=t.options,o=t.legend,a=t.type,i=t.plugins,u=this.element,c=this.memoizeDataProps();void 0===o||Ye(n.defaultProps.legend,o)||(e.legend=o),this.chartInstance=new r(u,{type:a,data:c,options:e,plugins:i})},n.prototype.destroyChart=function(){if(this.chartInstance){this.saveCurrentDatasets();var t=Object.values(this.datasets);this.chartInstance.config.data.datasets=t,this.chartInstance.destroy()}},n.prototype.render=function(){var t=this.props,r=t.height,n=t.width,o=t.id;return e.createElement("canvas",{ref:this.ref,height:r,width:n,id:o,onClick:this.handleOnClick})},n}(e.Component);Yr.getLabelAsKey=function(t){return t.label},Yr.propTypes={data:j.oneOfType([j.object,j.func]).isRequired,getDatasetAtEvent:j.func,getElementAtEvent:j.func,getElementsAtEvent:j.func,height:j.number,legend:j.object,onElementsClick:j.func,options:j.object,plugins:j.arrayOf(j.object),redraw:j.bool,type:function(t,e,n){if(!r.controllers[t[e]])return Error("Invalid chart type `"+t[e]+"` supplied to `"+n+"`.")},width:j.number,datasetKeyProvider:j.func},Yr.defaultProps={legend:{display:!0,position:"bottom"},type:"doughnut",height:150,width:300,redraw:!1,options:{},datasetKeyProvider:Yr.getLabelAsKey};var Jr=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"doughnut"}))},r}(e.Component),Qr=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"pie"}))},r}(e.Component),Xr=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"line"}))},r}(e.Component),Zr=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"bar"}))},r}(e.Component),tn=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"horizontalBar"}))},r}(e.Component),en=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"radar"}))},r}(e.Component),rn=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"polarArea"}))},r}(e.Component),nn=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"bubble"}))},r}(e.Component),on=function(t){function r(){return qr(this,r),Hr(this,t.apply(this,arguments))}return Vr(r,t),r.prototype.render=function(){var t=this;return e.createElement(Yr,Wr({},this.props,{ref:function(e){return t.chartInstance=e&&e.chartInstance},type:"scatter"}))},r}(e.Component),an=r.defaults;t.default=Yr,t.Doughnut=Jr,t.Pie=Qr,t.Line=Xr,t.Bar=Zr,t.HorizontalBar=tn,t.Radar=en,t.Polar=rn,t.Bubble=nn,t.Scatter=on,t.defaults=an,t.Chart=r,Object.defineProperty(t,"__esModule",{value:!0})});