katoikia-app/web-ui/web-react/node_modules/primereact/chart/chart.esm.min.js

2 lines
3.5 KiB
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
import t,{Component as e}from"react";import{classNames as n}from"primereact/utils";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e){return i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}function a(t){return a="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},a(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function s(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var f,h,y,d=function(i){u(b,e);var a,c,f,h,y,d=(a=b,c=p(),function(){var t,e=l(a);if(c){var n=l(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return s(this,t)});function b(){return r(this,b),d.apply(this,arguments)}return f=b,(h=[{key:"initChart",value:function(){var t=this;import("chart.js/auto").then((function(e){t.chart&&(t.chart.destroy(),t.chart=null),e&&e.default&&(t.chart=new e.default(t.canvas,{type:t.props.type,data:t.props.data,options:t.props.options,plugins:t.props.plugins}))}))}},{key:"getCanvas",value:function(){return this.canvas}},{key:"getChart",value:function(){return this.chart}},{key:"getBase64Image",value:function(){return this.chart.toBase64Image()}},{key:"generateLegend",value:function(){this.chart&&this.chart.generateLegend()}},{key:"refresh",value:function(){this.chart&&this.chart.update()}},{key:"reinit",value:function(){this.initChart()}},{key:"shouldComponentUpdate",value:function(t){return t.data!==this.props.data||t.options!==this.props.options||t.type!==this.props.type}},{key:"componentDidMount",value:function(){this.initChart()}},{key:"componentDidUpdate",value:function(){this.reinit()}},{key:"componentWillUnmount",value:function(){this.chart&&(this.chart.destroy(),this.chart=null)}},{key:"render",value:function(){var e=this,r=n("p-chart",this.props.className),o=Object.assign({width:this.props.width,height:this.props.height},this.props.style);return t.createElement("div",{id:this.props.id,style:o,className:r},t.createElement("canvas",{ref:function(t){e.canvas=t},width:this.props.width,height:this.props.height}))}}])&&o(f.prototype,h),y&&o(f,y),Object.defineProperty(f,"prototype",{writable:!1}),b}();y={id:null,type:null,data:null,options:null,plugins:null,width:null,height:null,style:null,className:null},(h="defaultProps")in(f=d)?Object.defineProperty(f,h,{value:y,enumerable:!0,configurable:!0,writable:!0}):f[h]=y;export{d as Chart};