@kodiak-finance/orderly-chart 2.8.16-rc.3 → 2.8.16-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {useMemo,useRef,useId}from'react';import {ResponsiveContainer,BarChart,Tooltip,CartesianGrid,ReferenceLine,Bar,Cell,YAxis,XAxis,LineChart,Line,AreaChart,Area,ComposedChart,Cross}from'recharts';export{Area,AreaChart,Bar,BarChart,Cell,Line,LineChart}from'recharts';import {useTranslation}from'@kodiak-finance/orderly-i18n';import {cn,useScreen,Box,Flex,BarChartIcon,Text}from'@kodiak-finance/orderly-ui';import {numberToHumanStyle}from'@kodiak-finance/orderly-utils';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ft=Object.create;var q=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var $=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var Mt=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of Pt(o))!At.call(t,a)&&a!==e&&q(t,a,{get:()=>o[a],enumerable:!(r=kt(o,a))||r.enumerable});return t};var Tt=(t,o,e)=>(e=t!=null?Ft(Rt(t)):{},Mt(!t||!t.__esModule?q(e,"default",{value:t,enumerable:true}):e,t));var Ct=$(U=>{Object.defineProperty(U,"__esModule",{value:true});Object.defineProperty(U,"default",{enumerable:true,get:function(){return qr}});function yt(t,o){return {handler:t,config:o}}yt.withOptions=function(t,o=()=>({})){let e=function(r){return {__options:r,handler:t(r),config:o(r)}};return e.__isOptionsFunction=true,e.__pluginFunction=t,e.__configFunction=o,e};var qr=yt;});var bt=$(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Object.defineProperty(Y,"default",{enumerable:true,get:function(){return Zr}});var Qr=Jr(Ct());function Jr(t){return t&&t.__esModule?t:{default:t}}var Zr=Qr.default;});var gt=$((un,xt)=>{var H=bt();xt.exports=(H.__esModule?H:{default:H}).default;});var P=t=>{let o=Math.abs(t),e=o===0?0:o<=10?2:o<=100?1:0,r=numberToHumanStyle(o,e);return t<0?`-${r}`:r};var v=t=>{let{label:o,value:e,prefix:r,unit:a="USDC",coloring:i=false,dp:n,rm:l}=t;return jsxs(Box,{intensity:600,p:3,r:"md",children:[jsxs(Flex,{direction:"row",className:t.titleClassName,children:[r,jsx(Text.numeral,{unit:a,as:"div",size:"sm",coloring:i,showIdentifier:i,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:l,dp:n,children:e})]}),jsx(Text,{size:"2xs",intensity:54,weight:"semibold",children:o})]})};var j=()=>{let t=document.documentElement,o=getComputedStyle(t);return {primary:T(o.getPropertyValue("--oui-color-primary")),primaryLight:T(o.getPropertyValue("--oui-color-primary-light")),secondary:T(o.getPropertyValue("--oui-color-secondary")),success:T(o.getPropertyValue("--oui-color-success")),warning:T(o.getPropertyValue("--oui-color-warning")),danger:T(o.getPropertyValue("--oui-color-danger")),info:T(o.getPropertyValue("--oui-color-info")),loss:T(o.getPropertyValue("--oui-color-trading-loss")),profit:T(o.getPropertyValue("--oui-color-trading-profit"))}},T=t=>`rgb(${t.split(" ").join(",")})`;var u=t=>useMemo(()=>{let e=j();return {profit:t?.profit||e.profit,loss:t?.loss||e.loss,primary:e.primary,primaryLight:e.primaryLight}},[t]);var Xt=t=>{let{fill:o,x:e,y:r,width:a,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?r:r+i,width:a,height:n,stroke:"none",fill:o})},Wt=t=>{let{x:o,y:e,stroke:r,payload:a,index:i,width:n,containerWidth:l}=t,{t:s}=useTranslation(),h=i===0?48:l>0?l-10:n+a.offset;return jsx("g",{transform:`translate(${h},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:i===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?a.value:s("chart.now")})})},Ut=t=>{let{width:o,height:e,stroke:r,fill:a}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Yt=t=>{let{active:o,payload:e,label:r}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(v,{label:r===a.current?i("chart.now"):r,value:e[0].value,coloring:true}):null},Ht=t=>{let{invisible:o,data:e,responsiveContainerProps:r}=t,a=u(t.colors),i=useRef(0);return jsx(ResponsiveContainer,{className:cn(o&&"chart-invisible"),onResize:n=>{i.current=n;},...r,children:jsxs(BarChart,{data:e,margin:{left:-10,top:10,right:10,bottom:30},children:[!o&&jsx(Tooltip,{cursor:jsx(Ut,{}),content:jsx(Yt,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!o&&jsx(Bar,{dataKey:"pnl",shape:jsx(Xt,{}),children:e.map((n,l)=>jsx(Cell,{fill:n.pnl>0?a.profit:a.loss},`cell-${l}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:n=>P(n),tickLine:false,axisLine:false,dataKey:"pnl"}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:e.length-2,height:1,tick:jsx(Wt,{containerWidth:i.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var D=t=>{let{x:o,y:e,stroke:r,payload:a,index:i}=t,{t:n}=useTranslation();return jsx("g",{transform:`translate(${o},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?a.value:n("chart.now")})})};var le=t=>{let{active:o,payload:e,label:r}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(v,{label:r===a.current?i("chart.now"):r,value:e[0].value,coloring:true}):null},ce=t=>{let o=[];return t?.reduce((e,r)=>(e+=r.pnl,o.push({...r,pnl:e,_pnl:r.pnl}),e),0),o},me=t=>{let{responsiveContainerProps:o}=t,e=u(t.colors),{isMobile:r}=useScreen(),a=useMemo(()=>ce(t.data),[t.data]),i=jsxs(LineChart,{data:a,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(D,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:P}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(le,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Pe=t=>{let{active:o,payload:e,label:r}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(v,{label:r===a.current?i("chart.now"):r,value:e[0].value,coloring:true}):null},Re=t=>{let o=[];return t?.reduce((e,r)=>(e+=r.pnl,o.push({...r,pnl:e,_pnl:r.pnl}),e),0),o},Ae=t=>{let{responsiveContainerProps:o}=t,e=u(t.colors),{isMobile:r}=useScreen(),a=useId(),i=useMemo(()=>Re(t.data),[t.data]),n=jsxs(AreaChart,{data:i,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(D,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:P}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(Pe,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#608CFF",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#608CFF",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:n})};var w=({title:t="No Data Available",description:o="No data to display for the selected period",height:e="300px",className:r})=>jsx(Box,{className:cn("oui-w-full oui-flex oui-items-center oui-justify-center oui-bg-base-8",r),style:{height:e},children:jsxs(Flex,{direction:"column",itemAlign:"center",gap:3,className:"oui-text-center",children:[jsx(BarChartIcon,{}),jsx(Text,{as:"div",size:"sm",weight:"semibold",className:"oui-text-base-contrast-100",children:t}),jsx(Text,{as:"div",size:"xs",className:"oui-text-base-contrast-54",children:o})]})});var Ue=t=>{let{fill:o,x:e,y:r,width:a,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?r:r+i,width:a,height:n,stroke:"none",fill:o})},Ye=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},He=t=>{try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return t}},at=t=>`${t>=0?"+":""}${t.toFixed(2)}`,it=(t,o)=>t===0?"inherit":t>0?o.profit:o.loss,qe=t=>{let{active:o,payload:e,label:r}=t,a=u();if(o&&e&&e.length>=1){let n=e.find(p=>p.dataKey==="pnl")?.value??0,s=e.find(p=>p.dataKey==="cumulativePnL")?.value??0,h=He(r),R=it(n,a);it(s,a);return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[h,":"," ",jsxs("span",{style:{color:R},children:[at(n)," USDC"]})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[at(s)," USDC"]})]})]})}return null},Qe=(t,o,e=false)=>{if(t<=12&&!e)return 0;let r;t>500||t>200?r=6:t>100?r=7:t>50?r=8:r=12,e&&(r=Math.ceil(r/2));let a=Math.ceil(t/r);if(o==="15m")return a>=96?Math.ceil(a/56)*56:a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/16)*16:Math.max(8,Math.ceil(a/4)*4);if(o==="1h")return a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/12)*12:Math.max(4,Math.ceil(a/4)*4);if(o==="1d"){if(a>=14)return Math.ceil(a/14)*14;if(a>=3)return Math.ceil(a/7)*7}return a},Je=t=>{let o=0;return t.map(e=>(o+=e.pnl,{...e,cumulativePnL:o}))},Ze=t=>{let{data:o,aggregationWindow:e="1d",isMobile:r=false,invisible:a,responsiveContainerProps:i,className:n}=t,l=u(t.colors),s=useMemo(()=>Je(o),[o]),h=useMemo(()=>Qe(s.length,e,r),[s.length,e,r]),R=useMemo(()=>{if(s.length===0)return [0,1];let m=s.map(N=>N.pnl),p=s.map(N=>N.cumulativePnL),A=Math.min(...m,...p,0),M=Math.max(...m,...p,0),g=Math.max(Math.abs(A),Math.abs(M)),V=g===0?1:g*1.15;return [-V,V]},[s]);return a||s.length===0?jsx(w,{title:"No P&L Data",description:"No profit and loss data available for the selected period",height:"300px",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:0,top:10,right:10,bottom:20},children:[jsx("defs",{children:jsxs("linearGradient",{id:"cumulativeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"5%",stopColor:"#608CFF",stopOpacity:.4}),jsx("stop",{offset:"95%",stopColor:"#608CFF",stopOpacity:0})]})}),jsx(Tooltip,{cursor:jsx(Ye,{}),content:jsx(qe,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.3)",strokeWidth:2,strokeDasharray:"4 4"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>je(m),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"pnl",shape:jsx(Ue,{}),minPointSize:1,isAnimationActive:false,children:s.map((m,p)=>jsx(Cell,{fill:m.pnl===0?"rgba(255,255,255,0.2)":m.pnl>0?l.profit:l.loss},`cell-${p}`))}),jsx(Area,{type:"natural",dataKey:"cumulativePnL",fill:"url(#cumulativeGradient)",stroke:"none",isAnimationActive:false}),jsx(Line,{type:"natural",dataKey:"cumulativePnL",stroke:l.primary,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function je(t){let o=["","K","M","B","T"],e=0,r=Math.abs(t);for(;r>=1e3&&e<o.length-1;)r/=1e3,e++;let a=t<0?"-":"",i=r<=10?1:0,n=r.toFixed(i);return `${a}${n}${o[e]}`}var po=t=>{let{fill:o,x:e,y:r,width:a,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?r:r+i,width:a,height:n,stroke:"none",fill:o})},uo=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},fo=t=>{try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return t}},st=t=>`${t>=0?"+":""}${t}`,ho=t=>{let{active:o,payload:e,label:r}=t;if(o&&e&&e.length>=1){let i=e.find(h=>h.dataKey==="volume")?.value??0,l=e.find(h=>h.dataKey==="cumulativeVolume")?.value??0,s=fo(r);return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[s,": ",st(i)," USDC"]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[st(l)," USDC"]})]})]})}return null},yo=(t,o,e=false)=>{if(t<=12&&!e)return 0;let r;t>500||t>200?r=6:t>100?r=7:t>50?r=8:r=12,e&&(r=Math.ceil(r/2));let a=Math.ceil(t/r);if(o==="15m")return a>=96?Math.ceil(a/56)*56:a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/16)*16:Math.max(8,Math.ceil(a/4)*4);if(o==="1h")return a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/12)*12:Math.max(4,Math.ceil(a/4)*4);if(o==="1d"){if(a>=14)return Math.ceil(a/14)*14;if(a>=3)return Math.ceil(a/7)*7}return a},Co=t=>{let o=0;return t.map(e=>(o+=e.volume,{...e,cumulativeVolume:o}))},bo=t=>{let{data:o,aggregationWindow:e="1d",isMobile:r=false,invisible:a,responsiveContainerProps:i,className:n}=t,l=u(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),s=useMemo(()=>Co(o),[o]),h=useMemo(()=>yo(s.length,e,r),[s.length,e,r]),R=useMemo(()=>{if(s.length===0)return [0,1];let m=s.map(g=>g.volume),p=Math.max(...m,0),A=p,M=A===0?1:A*.1;return [0,Math.ceil((p+M)*100)/100]},[s]);return a||s.length===0?jsx(w,{title:"No Volume Data",description:"No trading volume data available for the selected period",height:"300px",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:0,top:10,right:10,bottom:20},children:[jsx(Tooltip,{cursor:jsx(uo,{}),content:jsx(ho,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>xo(m),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"volume",shape:jsx(po,{}),minPointSize:1,isAnimationActive:false,children:s.map((m,p)=>jsx(Cell,{fill:l.profit,opacity:.8},`cell-${p}`))})]})})})};function xo(t){let o=["","K","M","B","T"],e=0,r=Math.abs(t);for(;r>=1e3&&e<o.length-1;)r/=1e3,e++;let a=t<0?"-":"",i=r<=10?1:0,n=r.toFixed(i);return `${a}${n}${o[e]}`}var Oo=t=>{let{fill:o,x:e,y:r,width:a,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?r:r+i,width:a,height:n,stroke:"none",fill:o})},So=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Io=t=>{try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return t}},ct=t=>`${t>=0?"+":""}${t.toFixed(2)}`,Vo=t=>{let{active:o,payload:e,label:r}=t;if(o&&e&&e.length>=1){let i=e.find(h=>h.dataKey==="fees")?.value??0,l=e.find(h=>h.dataKey==="cumulativeFees")?.value??0,s=Io(r);return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[s,": ",ct(i)," USDC"]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[ct(l)," USDC"]})]})]})}return null},Bo=(t,o,e=false)=>{if(t<=12&&!e)return 0;let r;t>500||t>200?r=6:t>100?r=7:t>50?r=8:r=12,e&&(r=Math.ceil(r/2));let a=Math.ceil(t/r);if(o==="15m")return a>=96?Math.ceil(a/56)*56:a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/16)*16:Math.max(8,Math.ceil(a/4)*4);if(o==="1h")return a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/12)*12:Math.max(4,Math.ceil(a/4)*4);if(o==="1d"){if(a>=14)return Math.ceil(a/14)*14;if(a>=3)return Math.ceil(a/7)*7}return a},Ko=t=>{let o=0;return t.map(e=>(o+=e.fees,{...e,cumulativeFees:o}))},zo=t=>{let{data:o,aggregationWindow:e="1d",isMobile:r=false,invisible:a,responsiveContainerProps:i,className:n}=t,l=u(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),s=useMemo(()=>Ko(o),[o]),h=useMemo(()=>Bo(s.length,e,r),[s.length,e,r]),R=useMemo(()=>{if(s.length===0)return [0,1];let m=s.map(N=>N.fees),p=s.map(N=>N.cumulativeFees),A=Math.min(...m,...p,0),M=Math.max(...m,...p,0),g=M-A,V=g===0?1:g*.1;return [Math.floor((A-V)*100)/100,Math.ceil((M+V)*100)/100]},[s]);return a||s.length===0?jsx(w,{title:"No Fees Data",description:"No fees data available for the selected period",height:"300px",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:0,top:10,right:10,bottom:20},children:[jsx("defs",{children:jsxs("linearGradient",{id:"feesGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"5%",stopColor:"#00B49E",stopOpacity:.4}),jsx("stop",{offset:"95%",stopColor:"#00B49E",stopOpacity:0})]})}),jsx(Tooltip,{cursor:jsx(So,{}),content:jsx(Vo,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:m=>$o(m),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"fees",shape:jsx(Oo,{}),minPointSize:1,isAnimationActive:false,children:s.map((m,p)=>jsx(Cell,{fill:l.profit,opacity:.8},`cell-${p}`))}),jsx(Area,{type:"natural",dataKey:"cumulativeFees",fill:"url(#feesGradient)",stroke:"none",isAnimationActive:false}),jsx(Line,{type:"natural",dataKey:"cumulativeFees",stroke:l.primary,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function $o(t){let o=["","K","M","B","T"],e=0,r=Math.abs(t);for(;r>=1e3&&e<o.length-1;)r/=1e3,e++;let a=t<0?"-":"",i=r<=10?1:0,n=r.toFixed(i);return `${a}${n}${o[e]}`}var Zo=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},jo=t=>{let{active:o,payload:e}=t;if(o&&e&&e.length>=1){let r=e[0].payload;return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Open:"}),jsx("span",{className:"oui-font-semibold",children:r.open.toFixed(2)})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"High:"}),jsx("span",{className:"oui-font-semibold",children:r.high.toFixed(2)})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Low:"}),jsx("span",{className:"oui-font-semibold",children:r.low.toFixed(2)})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Close:"}),jsx("span",{className:"oui-font-semibold",children:r.close.toFixed(2)})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Time:"}),jsx("span",{className:"oui-font-semibold",children:r.date})]})]})}return null},tr=(t,o,e=false)=>{if(t<=12&&!e)return 0;let r;t>500||t>200?r=6:t>100?r=7:t>50?r=8:r=12,e&&(r=Math.ceil(r/2));let a=Math.ceil(t/r);if(o==="15m")return a>=96?Math.ceil(a/56)*56:a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/16)*16:Math.max(8,Math.ceil(a/4)*4);if(o==="1h")return a>=48?Math.ceil(a/28)*28:a>=24?Math.ceil(a/12)*12:Math.max(4,Math.ceil(a/4)*4);if(o==="1d"){if(a>=14)return Math.ceil(a/14)*14;if(a>=3)return Math.ceil(a/7)*7}return a};function er(t){return t.toFixed(2)}var or=t=>{let {data:o,aggregationWindow:e="1d",isMobile:r=false,invisible:a,responsiveContainerProps:i,className:n}=t;u();let s=useMemo(()=>tr(o.length,e,r),[o.length,e,r]),h=useMemo(()=>{if(o.length===0)return [0,1];let R=o.flatMap(g=>[g.open,g.high,g.low,g.close]),m=Math.min(...R),p=Math.max(...R),A=p-m,M=A===0?1:A*.15;return [m-M,p+M]},[o]);return a||o.length===0?jsx(w,{title:"No Price Data",description:"No price data available for the selected period",height:"300px",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:o,margin:{left:20,top:10,right:10,bottom:20},children:[jsx(Tooltip,{cursor:jsx(Zo,{}),content:jsx(jo,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:h,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:er,width:50}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:s,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Area,{type:"natural",dataKey:"high",isAnimationActive:false,fill:"rgba(0, 180, 158, 0.1)",stroke:"none"}),jsx(Line,{type:"natural",dataKey:"close",stroke:"#00B49E",strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};var fr=t=>{let{active:o,payload:e,label:r}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(v,{label:r===a.current?i("chart.now"):r,value:e[0].value}):null},dr=t=>{let{responsiveContainerProps:o}=t,e=u(t.colors),r=useId(),{isMobile:a}=useScreen(),i=a?jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(D,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:n=>P(n)}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${r})`})]})]}):jsxs(LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(D,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:P}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(fr,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Mr=t=>{let{active:o,payload:e,label:r}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(v,{label:r===a.current?i("chart.now"):r,value:e[0].value}):null},Tr=t=>{let{responsiveContainerProps:o}=t,e=u(t.colors),r=useId(),{isMobile:a}=useScreen(),i=jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(D,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:P}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(Mr,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${r})`})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Gr=t=>{let{fill:o,x:e,y:r,width:a,height:i,opacity:n}=t,l=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?r:r+i,width:a,height:l,stroke:"none",fill:o,opacity:n})},Er=t=>{let{width:o,height:e,payload:r,stroke:a,fill:i}=t;return r?.[0]?.value===0?null:jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Xr=t=>{let{active:o,payload:e,label:r,tooltip:a}=t;return e?.[0]?.value===0?null:o&&e&&e.length?jsx(v,{label:r,value:e[0].value,titleClassName:"oui-gap-4",rm:a?.rm,dp:a?.dp}):null},Wr=t=>{let o=u(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),e=t.data?.reduce((i,n)=>i+n.volume,0)===0,r=t.data?.reduce((i,n)=>i>n.volume?i:n.volume,0),a=r<=10?2:r<=100?1:0;return jsx(Box,{className:cn(t.className),children:jsx(ResponsiveContainer,{children:jsxs(BarChart,{data:t.data,margin:{left:-0,top:6,right:0,bottom:20},children:[jsx(Tooltip,{cursor:jsx(Er,{}),content:jsx(Xr,{tooltip:t.tooltip})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsx(ReferenceLine,{y:0,stroke:"#000"}),jsx(Bar,{dataKey:"volume",shape:jsx(Gr,{}),minPointSize:1,children:t.data.map((i,n)=>jsx(Cell,{fill:i.volume>0?o.profit:o.loss,opacity:i.opacity},`cell-${n}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(i,n)=>e?`${n*100}`:Ur(i,a),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"rgb(229, 231, 235)",strokeOpacity:.2})]})})})};function Ur(t,o=0){let e=["","K","M","B","T"],r=0;for(;t>=1e3&&r<e.length-1;)t/=1e3,r++;return `${Yr(t,o)}${e[r]}`}function Yr(t,o){let e=t.toString(),r=e.indexOf(".");if(r===-1||o===0)return e.split(".")[0];let a=r+o+1;return e.slice(0,a)}var vt=Tt(gt()),jr=()=>(0, vt.default)(function({addComponents:t,addBase:o}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});export{Tr as AssetAreaChart,dr as AssetLineChart,w as ChartEmptyState,zo as CombinedFeesChart,Ze as CombinedPnLChart,or as CombinedPriceChart,bo as CombinedVolumeChart,Ht as PnLBarChart,Ae as PnlAreaChart,me as PnlLineChart,Wr as VolBarChart,jr as chartPlugin};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import {useMemo,useRef,useId}from'react';import {ResponsiveContainer,BarChart,Tooltip,CartesianGrid,ReferenceLine,Bar,Cell,YAxis,XAxis,LineChart,Line,AreaChart,Area,ComposedChart,Cross}from'recharts';export{Area,AreaChart,Bar,BarChart,Cell,Line,LineChart}from'recharts';import {useTranslation}from'@kodiak-finance/orderly-i18n';import {cn,useScreen,Box,Flex,BarChartIcon,Text}from'@kodiak-finance/orderly-ui';import {numberToHumanStyle}from'@kodiak-finance/orderly-utils';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var St=Object.create;var it=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var H=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var zt=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Bt(o))!Kt.call(t,r)&&r!==e&&it(t,r,{get:()=>o[r],enumerable:!(a=It(o,r))||a.enumerable});return t};var $t=(t,o,e)=>(e=t!=null?St(Vt(t)):{},zt(!t||!t.__esModule?it(e,"default",{value:t,enumerable:true}):e,t));var wt=H(ot=>{Object.defineProperty(ot,"__esModule",{value:true});Object.defineProperty(ot,"default",{enumerable:true,get:function(){return ha}});function Tt(t,o){return {handler:t,config:o}}Tt.withOptions=function(t,o=()=>({})){let e=function(a){return {__options:a,handler:t(a),config:o(a)}};return e.__isOptionsFunction=true,e.__pluginFunction=t,e.__configFunction=o,e};var ha=Tt;});var Lt=H(rt=>{Object.defineProperty(rt,"__esModule",{value:true});Object.defineProperty(rt,"default",{enumerable:true,get:function(){return ba}});var ya=Ca(wt());function Ca(t){return t&&t.__esModule?t:{default:t}}var ba=ya.default;});var Nt=H((_n,Dt)=>{var at=Lt();Dt.exports=(at.__esModule?at:{default:at}).default;});var D=t=>{let o=Math.abs(t),e=o===0?0:o<=10?2:o<=100?1:0,a=numberToHumanStyle(o,e);return t<0?`-${a}`:a};var k=t=>{let{label:o,value:e,prefix:a,unit:r="USDC",coloring:i=false,dp:n,rm:l}=t;return jsxs(Box,{intensity:600,p:3,r:"md",children:[jsxs(Flex,{direction:"row",className:t.titleClassName,children:[a,jsx(Text.numeral,{unit:r,as:"div",size:"sm",coloring:i,showIdentifier:i,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:l,dp:n,children:e})]}),jsx(Text,{size:"2xs",intensity:54,weight:"semibold",children:o})]})};var ct=()=>{let t=document.documentElement,o=getComputedStyle(t);return {primary:S(o.getPropertyValue("--oui-color-primary")),primaryLight:S(o.getPropertyValue("--oui-color-primary-light")),secondary:S(o.getPropertyValue("--oui-color-secondary")),success:S(o.getPropertyValue("--oui-color-success")),warning:S(o.getPropertyValue("--oui-color-warning")),danger:S(o.getPropertyValue("--oui-color-danger")),info:S(o.getPropertyValue("--oui-color-info")),loss:S(o.getPropertyValue("--oui-color-trading-loss")),profit:S(o.getPropertyValue("--oui-color-trading-profit"))}},S=t=>`rgb(${t.split(" ").join(",")})`;var p=t=>useMemo(()=>{let e=ct();return {profit:t?.profit||e.profit,loss:t?.loss||e.loss,primary:e.primary,primaryLight:e.primaryLight}},[t]);var oe=t=>{let{fill:o,x:e,y:a,width:r,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:o})},re=t=>{let{x:o,y:e,stroke:a,payload:r,index:i,width:n,containerWidth:l}=t,{t:s}=useTranslation(),h=i===0?48:l>0?l-10:n+r.offset;return jsx("g",{transform:`translate(${h},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:i===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?r.value:s("chart.now")})})},ae=t=>{let{width:o,height:e,stroke:a,fill:r}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ie=t=>{let{active:o,payload:e,label:a}=t,r=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(k,{label:a===r.current?i("chart.now"):a,value:e[0].value,coloring:true}):null},ne=t=>{let{invisible:o,data:e,responsiveContainerProps:a}=t,r=p(t.colors),i=useRef(0);return jsx(ResponsiveContainer,{className:cn(o&&"chart-invisible"),onResize:n=>{i.current=n;},...a,children:jsxs(BarChart,{data:e,margin:{left:-10,top:10,right:10,bottom:30},children:[!o&&jsx(Tooltip,{cursor:jsx(ae,{}),content:jsx(ie,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!o&&jsx(Bar,{dataKey:"pnl",shape:jsx(oe,{}),children:e.map((n,l)=>jsx(Cell,{fill:n.pnl>0?r.profit:r.loss},`cell-${l}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:n=>D(n),tickLine:false,axisLine:false,dataKey:"pnl"}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:e.length-2,height:1,tick:jsx(re,{containerWidth:i.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var I=t=>{let{x:o,y:e,stroke:a,payload:r,index:i}=t,{t:n}=useTranslation();return jsx("g",{transform:`translate(${o},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?r.value:n("chart.now")})})};var xe=t=>{let{active:o,payload:e,label:a}=t,r=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(k,{label:a===r.current?i("chart.now"):a,value:e[0].value,coloring:true}):null},ve=t=>{let o=[];return t?.reduce((e,a)=>(e+=a.pnl,o.push({...a,pnl:e,_pnl:a.pnl}),e),0),o},Fe=t=>{let{responsiveContainerProps:o}=t,e=p(t.colors),{isMobile:a}=useScreen(),r=useMemo(()=>ve(t.data),[t.data]),i=jsxs(LineChart,{data:r,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(I,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:D}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(xe,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Be=t=>{let{active:o,payload:e,label:a}=t,r=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(k,{label:a===r.current?i("chart.now"):a,value:e[0].value,coloring:true}):null},Ve=t=>{let o=[];return t?.reduce((e,a)=>(e+=a.pnl,o.push({...a,pnl:e,_pnl:a.pnl}),e),0),o},Ke=t=>{let{responsiveContainerProps:o}=t,e=p(t.colors),{isMobile:a}=useScreen(),r=useId(),i=useMemo(()=>Ve(t.data),[t.data]),n=jsxs(AreaChart,{data:i,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(I,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:D}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(Be,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#608CFF",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#608CFF",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${r})`})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:n})};var V=({title:t="No Data Available",description:o="No data to display for the selected period",height:e="300px",className:a})=>jsx(Box,{className:cn("oui-w-full oui-flex oui-items-center oui-justify-center oui-bg-base-8",a),style:{height:e},children:jsxs(Flex,{direction:"column",itemAlign:"center",gap:3,className:"oui-text-center",children:[jsx(BarChartIcon,{}),jsx(Text,{as:"div",size:"sm",weight:"semibold",className:"oui-text-base-contrast-100",children:t}),jsx(Text,{as:"div",size:"xs",className:"oui-text-base-contrast-54",children:o})]})});var ao=t=>{let{fill:o,x:e,y:a,width:r,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:o})},io=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ft=t=>`${t>0?"+":""}${t.toFixed(2)}`,ht=(t,o)=>t===0?"inherit":t>0?o.profit:o.loss,no=t=>{let{active:o,payload:e,label:a}=t,r=p();if(o&&e&&e.length>=1){let n=e.find(u=>u.dataKey==="pnl")?.value??0,s=e.find(u=>u.dataKey==="cumulativePnL")?.value??0,h=a,R=ht(n,r);ht(s,r);return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[h,":"," ",jsxs("span",{style:{color:R},children:[ft(n)," USDC"]})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[ft(s)," USDC"]})]})]})}return null},so=(t,o,e=false)=>{if(t<=12&&!e)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,e&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(o==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(o==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(o==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},lo=t=>{let o=0;return t.map(e=>(o+=e.pnl,{...e,cumulativePnL:o}))},co=t=>{let{data:o,aggregationWindow:e="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n}=t,l=p(t.colors),s=useMemo(()=>lo(o),[o]),h=useMemo(()=>so(s.length,e,a),[s.length,e,a]),R=useMemo(()=>{if(s.length===0)return [0,1];let c=s.map($=>$.pnl),u=s.map($=>$.cumulativePnL),v=Math.min(...c,...u,0),N=Math.max(...c,...u,0),F=N-v;if(F===0)return [0,1];let A=F*.1,T=v-A,w=N+A,O=Math.pow(10,Math.floor(Math.log10(F))),L=Math.ceil((w-T)/5/O)*O,z=Math.floor(T/L)*L,Y=Math.ceil(w/L)*L;return [z,Y]},[s]);return r||s.length===0?jsx(V,{title:"No P&L Data",description:"No profit and loss data available for the selected period",height:"100%",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsx("defs",{children:jsxs("linearGradient",{id:"cumulativeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"5%",stopColor:"#608CFF",stopOpacity:.4}),jsx("stop",{offset:"95%",stopColor:"#608CFF",stopOpacity:0})]})}),jsx(Tooltip,{cursor:jsx(io,{}),content:jsx(no,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.3)",strokeWidth:2,strokeDasharray:"4 4"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:c=>mo(c),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"pnl",shape:jsx(ao,{}),minPointSize:1,isAnimationActive:false,children:s.map((c,u)=>jsx(Cell,{fill:c.pnl===0?"rgba(255,255,255,0.2)":c.pnl>0?l.profit:l.loss},`cell-${u}`))}),jsx(Area,{type:"natural",dataKey:"cumulativePnL",fill:"url(#cumulativeGradient)",stroke:"none",isAnimationActive:false}),jsx(Line,{type:"natural",dataKey:"cumulativePnL",stroke:l.primary,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function mo(t){let o=["","K","M","B","T"],e=0,a=Math.abs(t);for(;a>=1e3&&e<o.length-1;)a/=1e3,e++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${o[e]}`}var ko=t=>{let{fill:o,x:e,y:a,width:r,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:o})},Po=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Ct=t=>`${t>0?"+":""}${t}`,Mo=t=>{let{active:o,payload:e,label:a}=t;if(o&&e&&e.length>=1){let i=e.find(h=>h.dataKey==="volume")?.value??0,l=e.find(h=>h.dataKey==="cumulativeVolume")?.value??0;return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[a,": ",Ct(i)," USDC"]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[Ct(l)," USDC"]})]})]})}return null},Ro=(t,o,e=false)=>{if(t<=12&&!e)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,e&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(o==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(o==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(o==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},Ao=t=>{let o=0;return t.map(e=>(o+=e.volume,{...e,cumulativeVolume:o}))},To=t=>{let{data:o,aggregationWindow:e="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n}=t,l=p(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),s=useMemo(()=>Ao(o),[o]),h=useMemo(()=>Ro(s.length,e,a),[s.length,e,a]),R=useMemo(()=>{if(s.length===0)return [0,1];let c=s.map(O=>O.volume),u=Math.max(...c,0),v=u;if(v===0)return [0,1];let N=v*.1,F=u+N,A=Math.pow(10,Math.floor(Math.log10(v))),T=Math.ceil(F/5/A)*A;return [0,Math.ceil(F/T)*T]},[s]);return r||s.length===0?jsx(V,{title:"No Volume Data",description:"No trading volume data available for the selected period",height:"100%",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsx(Tooltip,{cursor:jsx(Po,{}),content:jsx(Mo,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:c=>wo(c),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"volume",shape:jsx(ko,{}),minPointSize:1,isAnimationActive:false,children:s.map((c,u)=>jsx(Cell,{fill:c.volume===0?"rgba(255,255,255,0.2)":l.profit,opacity:.8},`cell-${u}`))})]})})})};function wo(t){let o=["","K","M","B","T"],e=0,a=Math.abs(t);for(;a>=1e3&&e<o.length-1;)a/=1e3,e++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${o[e]}`}var Eo=t=>{let{fill:o,x:e,y:a,width:r,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?a:a+i,width:r,height:n,stroke:"none",fill:o})},Uo=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},gt=t=>`${t>0?"+":""}${t.toFixed(2)}`,Wo=t=>{let{active:o,payload:e,label:a}=t;if(o&&e&&e.length>=1){let i=e.find(h=>h.dataKey==="fees")?.value??0,l=e.find(h=>h.dataKey==="cumulativeFees")?.value??0;return jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-font-semibold",children:[a,": ",gt(i)," USDC"]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Cumulative:"}),jsxs("span",{className:"oui-font-semibold",children:[gt(l)," USDC"]})]})]})}return null},Xo=(t,o,e=false)=>{if(t<=12&&!e)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,e&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(o==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(o==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(o==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r},Yo=t=>{let o=0;return t.map(e=>(o+=e.fees,{...e,cumulativeFees:o}))},Ho=t=>{let{data:o,aggregationWindow:e="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n}=t,l=p(t.colors?{profit:t.colors.fill,loss:t.colors.fill}:void 0),s=useMemo(()=>Yo(o),[o]),h=useMemo(()=>Xo(s.length,e,a),[s.length,e,a]),R=useMemo(()=>{if(s.length===0)return [0,1];let c=s.map($=>$.fees),u=s.map($=>$.cumulativeFees),v=Math.min(...c,...u,0),N=Math.max(...c,...u,0),F=N-v;if(F===0)return [0,1];let A=F*.1,T=v-A,w=N+A,O=Math.pow(10,Math.floor(Math.log10(F))),L=Math.ceil((w-T)/5/O)*O,z=Math.floor(T/L)*L,Y=Math.ceil(w/L)*L;return [z,Y]},[s]);return r||s.length===0?jsx(V,{title:"No Fees Data",description:"No fees data available for the selected period",height:"100%",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:s,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsx("defs",{children:jsxs("linearGradient",{id:"feesGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"5%",stopColor:"#FF6B6B",stopOpacity:.4}),jsx("stop",{offset:"95%",stopColor:"#FF6B6B",stopOpacity:0})]})}),jsx(Tooltip,{cursor:jsx(Uo,{}),content:jsx(Wo,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:R,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:c=>qo(c),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:h,minTickGap:30,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Bar,{dataKey:"fees",shape:jsx(Eo,{}),minPointSize:1,isAnimationActive:false,children:s.map((c,u)=>jsx(Cell,{fill:c.fees===0?"rgba(255,255,255,0.2)":l.loss,opacity:.8},`cell-${u}`))}),jsx(Area,{type:"natural",dataKey:"cumulativeFees",fill:"url(#feesGradient)",stroke:"none",isAnimationActive:false}),jsx(Line,{type:"natural",dataKey:"cumulativeFees",stroke:l.loss,strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};function qo(t){let o=["","K","M","B","T"],e=0,a=Math.abs(t);for(;a>=1e3&&e<o.length-1;)a/=1e3,e++;let r=t<0?"-":"",i=a<=10?1:0,n=a.toFixed(i);return `${r}${n}${o[e]}`}var nr=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},sr=t=>{let{active:o,payload:e,label:a}=t;if(o&&e&&e.length>=1){let r=e[0].payload;return r.close!==null&&r.close!==void 0?jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Open:"}),jsx("span",{className:"oui-font-semibold",children:r.open?.toFixed(2)??"--"})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"High:"}),jsx("span",{className:"oui-font-semibold",children:r.high?.toFixed(2)??"--"})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Low:"}),jsx("span",{className:"oui-font-semibold",children:r.low?.toFixed(2)??"--"})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Close:"}),jsx("span",{className:"oui-font-semibold",children:r.close.toFixed(2)})]}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Time:"}),jsx("span",{className:"oui-font-semibold",children:a})]})]}):jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsx("div",{className:"oui-text-xs oui-text-base-contrast-54",children:"Price data unavailable"}),jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2 oui-mt-1 oui-pt-2 oui-border-t oui-border-base-contrast-16",children:[jsx("span",{className:"oui-text-base-contrast-54",children:"Time:"}),jsx("span",{className:"oui-font-semibold",children:a})]})]})}return null},lr=(t,o,e=false)=>{if(t<=12&&!e)return 0;let a;t>500||t>200?a=6:t>100?a=7:t>50?a=8:a=12,e&&(a=Math.ceil(a/2));let r=Math.ceil(t/a);if(o==="15m")return r>=96?Math.ceil(r/56)*56:r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/16)*16:Math.max(8,Math.ceil(r/4)*4);if(o==="1h")return r>=48?Math.ceil(r/28)*28:r>=24?Math.ceil(r/12)*12:Math.max(4,Math.ceil(r/4)*4);if(o==="1d"){if(r>=14)return Math.ceil(r/14)*14;if(r>=3)return Math.ceil(r/7)*7}return r};function cr(t){return t.toFixed(2)}var mr=t=>{let {data:o,aggregationWindow:e="1d",isMobile:a=false,invisible:r,responsiveContainerProps:i,className:n}=t;p();let s=useMemo(()=>lr(o.length,e,a),[o.length,e,a]),h=useMemo(()=>{if(o.length===0)return [0,1];let R=o.map(z=>z.close).filter(z=>z!=null);if(R.length===0)return [0,1];let c=Math.min(...R),u=Math.max(...R),v=u-c;if(v===0)return [c-1,u+1];let N=v*.1,F=c-N,A=u+N,T=Math.pow(10,Math.floor(Math.log10(v))),w=Math.ceil((A-F)/5/T)*T,O=Math.floor(F/w)*w,L=Math.ceil(A/w)*w;return [O,L]},[o]);return r||o.length===0?jsx(V,{title:"No Price Data",description:"No price data available for the selected period",height:"100%",className:n}):jsx(Box,{className:cn("oui-w-full oui-h-full",n),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",...i,children:jsxs(ComposedChart,{data:o,margin:{left:45,top:10,right:50,bottom:20},syncId:"symbol-performance",children:[jsx(Tooltip,{cursor:jsx(nr,{}),content:jsx(sr,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(YAxis,{domain:h,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:cr,width:50}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:s,minTickGap:50,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(Line,{type:"natural",dataKey:"close",stroke:"#00B49E",strokeWidth:2,dot:false,isAnimationActive:false,strokeLinecap:"round",strokeLinejoin:"round"})]})})})};var vr=t=>{let{active:o,payload:e,label:a}=t,r=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(k,{label:a===r.current?i("chart.now"):a,value:e[0].value}):null},Fr=t=>{let{responsiveContainerProps:o}=t,e=p(t.colors),a=useId(),{isMobile:r}=useScreen(),i=r?jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(I,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:n=>D(n)}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`})]})]}):jsxs(LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(I,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:D}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(vr,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Ir=t=>{let{active:o,payload:e,label:a}=t,r=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return o&&e&&e.length?jsx(k,{label:a===r.current?i("chart.now"):a,value:e[0].value}):null},Br=t=>{let{responsiveContainerProps:o}=t,e=p(t.colors),a=useId(),{isMobile:r}=useScreen(),i=jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(I,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:D}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(Ir,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:r?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...o,children:i})};var Qr=t=>{let{fill:o,x:e,y:a,width:r,height:i,opacity:n}=t,l=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?a:a+i,width:r,height:l,stroke:"none",fill:o,opacity:n})},Jr=t=>{let{width:o,height:e,payload:a,stroke:r,fill:i}=t;return a?.[0]?.value===0?null:jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Zr=t=>{let{active:o,payload:e,label:a,tooltip:r}=t;return e?.[0]?.value===0?null:o&&e&&e.length?jsx(k,{label:a,value:e[0].value,titleClassName:"oui-gap-4",rm:r?.rm,dp:r?.dp}):null},jr=t=>{let o=p(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),e=t.data?.reduce((i,n)=>i+n.volume,0)===0,a=t.data?.reduce((i,n)=>i>n.volume?i:n.volume,0),r=a<=10?2:a<=100?1:0;return jsx(Box,{className:cn(t.className),children:jsx(ResponsiveContainer,{children:jsxs(BarChart,{data:t.data,margin:{left:-0,top:6,right:0,bottom:20},children:[jsx(Tooltip,{cursor:jsx(Jr,{}),content:jsx(Zr,{tooltip:t.tooltip})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsx(ReferenceLine,{y:0,stroke:"#000"}),jsx(Bar,{dataKey:"volume",shape:jsx(Qr,{}),minPointSize:1,children:t.data.map((i,n)=>jsx(Cell,{fill:i.volume>0?o.profit:o.loss,opacity:i.opacity},`cell-${n}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(i,n)=>e?`${n*100}`:ta(i,r),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"rgb(229, 231, 235)",strokeOpacity:.2})]})})})};function ta(t,o=0){let e=["","K","M","B","T"],a=0;for(;t>=1e3&&a<e.length-1;)t/=1e3,a++;return `${ea(t,o)}${e[a]}`}function ea(t,o){let e=t.toString(),a=e.indexOf(".");if(a===-1||o===0)return e.split(".")[0];let r=a+o+1;return e.slice(0,r)}var pa=t=>{let{width:o,height:e}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},da=t=>{let{active:o,payload:e,label:a}=t;return o&&e&&e.length>0?jsxs(Box,{intensity:600,p:3,r:"md",className:"oui-flex oui-flex-col oui-gap-2",children:[jsx("div",{className:"oui-text-xs oui-font-semibold",children:a}),e.map((r,i)=>jsxs("div",{className:"oui-text-xs oui-flex oui-gap-2",children:[jsxs("span",{style:{color:r.color},className:"oui-font-semibold",children:[r.name,":"]}),jsx("span",{children:r.value?.toFixed(2)||0})]},i))]}):null},fa=({volumeData:t,feesData:o,priceData:e,aggregationWindow:a,includeFees:r,className:i})=>{let n=useMemo(()=>{let l=new Map;return t.forEach(s=>{l.set(s.date,{...l.get(s.date),date:s.date,volume:s.volume});}),o.forEach(s=>{l.set(s.date,{...l.get(s.date),date:s.date,fees:s.fees});}),e.forEach(s=>{l.set(s.date,{...l.get(s.date),date:s.date,open:s.open,high:s.high,low:s.low,close:s.close});}),Array.from(l.values())},[t,o,e]);return n.length===0?jsx(Box,{className:cn("oui-w-full oui-h-full",i),children:jsx("div",{className:"oui-text-center oui-text-base-contrast-54 oui-py-10",children:"No data available"})}):jsx(Box,{className:cn("oui-w-full oui-h-full",i),children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(ComposedChart,{data:n,margin:{left:0,top:10,right:10,bottom:20},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",tickLine:false,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{yAxisId:"left",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,width:45,label:{value:"Volume / Fees",angle:-90,position:"insideLeft"}}),jsx(YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,width:50,label:{value:"Price",angle:90,position:"insideRight"}}),jsx(Tooltip,{cursor:jsx(pa,{}),content:jsx(da,{})}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),jsx(Bar,{yAxisId:"left",dataKey:"volume",fill:"rgba(0, 180, 158, 0.6)",name:"Volume"}),jsx(Bar,{yAxisId:"left",dataKey:"fees",fill:"rgba(255, 107, 107, 0.6)",name:"Fees"}),jsx(Line,{yAxisId:"right",type:"natural",dataKey:"close",stroke:"#00B49E",strokeWidth:2,dot:false,isAnimationActive:false,name:"Price",strokeLinecap:"round",strokeLinejoin:"round"})]})})})};var Ot=$t(Nt()),ga=()=>(0, Ot.default)(function({addComponents:t,addBase:o}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});export{Br as AssetAreaChart,Fr as AssetLineChart,V as ChartEmptyState,Ho as CombinedFeesChart,co as CombinedPnLChart,mr as CombinedPriceChart,To as CombinedVolumeChart,ne as PnLBarChart,Ke as PnlAreaChart,Fe as PnlLineChart,fa as UnifiedSymbolPerformanceChart,jr as VolBarChart,ga as chartPlugin};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|