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.32 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/hooks"),r=require("primereact/utils");function n(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 u=n(e);function a(){return a=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},a.apply(this,arguments)}var c={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 r.ObjectUtils.getMergedProps(e,c.defaultProps)},getOtherProps:function(e){return r.ObjectUtils.getDiffProps(e,c.defaultProps)}},i=function(){try{return Chart}catch(e){return null}}(),o=u.memo(u.forwardRef((function(e,o){var s=c.getProps(e),l=u.useRef(null),f=u.useRef(null),p=u.useRef(null),d=function(){h();var e={type:s.type,data:s.data,options:s.options,plugins:s.plugins};i?f.current=new i(p.current,e):Promise.resolve().then((function(){return n(require("chart.js/auto"))})).then((function(t){h(),p.current&&t&&(f.current=t.default?new t.default(p.current,e):new t(p.current,e))}))},h=function(){f.current&&(f.current.destroy(),f.current=null)};u.useImperativeHandle(o,(function(){return{props:s,getCanvas:function(){return p.current},getChart:function(){return f.current},getBase64Image:function(){return f.current.toBase64Image()},getElement:function(){return l.current},generateLegend:function(){return f.current&&f.current.generateLegend()},refresh:function(){return f.current&&f.current.update()}}})),u.useEffect((function(){d()})),t.useUnmountEffect((function(){h()}));var g=c.getOtherProps(s),m=r.classNames("p-chart",s.className),v=Object.assign({width:s.width,height:s.height},s.style);return u.createElement("div",a({id:s.id,ref:l,style:v,className:m},g),u.createElement("canvas",{ref:p,width:s.width,height:s.height}))})),(function(e,t){return e.data===t.data&&e.options===t.options&&e.type===t.type}));o.displayName="Chart",exports.Chart=o;
;