ag-charts-react
Version:
AG Charts React Component
2 lines (1 loc) • 1.8 kB
JavaScript
;var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,r)=>{for(var t in r)__defProp(e,t,{get:r[t],enumerable:!0})},__copyProps=(e,r,t,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of __getOwnPropNames(r))!__hasOwnProp.call(e,a)&&a!==t&&__defProp(e,a,{get:()=>r[a],enumerable:!(c=__getOwnPropDesc(r,a))||c.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),src_exports={};__export(src_exports,{AgCharts:()=>AgCharts,AgFinancialCharts:()=>AgFinancialCharts,AgGauge:()=>AgGauge}),module.exports=__toCommonJS(src_exports);var import_react=require("react"),import_ag_charts_community=require("ag-charts-community");function getOptions(e,r){return{...e,container:r.current}}function ChartWithConstructor(e,r){const t=(0,import_react.forwardRef)(function(a,p){const{options:s,style:i,className:g}=a,u=(0,import_react.useRef)(null),n=(0,import_react.useRef)();(0,import_react.useLayoutEffect)(()=>{const o=e(getOptions(s,u));return n.current=o,()=>{o.destroy()}},[]);const f=n.current===void 0;return(0,import_react.useEffect)(()=>{f||n.current?.update(getOptions(s,u)).catch(o=>console.error(o))},[s]),(0,import_react.useImperativeHandle)(p,()=>n.current,[]),(0,import_react.useMemo)(()=>(0,import_react.createElement)("div",{ref:u,style:i,className:g}),[i,g])});return t.displayName=r,t}var AgCharts=ChartWithConstructor(e=>import_ag_charts_community.AgCharts.create(e),"AgCharts"),AgFinancialCharts=ChartWithConstructor(e=>import_ag_charts_community.AgCharts.createFinancialChart(e),"AgFinancialCharts"),AgGauge=ChartWithConstructor(e=>import_ag_charts_community.AgCharts.createGauge(e),"AgGauge");