primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime
2 lines (1 loc) • 2.13 kB
JavaScript
this.primereact=this.primereact||{},this.primereact.chart=function(e,t,r,n){"use strict";function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=u(t);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}var i=function(){try{return Chart}catch(e){return null}}(),l=a.memo(a.forwardRef((function(e,t){var u=a.useRef(null),s=a.useRef(null),o=a.useRef(null),f=function(){p();var t={type:e.type,data:e.data,options:e.options,plugins:e.plugins};i?s.current=new i(o.current,t):import("chart.js/auto").then((function(e){p(),e&&(s.current=e.default?new e.default(o.current,t):new e(o.current,t))}))},p=function(){s.current&&(s.current.destroy(),s.current=null)};a.useImperativeHandle(t,(function(){return{props:e,getCanvas:function(){return o.current},getChart:function(){return s.current},getBase64Image:function(){return s.current.toBase64Image()},getElement:function(){return u.current},generateLegend:function(){return s.current&&s.current.generateLegend()},refresh:function(){return s.current&&s.current.update()}}})),a.useEffect((function(){f()})),r.useUnmountEffect((function(){p()}));var h=n.ObjectUtils.findDiffKeys(e,l.defaultProps),d=n.classNames("p-chart",e.className),g=Object.assign({width:e.width,height:e.height},e.style);return a.createElement("div",c({id:e.id,ref:u,style:g,className:d},h),a.createElement("canvas",{ref:o,width:e.width,height:e.height}))})),(function(e,t){return e.data===t.data&&e.options===t.options&&e.type===t.type}));return l.displayName="Chart",l.defaultProps={__TYPE:"Chart",id:null,type:null,data:null,options:null,plugins:null,width:null,height:null,style:null,className:null},e.Chart=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.hooks,primereact.utils);