2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
|
this.primereact=this.primereact||{},this.primereact.chart=function(t,e,n){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=r(e);function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(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 u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function c(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&&u(t,e)}function s(t){return s="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},s(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){if(e&&("object"===s(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function h(){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 y,d,b,v=function(t){c(d,t);var e,r,u,s,l,y=(e=d,r=h(),function(){var t,n=f(e);if(r){var o=f(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return p(this,t)});function d(){return i(this,d),y.apply(this,arguments)}return u=d,(s=[{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 t=this,e=n.classNames("p-chart",this.props.className),r=Object.assign({width:this.props.width,height:this.props.height},this.props.style);return o.default.createElement("div",{id:this.props.id,style:r,className:e},o.default.createElement("canvas",{ref:function(e){t.canvas=e},width:this.props.width,height:this.props.height}))}}])&&a(u.prototype,s),l&&a(u,l),Object.defineProperty(u,"prototype",{writable:!1}),d}(e.Component);return b={id:null,type:null,data:null,options:null,plugins:null,width:null,height:null,style:null,className:null},(d="defaultProps")in(y=v)?Object.defineProperty(y,d,{value:b,enumerable:!0,configurable:!0,writable:!0}):y[d]=b,t.Chart=v,Object.defineProperty(t,"__esModule",{value:!0}),t}({},React,primereact.utils);
|