UNPKG

primereact

Version:

PrimeReact is an open source UI library for React featuring a rich set of 90+ 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.31 kB
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={defaultProps:{__TYPE:"Chart",id:null,type:null,data:null,options:null,plugins:null,width:null,height:null,style:null,className:null,children:void 0},getProps:function(e){return n.ObjectUtils.getMergedProps(e,i.defaultProps)},getOtherProps:function(e){return n.ObjectUtils.getDiffProps(e,i.defaultProps)}},o=function(){try{return Chart}catch(e){return null}}(),s=a.memo(a.forwardRef((function(e,t){var u=i.getProps(e),s=a.useRef(null),l=a.useRef(null),f=a.useRef(null),p=function(){h();var e={type:u.type,data:u.data,options:u.options,plugins:u.plugins};o?l.current=new o(f.current,e):import("chart.js/auto").then((function(t){h(),f.current&&t&&(l.current=t.default?new t.default(f.current,e):new t(f.current,e))}))},h=function(){l.current&&(l.current.destroy(),l.current=null)};a.useImperativeHandle(t,(function(){return{props:u,getCanvas:function(){return f.current},getChart:function(){return l.current},getBase64Image:function(){return l.current.toBase64Image()},getElement:function(){return s.current},generateLegend:function(){return l.current&&l.current.generateLegend()},refresh:function(){return l.current&&l.current.update()}}})),a.useEffect((function(){p()})),r.useUnmountEffect((function(){h()}));var d=i.getOtherProps(u),g=n.classNames("p-chart",u.className),m=Object.assign({width:u.width,height:u.height},u.style);return a.createElement("div",c({id:u.id,ref:s,style:m,className:g},d),a.createElement("canvas",{ref:f,width:u.width,height:u.height}))})),(function(e,t){return e.data===t.data&&e.options===t.options&&e.type===t.type}));return s.displayName="Chart",e.Chart=s,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.hooks,primereact.utils);