@orderly.network/chart 2.0.3 → 2.0.4-alpha.0

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.js CHANGED
@@ -6,7 +6,7 @@ var ui = require('@orderly.network/ui');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var utils = require('@orderly.network/utils');
8
8
 
9
- var N=Object.create;var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var $=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!K.call(t,i)&&i!==r&&k(t,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return t};var M=(t,e,r)=>(r=t!=null?N(I(t)):{},$(!t||!t.__esModule?k(r,"default",{value:t,enumerable:!0}):r,t));var _=g(x=>{Object.defineProperty(x,"__esModule",{value:!0});Object.defineProperty(x,"default",{enumerable:!0,get:function(){return Jt}});function S(t,e){return {handler:t,config:e}}S.withOptions=function(t,e=()=>({})){let r=function(o){return {__options:o,handler:t(o),config:e(o)}};return r.__isOptionsFunction=!0,r.__pluginFunction=t,r.__configFunction=e,r};var Jt=S;});var O=g(b=>{Object.defineProperty(b,"__esModule",{value:!0});Object.defineProperty(b,"default",{enumerable:!0,get:function(){return te}});var Zt=jt(_());function jt(t){return t&&t.__esModule?t:{default:t}}var te=Zt.default;});var R=g((Qe,A)=>{var C=O();A.exports=(C.__esModule?C:{default:C}).default;});var v=()=>{let t=document.documentElement,e=getComputedStyle(t);return {primary:u(e.getPropertyValue("--oui-color-primary")),primaryLight:u(e.getPropertyValue("--oui-color-primary-light")),secondary:u(e.getPropertyValue("--oui-color-secondary")),success:u(e.getPropertyValue("--oui-color-success")),warning:u(e.getPropertyValue("--oui-color-warning")),danger:u(e.getPropertyValue("--oui-color-danger")),info:u(e.getPropertyValue("--oui-color-info")),loss:u(e.getPropertyValue("--oui-color-trading-loss")),profit:u(e.getPropertyValue("--oui-color-trading-profit"))}},u=t=>`rgb(${t.split(" ").join(",")})`;var f=t=>react.useMemo(()=>{let r=v();return {profit:t?.profit||r.profit,loss:t?.loss||r.loss,primary:r.primary,primaryLight:r.primaryLight}},[t]);var d=t=>{let{label:e,value:r,prefix:o,unit:i="USDC",coloring:a=!1,dp:n,rm:c}=t;return jsxRuntime.jsxs(ui.Box,{intensity:600,p:3,r:"md",children:[jsxRuntime.jsxs(ui.Flex,{direction:"row",className:t.titleClassName,children:[o,jsxRuntime.jsx(ui.Text.numeral,{unit:i,as:"div",size:"sm",coloring:a,showIdentifier:a,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:c,dp:n,children:r})]}),jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:54,weight:"semibold",children:e})]})};var h=t=>{let e=Math.abs(t),r=e===0?0:e<=10?2:e<=100?1:0,o=utils.numberToHumanStyle(e,r);return t<0?`-${o}`:o};var ot=t=>{let{fill:e,x:r,y:o,width:i,height:a}=t,n=Math.abs(a);return jsxRuntime.jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:n,stroke:"none",fill:e})},it=t=>{let{x:e,y:r,stroke:o,payload:i,index:a,width:n,containerWidth:c}=t,V=a===0?48:c>0?c-10:n+i.offset;return jsxRuntime.jsx("g",{transform:`translate(${V},${r-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:a===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})},at=t=>{let{width:e,height:r,stroke:o,fill:i}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},nt=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:!0}):null},lt=t=>{let{invisible:e}=t,r=f(t.colors),o=react.useRef(0);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:ui.cn(e&&"chart-invisible"),onResize:(i,a)=>{o.current=i;},children:jsxRuntime.jsxs(recharts.BarChart,{data:t.data,margin:{left:-10,top:10,right:10,bottom:30},children:[!e&&jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(at,{}),content:jsxRuntime.jsx(nt,{})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!e&&jsxRuntime.jsx(recharts.Bar,{dataKey:"pnl",shape:jsxRuntime.jsx(ot,{}),children:t.data.map((i,a)=>jsxRuntime.jsx(recharts.Cell,{fill:i.pnl>0?r.profit:r.loss},`cell-${a}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:i=>h(i),tickLine:!1,axisLine:!1,dataKey:"pnl"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:!1,interval:t.data.length-2,height:1,tick:jsxRuntime.jsx(it,{containerWidth:o.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var y=t=>{let{x:e,y:r,stroke:o,payload:i,index:a}=t;return jsxRuntime.jsx("g",{transform:`translate(${e},${r-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})};var xt=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:!0}):null},bt=t=>{let e=f(t.colors),r=i=>{let a=[];return i?.reduce((n,c)=>(n+=c.pnl,a.push({...c,pnl:n,_pnl:c.pnl}),n),0),a},o=react.useMemo(()=>r(t.data),[t.data]);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxRuntime.jsxs(recharts.LineChart,{data:o,margin:{top:20,right:10,left:-10,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,tickFormatter:i=>h(i)}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(xt,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:2,dot:!1,isAnimationActive:!1})]})})};var _t=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value}):null},Ot=t=>{let e=f(t.colors);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxRuntime.jsxs(recharts.LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,tickFormatter:r=>h(r)}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(_t,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:2,dot:!1,isAnimationActive:!1})]})})};var Gt=t=>{let{fill:e,x:r,y:o,width:i,height:a,opacity:n}=t,c=Math.abs(a);return jsxRuntime.jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:c,stroke:"none",fill:e,opacity:n})},Wt=t=>{let{width:e,height:r,payload:o,stroke:i,fill:a}=t;return o?.[0]?.value===0?null:jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Yt=t=>{let{active:e,payload:r,label:o,tooltip:i}=t;return r?.[0]?.value===0?null:e&&r&&r.length?jsxRuntime.jsx(d,{label:o,value:r[0].value,titleClassName:"oui-gap-4",rm:i?.rm,dp:i?.dp}):null},qt=t=>{let e=f(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),r=t.data.reduce((a,n)=>a+n.volume,0)===0,o=t.data.reduce((a,n)=>a>n.volume?a:n.volume,0),i=o<=10?2:o<=100?1:0;return jsxRuntime.jsx(ui.Box,{className:ui.cn(t.className),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{children:jsxRuntime.jsxs(recharts.BarChart,{data:t.data,margin:{left:-0,top:6,right:0,bottom:20},children:[jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(Wt,{}),content:jsxRuntime.jsx(Yt,{tooltip:t.tooltip})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"#000"}),jsxRuntime.jsx(recharts.Bar,{dataKey:"volume",shape:jsxRuntime.jsx(Gt,{}),minPointSize:1,children:t.data.map((a,n)=>jsxRuntime.jsx(recharts.Cell,{fill:a.volume>0?e.profit:e.loss,opacity:a.opacity},`cell-${n}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,dataKey:"volume",tickFormatter:(a,n)=>r?`${n*100}`:Et(a,i),width:45}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:!1,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 Et(t,e=0){let r=["","K","M","B","T"],o=0;for(;t>=1e3&&o<r.length-1;)t/=1e3,o++;return `${Qt(t,e)}${r[o]}`}function Qt(t,e){let r=t.toString(),o=r.indexOf(".");if(o===-1||e===0)return r.split(".")[0];let i=o+e+1;return r.slice(0,i)}var B=M(R()),ee=()=>(0, B.default)(function({addComponents:t,addBase:e}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:!1});});
9
+ var N=Object.create;var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var $=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!K.call(t,i)&&i!==r&&k(t,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return t};var M=(t,e,r)=>(r=t!=null?N(I(t)):{},$(!t||!t.__esModule?k(r,"default",{value:t,enumerable:true}):r,t));var _=g(x=>{Object.defineProperty(x,"__esModule",{value:true});Object.defineProperty(x,"default",{enumerable:true,get:function(){return Jt}});function S(t,e){return {handler:t,config:e}}S.withOptions=function(t,e=()=>({})){let r=function(o){return {__options:o,handler:t(o),config:e(o)}};return r.__isOptionsFunction=true,r.__pluginFunction=t,r.__configFunction=e,r};var Jt=S;});var O=g(b=>{Object.defineProperty(b,"__esModule",{value:true});Object.defineProperty(b,"default",{enumerable:true,get:function(){return te}});var Zt=jt(_());function jt(t){return t&&t.__esModule?t:{default:t}}var te=Zt.default;});var R=g((Qe,A)=>{var C=O();A.exports=(C.__esModule?C:{default:C}).default;});var v=()=>{let t=document.documentElement,e=getComputedStyle(t);return {primary:u(e.getPropertyValue("--oui-color-primary")),primaryLight:u(e.getPropertyValue("--oui-color-primary-light")),secondary:u(e.getPropertyValue("--oui-color-secondary")),success:u(e.getPropertyValue("--oui-color-success")),warning:u(e.getPropertyValue("--oui-color-warning")),danger:u(e.getPropertyValue("--oui-color-danger")),info:u(e.getPropertyValue("--oui-color-info")),loss:u(e.getPropertyValue("--oui-color-trading-loss")),profit:u(e.getPropertyValue("--oui-color-trading-profit"))}},u=t=>`rgb(${t.split(" ").join(",")})`;var f=t=>react.useMemo(()=>{let r=v();return {profit:t?.profit||r.profit,loss:t?.loss||r.loss,primary:r.primary,primaryLight:r.primaryLight}},[t]);var d=t=>{let{label:e,value:r,prefix:o,unit:i="USDC",coloring:a=false,dp:n,rm:c}=t;return jsxRuntime.jsxs(ui.Box,{intensity:600,p:3,r:"md",children:[jsxRuntime.jsxs(ui.Flex,{direction:"row",className:t.titleClassName,children:[o,jsxRuntime.jsx(ui.Text.numeral,{unit:i,as:"div",size:"sm",coloring:a,showIdentifier:a,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:c,dp:n,children:r})]}),jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:54,weight:"semibold",children:e})]})};var h=t=>{let e=Math.abs(t),r=e===0?0:e<=10?2:e<=100?1:0,o=utils.numberToHumanStyle(e,r);return t<0?`-${o}`:o};var ot=t=>{let{fill:e,x:r,y:o,width:i,height:a}=t,n=Math.abs(a);return jsxRuntime.jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:n,stroke:"none",fill:e})},it=t=>{let{x:e,y:r,stroke:o,payload:i,index:a,width:n,containerWidth:c}=t,V=a===0?48:c>0?c-10:n+i.offset;return jsxRuntime.jsx("g",{transform:`translate(${V},${r-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:a===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})},at=t=>{let{width:e,height:r,stroke:o,fill:i}=t;return jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},nt=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:true}):null},lt=t=>{let{invisible:e}=t,r=f(t.colors),o=react.useRef(0);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:ui.cn(e&&"chart-invisible"),onResize:(i,a)=>{o.current=i;},children:jsxRuntime.jsxs(recharts.BarChart,{data:t.data,margin:{left:-10,top:10,right:10,bottom:30},children:[!e&&jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(at,{}),content:jsxRuntime.jsx(nt,{})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!e&&jsxRuntime.jsx(recharts.Bar,{dataKey:"pnl",shape:jsxRuntime.jsx(ot,{}),children:t.data.map((i,a)=>jsxRuntime.jsx(recharts.Cell,{fill:i.pnl>0?r.profit:r.loss},`cell-${a}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:i=>h(i),tickLine:false,axisLine:false,dataKey:"pnl"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:jsxRuntime.jsx(it,{containerWidth:o.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var y=t=>{let{x:e,y:r,stroke:o,payload:i,index:a}=t;return jsxRuntime.jsx("g",{transform:`translate(${e},${r-6})`,children:jsxRuntime.jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})};var xt=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:true}):null},bt=t=>{let e=f(t.colors),r=i=>{let a=[];return i?.reduce((n,c)=>(n+=c.pnl,a.push({...c,pnl:n,_pnl:c.pnl}),n),0),a},o=react.useMemo(()=>r(t.data),[t.data]);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxRuntime.jsxs(recharts.LineChart,{data:o,margin:{top:20,right:10,left:-10,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:i=>h(i)}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(xt,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:2,dot:false,isAnimationActive:false})]})})};var _t=t=>{let{active:e,payload:r,label:o}=t,i=react.useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsxRuntime.jsx(d,{label:o===i.current?"Now":o,value:r[0].value}):null},Ot=t=>{let e=f(t.colors);return jsxRuntime.jsx(recharts.ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxRuntime.jsxs(recharts.LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsxRuntime.jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsxRuntime.jsx(recharts.YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:r=>h(r)}),!t.invisible&&jsxRuntime.jsx(recharts.Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsxRuntime.jsx(_t,{})}),!t.invisible&&jsxRuntime.jsx(recharts.Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:2,dot:false,isAnimationActive:false})]})})};var Gt=t=>{let{fill:e,x:r,y:o,width:i,height:a,opacity:n}=t,c=Math.abs(a);return jsxRuntime.jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:c,stroke:"none",fill:e,opacity:n})},Wt=t=>{let{width:e,height:r,payload:o,stroke:i,fill:a}=t;return o?.[0]?.value===0?null:jsxRuntime.jsx(recharts.Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Yt=t=>{let{active:e,payload:r,label:o,tooltip:i}=t;return r?.[0]?.value===0?null:e&&r&&r.length?jsxRuntime.jsx(d,{label:o,value:r[0].value,titleClassName:"oui-gap-4",rm:i?.rm,dp:i?.dp}):null},qt=t=>{let e=f(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),r=t.data.reduce((a,n)=>a+n.volume,0)===0,o=t.data.reduce((a,n)=>a>n.volume?a:n.volume,0),i=o<=10?2:o<=100?1:0;return jsxRuntime.jsx(ui.Box,{className:ui.cn(t.className),children:jsxRuntime.jsx(recharts.ResponsiveContainer,{children:jsxRuntime.jsxs(recharts.BarChart,{data:t.data,margin:{left:-0,top:6,right:0,bottom:20},children:[jsxRuntime.jsx(recharts.Tooltip,{cursor:jsxRuntime.jsx(Wt,{}),content:jsxRuntime.jsx(Yt,{tooltip:t.tooltip})}),jsxRuntime.jsx(recharts.CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"#000"}),jsxRuntime.jsx(recharts.Bar,{dataKey:"volume",shape:jsxRuntime.jsx(Gt,{}),minPointSize:1,children:t.data.map((a,n)=>jsxRuntime.jsx(recharts.Cell,{fill:a.volume>0?e.profit:e.loss,opacity:a.opacity},`cell-${n}`))}),jsxRuntime.jsx(recharts.YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(a,n)=>r?`${n*100}`:Et(a,i),width:45}),jsxRuntime.jsx(recharts.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 Et(t,e=0){let r=["","K","M","B","T"],o=0;for(;t>=1e3&&o<r.length-1;)t/=1e3,o++;return `${Qt(t,e)}${r[o]}`}function Qt(t,e){let r=t.toString(),o=r.indexOf(".");if(o===-1||e===0)return r.split(".")[0];let i=o+e+1;return r.slice(0,i)}var B=M(R()),ee=()=>(0, B.default)(function({addComponents:t,addBase:e}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});
10
10
 
11
11
  exports.AssetLineChart = Ot;
12
12
  exports.PnLBarChart = lt;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/lib/util/createPlugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/lib/public/create-plugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/plugin.js","../src/orderly/useColors.ts","../src/utils/theme.ts","../src/orderly/pnlBar.tsx","../src/orderly/customTooltip.tsx","../src/utils/yTickFormatter.ts","../src/orderly/pnlLine.tsx","../src/orderly/xAxisLabel.tsx","../src/orderly/assetLine.tsx","../src/orderly/volBar.tsx","../src/tailwindcss/theme.ts"],"names":["require_createPlugin","__commonJSMin","exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","require_create_plugin","_createPlugin","_interop_require_default","obj","require_plugin","module","useMemo","getThemeColors","root","computedStyle","convertToRGB","color","useColors","colors","themeColors","BarChart","XAxis","YAxis","ResponsiveContainer","Bar","Cell","Tooltip","CartesianGrid","ReferenceLine","Cross","Box","Flex","Text","jsx","jsxs","OrderlyChartTooltip","props","label","value","prefix","unit","coloring","dp","rm","cn","useRef","numberToHumanStyle","tickFormatter","absValue","formatted","RoundedRectangle","fill","x","y","width","height","absHeight","XAxisLabel","stroke","payload","index","containerWidth","_x","CustomizedCross","CustomTooltip","active","todayStr","PnLBarChart","invisible","widthRef","entry","LineChart","Line","PnlLineChart","dataTransfer","data","series","acc","item","AssetLineChart","opacity","tooltip","VolBarChart","isEmpty","b","maxVolume","decimal","number","decimalPlaces","abbreviations","toFixedWithoutRounding","num","fix","numStr","decimalIndex","cutoffIndex","import_plugin","chartPlugin","addComponents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ject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","import { useMemo } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\n\nexport const useColors = (colors?: { profit: string; loss: string }) => {\n const _colors = useMemo(() => {\n const themeColors = getThemeColors();\n return {\n profit: colors?.profit || themeColors.profit,\n loss: colors?.loss || themeColors.loss,\n primary: themeColors.primary,\n primaryLight: themeColors.primaryLight,\n };\n }, [colors]);\n\n return _colors;\n};\n","export const getThemeColors = () => {\n const root = document.documentElement;\n const computedStyle = getComputedStyle(root);\n\n const colors = {\n primary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary\")\n ),\n primaryLight: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary-light\")\n ),\n secondary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-secondary\")\n ),\n success: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-success\")\n ),\n warning: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-warning\")\n ),\n danger: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-danger\")),\n info: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-info\")),\n loss: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-loss\")\n ),\n profit: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-profit\")\n ),\n };\n\n return colors;\n};\n\nconst convertToRGB = (color: string) => {\n return `rgb(${color.split(\" \").join(\",\")})`;\n};\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\nimport { Flex } from \"@orderly.network/ui\";\n// import { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnLChartDataItem = {\n date: string;\n pnl: number;\n};\n\nexport type PnLChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: PnLChartDataItem[];\n invisible?: boolean;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height } = props;\n\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n />\n );\n};\n\nexport const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index, width, containerWidth } = props;\n\n const _x =\n index === 0\n ? 48\n : containerWidth > 0\n ? containerWidth - 10\n : width + payload.offset;\n\n return (\n <g transform={`translate(${_x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor={index === 0 ? \"start\" : \"end\"}\n // textAnchor={\"start\"}\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, stroke, fill } = props;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nexport const PnLBarChart = (props: PnLChartProps) => {\n const { invisible } = props;\n const colors = useColors(props.colors);\n const widthRef = useRef(0);\n\n return (\n // @ts-ignore\n <ResponsiveContainer\n className={cn(invisible && \"chart-invisible\")}\n onResize={(width, height) => {\n // console.log(\"width\", width, height);\n widthRef.current = width;\n }}\n >\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -10, top: 10, right: 10, bottom: 30 }}\n >\n {!invisible && (\n // @ts-ignore\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip />}\n />\n )}\n\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n <ReferenceLine y={0} stroke=\"rgba(0,0,0,0.04)\" />\n\n {!invisible && (\n // @ts-ignore\n <Bar dataKey=\"pnl\" shape={<RoundedRectangle />}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.pnl > 0 ? colors.profit : colors.loss}\n />\n );\n })}\n </Bar>\n )}\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickFormatter={(value) => tickFormatter(value)}\n tickLine={false}\n axisLine={false}\n dataKey={\"pnl\"}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel containerWidth={widthRef.current} />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n />\n </BarChart>\n </ResponsiveContainer>\n );\n};\n","import { Box, Flex, Text } from \"@orderly.network/ui\";\n\nexport const OrderlyChartTooltip = (props: {\n label: string;\n value: string | number;\n unit?: string;\n prefix?: React.ReactNode;\n titleClassName?: string;\n coloring?: boolean;\n dp?: number;\n rm?: number;\n}) => {\n const {\n label,\n value,\n prefix,\n unit = \"USDC\",\n coloring = false,\n dp,\n rm,\n } = props;\n return (\n <Box intensity={600} p={3} r=\"md\">\n <Flex direction={\"row\"} className={props.titleClassName}>\n {prefix}\n <Text.numeral\n unit={unit}\n as=\"div\"\n size=\"sm\"\n coloring={coloring}\n showIdentifier={coloring}\n unitClassName=\"oui-text-base-contrast-54 oui-ml-1\"\n weight=\"semibold\"\n rm={rm}\n dp={dp}\n >\n {value}\n </Text.numeral>\n </Flex>\n <Text size=\"2xs\" intensity={54} weight=\"semibold\">\n {label}\n </Text>\n </Box>\n );\n};\n","import { numberToHumanStyle } from \"@orderly.network/utils\";\n\nexport const tickFormatter = (value: number) => {\n let absValue = Math.abs(value);\n const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;\n\n const formatted = numberToHumanStyle(absValue, dp);\n return value < 0 ? `-${formatted}` : formatted;\n};\n","import { useMemo, useRef } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\nimport { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n ReferenceLine,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: any;\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nconst PnlLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n const dataTransfer = (data: any[]) => {\n const series: any[] = [];\n\n data?.reduce((acc, item) => {\n acc += item.pnl;\n series.push({\n ...item,\n pnl: acc,\n _pnl: item.pnl,\n // date: new Date(item.date).getTime(),\n });\n return acc;\n }, 0);\n\n return series;\n };\n\n const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n data={data}\n margin={{ top: 20, right: 10, left: -10, bottom: 0 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n // scale={\"time\"}\n // type=\"number\"\n // range={}\n />\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"pnl\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <ReferenceLine y={0} stroke=\"#000\" /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"pnl\"\n stroke={colors.primary}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { PnlLineChart };\n","export const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index } = props;\n\n return (\n <g transform={`translate(${x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor=\"end\"\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n","import { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n Tooltip,\n Label,\n ResponsiveContainer,\n} from \"recharts\";\n\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type AssetChartDataItem = {\n date: string;\n account_value: number;\n};\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: AssetChartDataItem[];\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n />\n );\n }\n\n return null;\n};\n\nconst AssetLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n // const dataTransfer = (data: any[]) => {\n // const series: any[] = [];\n\n // data.reduce((acc, item) => {\n // acc += item.pnl;\n // series.push({ ...item, pnl: acc, _pnl: item.pnl });\n // return acc;\n // }, 0);\n\n // return series;\n // };\n\n // const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n width={530}\n height={180}\n data={props.data}\n margin={{ top: 20, right: 10, left: -20, bottom: -10 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n ></XAxis>\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"account_value\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <Legend /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"account_value\"\n stroke={colors.profit}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { AssetLineChart };\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\n\nexport type VolChartDataItem = {\n date: string;\n volume: number;\n opacity?: string | number;\n};\n\nexport type VolChartTooltip = {\n rm?: number;\n dp?: number;\n};\n\nexport type VolChartProps = {\n colors?: {\n fill: string;\n };\n data: VolChartDataItem[];\n tooltip?: VolChartTooltip;\n className?: string;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height, opacity } = props;\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n opacity={opacity}\n />\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, payload, stroke, fill } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (\n props: TooltipProps<any, any> & { tooltip?: VolChartTooltip }\n) => {\n const { active, payload, label, tooltip } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label}\n value={payload[0].value}\n // prefix=\"Commission\"\n titleClassName=\"oui-gap-4\"\n rm={tooltip?.rm}\n dp={tooltip?.dp}\n />\n );\n }\n\n return null;\n};\n\nexport const VolBarChart = (props: VolChartProps) => {\n const colors = useColors(\n props.colors?.fill\n ? { profit: props.colors?.fill, loss: props.colors?.fill }\n : undefined\n );\n\n const isEmpty = props.data.reduce((a, b) => a + b.volume, 0) === 0;\n const maxVolume = props.data.reduce((a,b) => (a > b.volume ? a : b.volume), 0);\n const decimal = maxVolume <= 10 ? 2 : (maxVolume <= 100 ? 1 : 0);\n\n return (\n // @ts-ignore\n <Box className={cn(props.className)}>\n {/* @ts-ignore */}\n <ResponsiveContainer>\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -0, top: 6, right: 0, bottom: 20 }}\n >\n {/* @ts-ignore */}\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip tooltip={props.tooltip} />}\n />\n <CartesianGrid\n vertical={false}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.08}\n repeatCount={6}\n />\n <ReferenceLine y={0} stroke=\"#000\" />\n {/* @ts-ignore */}\n <Bar dataKey=\"volume\" shape={<RoundedRectangle />} minPointSize={1}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.volume > 0 ? colors.profit : colors.loss}\n opacity={entry.opacity}\n />\n );\n })}\n </Bar>\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n dataKey={\"volume\"}\n tickFormatter={(value, index) => {\n if (isEmpty) return `${index * 100}`;\n return numberToHumanStyle(value, decimal);\n }}\n width={45}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n stroke=\"rgb(229, 231, 235)\"\n strokeOpacity={0.2}\n />\n </BarChart>\n </ResponsiveContainer>\n </Box>\n );\n};\nfunction numberToHumanStyle(number: number, decimalPlaces: number = 0): string {\n const abbreviations = [\"\", \"K\", \"M\", \"B\", \"T\"];\n\n let index = 0;\n while (number >= 1000 && index < abbreviations.length - 1) {\n number /= 1000;\n index++;\n }\n\n const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);\n\n return `${roundedNumber}${abbreviations[index]}`;\n}\n\nfunction toFixedWithoutRounding(num: number, fix: number): string {\n const numStr = num.toString();\n const decimalIndex = numStr.indexOf(\".\");\n\n if (decimalIndex === -1 || fix === 0) {\n return numStr.split(\".\")[0];\n }\n\n const cutoffIndex = decimalIndex + fix + 1;\n\n return numStr.slice(0, cutoffIndex);\n}\n","import plugin from \"tailwindcss/plugin\";\n\nimport { PluginCreator } from \"tailwindcss/types/config\";\n\nexport const chartPlugin: PluginCreator = () =>\n plugin(function ({ addComponents, addBase }) {\n addComponents(\n {\n \".xAxis\": {\n \".recharts-cartesian-axis-tick:first-child text\": {\n \"text-anchor\": \"start\",\n },\n \".recharts-cartesian-axis-tick:last-child text\": {\n \"text-anchor\": \"end\",\n },\n },\n },\n {\n respectPrefix: false,\n }\n );\n });\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/lib/util/createPlugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/lib/public/create-plugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/plugin.js","../src/orderly/useColors.ts","../src/utils/theme.ts","../src/orderly/pnlBar.tsx","../src/orderly/customTooltip.tsx","../src/utils/yTickFormatter.ts","../src/orderly/pnlLine.tsx","../src/orderly/xAxisLabel.tsx","../src/orderly/assetLine.tsx","../src/orderly/volBar.tsx","../src/tailwindcss/theme.ts"],"names":["require_createPlugin","__commonJSMin","exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","require_create_plugin","_createPlugin","_interop_require_default","obj","require_plugin","module","useMemo","getThemeColors","root","computedStyle","convertToRGB","color","useColors","colors","themeColors","BarChart","XAxis","YAxis","ResponsiveContainer","Bar","Cell","Tooltip","CartesianGrid","ReferenceLine","Cross","Box","Flex","Text","jsx","jsxs","OrderlyChartTooltip","props","label","value","prefix","unit","coloring","dp","rm","cn","useRef","numberToHumanStyle","tickFormatter","absValue","formatted","RoundedRectangle","fill","x","y","width","height","absHeight","XAxisLabel","stroke","payload","index","containerWidth","_x","CustomizedCross","CustomTooltip","active","todayStr","PnLBarChart","invisible","widthRef","entry","LineChart","Line","PnlLineChart","dataTransfer","data","series","acc","item","AssetLineChart","opacity","tooltip","VolBarChart","isEmpty","b","maxVolume","decimal","number","decimalPlaces","abbreviations","toFixedWithoutRounding","num","fix","numStr","decimalIndex","cutoffIndex","import_plugin","chartPlugin","addComponents","addBase"],"mappings":"ygBAAA,IAAAA,EAAAC,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CACtC,WAAY,GACZ,IAAK,UAAW,CACZ,OAAOC,EACX,CACJ,CAAC,EACD,SAASC,EAAaC,EAAQC,EAAQ,CAClC,MAAO,CACH,QAASD,EACT,OAAAC,CACJ,CACJ,CACAF,EAAa,YAAc,SAASG,EAAgBC,EAAiB,KAAK,CAAC,GAAI,CAC3E,IAAMC,EAAkB,SAASC,EAAS,CACtC,MAAO,CACH,UAAWA,EACX,QAASH,EAAeG,CAAO,EAC/B,OAAQF,EAAeE,CAAO,CAClC,CACJ,EACA,OAAAD,EAAgB,oBAAsB,GAGtCA,EAAgB,iBAAmBF,EACnCE,EAAgB,iBAAmBD,EAC5BC,CACX,EACA,IAAMN,GAAWC,IC/BjB,IAAAO,EAAAV,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CACtC,WAAY,GACZ,IAAK,UAAW,CACZ,OAAOC,EACX,CACJ,CAAC,EACD,IAAMS,GAA8BC,GAAyB,GAA+B,EAC5F,SAASA,GAAyBC,EAAK,CACnC,OAAOA,GAAOA,EAAI,WAAaA,EAAM,CACjC,QAASA,CACb,CACJ,CACA,IAAMX,GAAWS,GAAc,UChB/B,IAAAG,EAAAd,EAAA,CAAAC,G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EAEzC,OAAOC,EAAO,MAAM,EAAGE,CAAW,CACpC,CCxMA,IAAAC,EAAmB,OAINC,GAA6B,OACxC,EAAAlG,SAAO,SAAU,CAAE,cAAAmG,EAAe,QAAAC,CAAQ,EAAG,CAC3CD,EACE,CACE,SAAU,CACR,iDAAkD,CAChD,cAAe,OACjB,EACA,gDAAiD,CAC/C,cAAe,KACjB,CACF,CACF,EACA,CACE,cAAe,EACjB,CACF,CACF,CAAC","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","import { useMemo } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\n\nexport const useColors = (colors?: { profit: string; loss: string }) => {\n const _colors = useMemo(() => {\n const themeColors = getThemeColors();\n return {\n profit: colors?.profit || themeColors.profit,\n loss: colors?.loss || themeColors.loss,\n primary: themeColors.primary,\n primaryLight: themeColors.primaryLight,\n };\n }, [colors]);\n\n return _colors;\n};\n","export const getThemeColors = () => {\n const root = document.documentElement;\n const computedStyle = getComputedStyle(root);\n\n const colors = {\n primary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary\")\n ),\n primaryLight: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary-light\")\n ),\n secondary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-secondary\")\n ),\n success: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-success\")\n ),\n warning: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-warning\")\n ),\n danger: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-danger\")),\n info: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-info\")),\n loss: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-loss\")\n ),\n profit: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-profit\")\n ),\n };\n\n return colors;\n};\n\nconst convertToRGB = (color: string) => {\n return `rgb(${color.split(\" \").join(\",\")})`;\n};\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\nimport { Flex } from \"@orderly.network/ui\";\n// import { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnLChartDataItem = {\n date: string;\n pnl: number;\n};\n\nexport type PnLChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: PnLChartDataItem[];\n invisible?: boolean;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height } = props;\n\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n />\n );\n};\n\nexport const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index, width, containerWidth } = props;\n\n const _x =\n index === 0\n ? 48\n : containerWidth > 0\n ? containerWidth - 10\n : width + payload.offset;\n\n return (\n <g transform={`translate(${_x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor={index === 0 ? \"start\" : \"end\"}\n // textAnchor={\"start\"}\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, stroke, fill } = props;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nexport const PnLBarChart = (props: PnLChartProps) => {\n const { invisible } = props;\n const colors = useColors(props.colors);\n const widthRef = useRef(0);\n\n return (\n // @ts-ignore\n <ResponsiveContainer\n className={cn(invisible && \"chart-invisible\")}\n onResize={(width, height) => {\n // console.log(\"width\", width, height);\n widthRef.current = width;\n }}\n >\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -10, top: 10, right: 10, bottom: 30 }}\n >\n {!invisible && (\n // @ts-ignore\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip />}\n />\n )}\n\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n <ReferenceLine y={0} stroke=\"rgba(0,0,0,0.04)\" />\n\n {!invisible && (\n // @ts-ignore\n <Bar dataKey=\"pnl\" shape={<RoundedRectangle />}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.pnl > 0 ? colors.profit : colors.loss}\n />\n );\n })}\n </Bar>\n )}\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickFormatter={(value) => tickFormatter(value)}\n tickLine={false}\n axisLine={false}\n dataKey={\"pnl\"}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel containerWidth={widthRef.current} />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n />\n </BarChart>\n </ResponsiveContainer>\n );\n};\n","import { Box, Flex, Text } from \"@orderly.network/ui\";\n\nexport const OrderlyChartTooltip = (props: {\n label: string;\n value: string | number;\n unit?: string;\n prefix?: React.ReactNode;\n titleClassName?: string;\n coloring?: boolean;\n dp?: number;\n rm?: number;\n}) => {\n const {\n label,\n value,\n prefix,\n unit = \"USDC\",\n coloring = false,\n dp,\n rm,\n } = props;\n return (\n <Box intensity={600} p={3} r=\"md\">\n <Flex direction={\"row\"} className={props.titleClassName}>\n {prefix}\n <Text.numeral\n unit={unit}\n as=\"div\"\n size=\"sm\"\n coloring={coloring}\n showIdentifier={coloring}\n unitClassName=\"oui-text-base-contrast-54 oui-ml-1\"\n weight=\"semibold\"\n rm={rm}\n dp={dp}\n >\n {value}\n </Text.numeral>\n </Flex>\n <Text size=\"2xs\" intensity={54} weight=\"semibold\">\n {label}\n </Text>\n </Box>\n );\n};\n","import { numberToHumanStyle } from \"@orderly.network/utils\";\n\nexport const tickFormatter = (value: number) => {\n let absValue = Math.abs(value);\n const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;\n\n const formatted = numberToHumanStyle(absValue, dp);\n return value < 0 ? `-${formatted}` : formatted;\n};\n","import { useMemo, useRef } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\nimport { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n ReferenceLine,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: any;\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nconst PnlLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n const dataTransfer = (data: any[]) => {\n const series: any[] = [];\n\n data?.reduce((acc, item) => {\n acc += item.pnl;\n series.push({\n ...item,\n pnl: acc,\n _pnl: item.pnl,\n // date: new Date(item.date).getTime(),\n });\n return acc;\n }, 0);\n\n return series;\n };\n\n const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n data={data}\n margin={{ top: 20, right: 10, left: -10, bottom: 0 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n // scale={\"time\"}\n // type=\"number\"\n // range={}\n />\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"pnl\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <ReferenceLine y={0} stroke=\"#000\" /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"pnl\"\n stroke={colors.primary}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { PnlLineChart };\n","export const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index } = props;\n\n return (\n <g transform={`translate(${x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor=\"end\"\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n","import { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n Tooltip,\n Label,\n ResponsiveContainer,\n} from \"recharts\";\n\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type AssetChartDataItem = {\n date: string;\n account_value: number;\n};\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: AssetChartDataItem[];\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n />\n );\n }\n\n return null;\n};\n\nconst AssetLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n // const dataTransfer = (data: any[]) => {\n // const series: any[] = [];\n\n // data.reduce((acc, item) => {\n // acc += item.pnl;\n // series.push({ ...item, pnl: acc, _pnl: item.pnl });\n // return acc;\n // }, 0);\n\n // return series;\n // };\n\n // const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n width={530}\n height={180}\n data={props.data}\n margin={{ top: 20, right: 10, left: -20, bottom: -10 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n ></XAxis>\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"account_value\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <Legend /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"account_value\"\n stroke={colors.profit}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { AssetLineChart };\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\n\nexport type VolChartDataItem = {\n date: string;\n volume: number;\n opacity?: string | number;\n};\n\nexport type VolChartTooltip = {\n rm?: number;\n dp?: number;\n};\n\nexport type VolChartProps = {\n colors?: {\n fill: string;\n };\n data: VolChartDataItem[];\n tooltip?: VolChartTooltip;\n className?: string;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height, opacity } = props;\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n opacity={opacity}\n />\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, payload, stroke, fill } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (\n props: TooltipProps<any, any> & { tooltip?: VolChartTooltip }\n) => {\n const { active, payload, label, tooltip } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label}\n value={payload[0].value}\n // prefix=\"Commission\"\n titleClassName=\"oui-gap-4\"\n rm={tooltip?.rm}\n dp={tooltip?.dp}\n />\n );\n }\n\n return null;\n};\n\nexport const VolBarChart = (props: VolChartProps) => {\n const colors = useColors(\n props.colors?.fill\n ? { profit: props.colors?.fill, loss: props.colors?.fill }\n : undefined\n );\n\n const isEmpty = props.data.reduce((a, b) => a + b.volume, 0) === 0;\n const maxVolume = props.data.reduce((a,b) => (a > b.volume ? a : b.volume), 0);\n const decimal = maxVolume <= 10 ? 2 : (maxVolume <= 100 ? 1 : 0);\n\n return (\n // @ts-ignore\n <Box className={cn(props.className)}>\n {/* @ts-ignore */}\n <ResponsiveContainer>\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -0, top: 6, right: 0, bottom: 20 }}\n >\n {/* @ts-ignore */}\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip tooltip={props.tooltip} />}\n />\n <CartesianGrid\n vertical={false}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.08}\n repeatCount={6}\n />\n <ReferenceLine y={0} stroke=\"#000\" />\n {/* @ts-ignore */}\n <Bar dataKey=\"volume\" shape={<RoundedRectangle />} minPointSize={1}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.volume > 0 ? colors.profit : colors.loss}\n opacity={entry.opacity}\n />\n );\n })}\n </Bar>\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n dataKey={\"volume\"}\n tickFormatter={(value, index) => {\n if (isEmpty) return `${index * 100}`;\n return numberToHumanStyle(value, decimal);\n }}\n width={45}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n stroke=\"rgb(229, 231, 235)\"\n strokeOpacity={0.2}\n />\n </BarChart>\n </ResponsiveContainer>\n </Box>\n );\n};\nfunction numberToHumanStyle(number: number, decimalPlaces: number = 0): string {\n const abbreviations = [\"\", \"K\", \"M\", \"B\", \"T\"];\n\n let index = 0;\n while (number >= 1000 && index < abbreviations.length - 1) {\n number /= 1000;\n index++;\n }\n\n const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);\n\n return `${roundedNumber}${abbreviations[index]}`;\n}\n\nfunction toFixedWithoutRounding(num: number, fix: number): string {\n const numStr = num.toString();\n const decimalIndex = numStr.indexOf(\".\");\n\n if (decimalIndex === -1 || fix === 0) {\n return numStr.split(\".\")[0];\n }\n\n const cutoffIndex = decimalIndex + fix + 1;\n\n return numStr.slice(0, cutoffIndex);\n}\n","import plugin from \"tailwindcss/plugin\";\n\nimport { PluginCreator } from \"tailwindcss/types/config\";\n\nexport const chartPlugin: PluginCreator = () =>\n plugin(function ({ addComponents, addBase }) {\n addComponents(\n {\n \".xAxis\": {\n \".recharts-cartesian-axis-tick:first-child text\": {\n \"text-anchor\": \"start\",\n },\n \".recharts-cartesian-axis-tick:last-child text\": {\n \"text-anchor\": \"end\",\n },\n },\n },\n {\n respectPrefix: false,\n }\n );\n });\n"]}
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { useRef, useMemo } from 'react';
1
+ import { useMemo, useRef } from 'react';
2
2
  import { ResponsiveContainer, BarChart, Tooltip, CartesianGrid, ReferenceLine, Bar, Cell, YAxis, XAxis, LineChart, Line, Cross } from 'recharts';
3
3
  import { cn, Box, Flex, Text } from '@orderly.network/ui';
4
4
  import { jsx, jsxs } from 'react/jsx-runtime';
5
5
  import { numberToHumanStyle } from '@orderly.network/utils';
6
6
 
7
- var N=Object.create;var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var $=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!K.call(t,i)&&i!==r&&k(t,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return t};var M=(t,e,r)=>(r=t!=null?N(I(t)):{},$(!t||!t.__esModule?k(r,"default",{value:t,enumerable:!0}):r,t));var _=g(x=>{Object.defineProperty(x,"__esModule",{value:!0});Object.defineProperty(x,"default",{enumerable:!0,get:function(){return Jt}});function S(t,e){return {handler:t,config:e}}S.withOptions=function(t,e=()=>({})){let r=function(o){return {__options:o,handler:t(o),config:e(o)}};return r.__isOptionsFunction=!0,r.__pluginFunction=t,r.__configFunction=e,r};var Jt=S;});var O=g(b=>{Object.defineProperty(b,"__esModule",{value:!0});Object.defineProperty(b,"default",{enumerable:!0,get:function(){return te}});var Zt=jt(_());function jt(t){return t&&t.__esModule?t:{default:t}}var te=Zt.default;});var R=g((Qe,A)=>{var C=O();A.exports=(C.__esModule?C:{default:C}).default;});var v=()=>{let t=document.documentElement,e=getComputedStyle(t);return {primary:u(e.getPropertyValue("--oui-color-primary")),primaryLight:u(e.getPropertyValue("--oui-color-primary-light")),secondary:u(e.getPropertyValue("--oui-color-secondary")),success:u(e.getPropertyValue("--oui-color-success")),warning:u(e.getPropertyValue("--oui-color-warning")),danger:u(e.getPropertyValue("--oui-color-danger")),info:u(e.getPropertyValue("--oui-color-info")),loss:u(e.getPropertyValue("--oui-color-trading-loss")),profit:u(e.getPropertyValue("--oui-color-trading-profit"))}},u=t=>`rgb(${t.split(" ").join(",")})`;var f=t=>useMemo(()=>{let r=v();return {profit:t?.profit||r.profit,loss:t?.loss||r.loss,primary:r.primary,primaryLight:r.primaryLight}},[t]);var d=t=>{let{label:e,value:r,prefix:o,unit:i="USDC",coloring:a=!1,dp:n,rm:c}=t;return jsxs(Box,{intensity:600,p:3,r:"md",children:[jsxs(Flex,{direction:"row",className:t.titleClassName,children:[o,jsx(Text.numeral,{unit:i,as:"div",size:"sm",coloring:a,showIdentifier:a,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:c,dp:n,children:r})]}),jsx(Text,{size:"2xs",intensity:54,weight:"semibold",children:e})]})};var h=t=>{let e=Math.abs(t),r=e===0?0:e<=10?2:e<=100?1:0,o=numberToHumanStyle(e,r);return t<0?`-${o}`:o};var ot=t=>{let{fill:e,x:r,y:o,width:i,height:a}=t,n=Math.abs(a);return jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:n,stroke:"none",fill:e})},it=t=>{let{x:e,y:r,stroke:o,payload:i,index:a,width:n,containerWidth:c}=t,V=a===0?48:c>0?c-10:n+i.offset;return jsx("g",{transform:`translate(${V},${r-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:a===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})},at=t=>{let{width:e,height:r,stroke:o,fill:i}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},nt=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:!0}):null},lt=t=>{let{invisible:e}=t,r=f(t.colors),o=useRef(0);return jsx(ResponsiveContainer,{className:cn(e&&"chart-invisible"),onResize:(i,a)=>{o.current=i;},children:jsxs(BarChart,{data:t.data,margin:{left:-10,top:10,right:10,bottom:30},children:[!e&&jsx(Tooltip,{cursor:jsx(at,{}),content:jsx(nt,{})}),jsx(CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!e&&jsx(Bar,{dataKey:"pnl",shape:jsx(ot,{}),children:t.data.map((i,a)=>jsx(Cell,{fill:i.pnl>0?r.profit:r.loss},`cell-${a}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:i=>h(i),tickLine:!1,axisLine:!1,dataKey:"pnl"}),jsx(XAxis,{dataKey:"date",tickLine:!1,interval:t.data.length-2,height:1,tick:jsx(it,{containerWidth:o.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var y=t=>{let{x:e,y:r,stroke:o,payload:i,index:a}=t;return jsx("g",{transform:`translate(${e},${r-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})};var xt=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:!0}):null},bt=t=>{let e=f(t.colors),r=i=>{let a=[];return i?.reduce((n,c)=>(n+=c.pnl,a.push({...c,pnl:n,_pnl:c.pnl}),n),0),a},o=useMemo(()=>r(t.data),[t.data]);return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxs(LineChart,{data:o,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,tickFormatter:i=>h(i)}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(xt,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:2,dot:!1,isAnimationActive:!1})]})})};var _t=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value}):null},Ot=t=>{let e=f(t.colors);return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxs(LineChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,tickFormatter:r=>h(r)}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(_t,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:2,dot:!1,isAnimationActive:!1})]})})};var Gt=t=>{let{fill:e,x:r,y:o,width:i,height:a,opacity:n}=t,c=Math.abs(a);return jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:c,stroke:"none",fill:e,opacity:n})},Wt=t=>{let{width:e,height:r,payload:o,stroke:i,fill:a}=t;return o?.[0]?.value===0?null:jsx(Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Yt=t=>{let{active:e,payload:r,label:o,tooltip:i}=t;return r?.[0]?.value===0?null:e&&r&&r.length?jsx(d,{label:o,value:r[0].value,titleClassName:"oui-gap-4",rm:i?.rm,dp:i?.dp}):null},qt=t=>{let e=f(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),r=t.data.reduce((a,n)=>a+n.volume,0)===0,o=t.data.reduce((a,n)=>a>n.volume?a:n.volume,0),i=o<=10?2:o<=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(Wt,{}),content:jsx(Yt,{tooltip:t.tooltip})}),jsx(CartesianGrid,{vertical:!1,stroke:"#FFFFFF",strokeOpacity:.08,repeatCount:6}),jsx(ReferenceLine,{y:0,stroke:"#000"}),jsx(Bar,{dataKey:"volume",shape:jsx(Gt,{}),minPointSize:1,children:t.data.map((a,n)=>jsx(Cell,{fill:a.volume>0?e.profit:e.loss,opacity:a.opacity},`cell-${n}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:!1,axisLine:!1,dataKey:"volume",tickFormatter:(a,n)=>r?`${n*100}`:Et(a,i),width:45}),jsx(XAxis,{dataKey:"date",tickLine:!1,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 Et(t,e=0){let r=["","K","M","B","T"],o=0;for(;t>=1e3&&o<r.length-1;)t/=1e3,o++;return `${Qt(t,e)}${r[o]}`}function Qt(t,e){let r=t.toString(),o=r.indexOf(".");if(o===-1||e===0)return r.split(".")[0];let i=o+e+1;return r.slice(0,i)}var B=M(R()),ee=()=>(0, B.default)(function({addComponents:t,addBase:e}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:!1});});
7
+ var N=Object.create;var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var $=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!K.call(t,i)&&i!==r&&k(t,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return t};var M=(t,e,r)=>(r=t!=null?N(I(t)):{},$(!t||!t.__esModule?k(r,"default",{value:t,enumerable:true}):r,t));var _=g(x=>{Object.defineProperty(x,"__esModule",{value:true});Object.defineProperty(x,"default",{enumerable:true,get:function(){return Jt}});function S(t,e){return {handler:t,config:e}}S.withOptions=function(t,e=()=>({})){let r=function(o){return {__options:o,handler:t(o),config:e(o)}};return r.__isOptionsFunction=true,r.__pluginFunction=t,r.__configFunction=e,r};var Jt=S;});var O=g(b=>{Object.defineProperty(b,"__esModule",{value:true});Object.defineProperty(b,"default",{enumerable:true,get:function(){return te}});var Zt=jt(_());function jt(t){return t&&t.__esModule?t:{default:t}}var te=Zt.default;});var R=g((Qe,A)=>{var C=O();A.exports=(C.__esModule?C:{default:C}).default;});var v=()=>{let t=document.documentElement,e=getComputedStyle(t);return {primary:u(e.getPropertyValue("--oui-color-primary")),primaryLight:u(e.getPropertyValue("--oui-color-primary-light")),secondary:u(e.getPropertyValue("--oui-color-secondary")),success:u(e.getPropertyValue("--oui-color-success")),warning:u(e.getPropertyValue("--oui-color-warning")),danger:u(e.getPropertyValue("--oui-color-danger")),info:u(e.getPropertyValue("--oui-color-info")),loss:u(e.getPropertyValue("--oui-color-trading-loss")),profit:u(e.getPropertyValue("--oui-color-trading-profit"))}},u=t=>`rgb(${t.split(" ").join(",")})`;var f=t=>useMemo(()=>{let r=v();return {profit:t?.profit||r.profit,loss:t?.loss||r.loss,primary:r.primary,primaryLight:r.primaryLight}},[t]);var d=t=>{let{label:e,value:r,prefix:o,unit:i="USDC",coloring:a=false,dp:n,rm:c}=t;return jsxs(Box,{intensity:600,p:3,r:"md",children:[jsxs(Flex,{direction:"row",className:t.titleClassName,children:[o,jsx(Text.numeral,{unit:i,as:"div",size:"sm",coloring:a,showIdentifier:a,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:c,dp:n,children:r})]}),jsx(Text,{size:"2xs",intensity:54,weight:"semibold",children:e})]})};var h=t=>{let e=Math.abs(t),r=e===0?0:e<=10?2:e<=100?1:0,o=numberToHumanStyle(e,r);return t<0?`-${o}`:o};var ot=t=>{let{fill:e,x:r,y:o,width:i,height:a}=t,n=Math.abs(a);return jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:n,stroke:"none",fill:e})},it=t=>{let{x:e,y:r,stroke:o,payload:i,index:a,width:n,containerWidth:c}=t,V=a===0?48:c>0?c-10:n+i.offset;return jsx("g",{transform:`translate(${V},${r-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:a===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})},at=t=>{let{width:e,height:r,stroke:o,fill:i}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},nt=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:true}):null},lt=t=>{let{invisible:e}=t,r=f(t.colors),o=useRef(0);return jsx(ResponsiveContainer,{className:cn(e&&"chart-invisible"),onResize:(i,a)=>{o.current=i;},children:jsxs(BarChart,{data:t.data,margin:{left:-10,top:10,right:10,bottom:30},children:[!e&&jsx(Tooltip,{cursor:jsx(at,{}),content:jsx(nt,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!e&&jsx(Bar,{dataKey:"pnl",shape:jsx(ot,{}),children:t.data.map((i,a)=>jsx(Cell,{fill:i.pnl>0?r.profit:r.loss},`cell-${a}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:i=>h(i),tickLine:false,axisLine:false,dataKey:"pnl"}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:jsx(it,{containerWidth:o.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var y=t=>{let{x:e,y:r,stroke:o,payload:i,index:a}=t;return jsx("g",{transform:`translate(${e},${r-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:a===0?i.value:"Now"})})};var xt=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value,coloring:true}):null},bt=t=>{let e=f(t.colors),r=i=>{let a=[];return i?.reduce((n,c)=>(n+=c.pnl,a.push({...c,pnl:n,_pnl:c.pnl}),n),0),a},o=useMemo(()=>r(t.data),[t.data]);return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children:jsxs(LineChart,{data:o,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(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:i=>h(i)}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(xt,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:2,dot:false,isAnimationActive:false})]})})};var _t=t=>{let{active:e,payload:r,label:o}=t,i=useRef(new Date().toISOString().split("T")[0]);return e&&r&&r.length?jsx(d,{label:o===i.current?"Now":o,value:r[0].value}):null},Ot=t=>{let e=f(t.colors);return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":"",children: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(y,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:r=>h(r)}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(_t,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:2,dot:false,isAnimationActive:false})]})})};var Gt=t=>{let{fill:e,x:r,y:o,width:i,height:a,opacity:n}=t,c=Math.abs(a);return jsx("rect",{rx:2,x:r,y:a>0?o:o+a,width:i,height:c,stroke:"none",fill:e,opacity:n})},Wt=t=>{let{width:e,height:r,payload:o,stroke:i,fill:a}=t;return o?.[0]?.value===0?null:jsx(Cross,{x:t.x+t.width/2,top:t.top,height:r,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Yt=t=>{let{active:e,payload:r,label:o,tooltip:i}=t;return r?.[0]?.value===0?null:e&&r&&r.length?jsx(d,{label:o,value:r[0].value,titleClassName:"oui-gap-4",rm:i?.rm,dp:i?.dp}):null},qt=t=>{let e=f(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),r=t.data.reduce((a,n)=>a+n.volume,0)===0,o=t.data.reduce((a,n)=>a>n.volume?a:n.volume,0),i=o<=10?2:o<=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(Wt,{}),content:jsx(Yt,{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(Gt,{}),minPointSize:1,children:t.data.map((a,n)=>jsx(Cell,{fill:a.volume>0?e.profit:e.loss,opacity:a.opacity},`cell-${n}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(a,n)=>r?`${n*100}`:Et(a,i),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 Et(t,e=0){let r=["","K","M","B","T"],o=0;for(;t>=1e3&&o<r.length-1;)t/=1e3,o++;return `${Qt(t,e)}${r[o]}`}function Qt(t,e){let r=t.toString(),o=r.indexOf(".");if(o===-1||e===0)return r.split(".")[0];let i=o+e+1;return r.slice(0,i)}var B=M(R()),ee=()=>(0, B.default)(function({addComponents:t,addBase:e}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});
8
8
 
9
9
  export { Ot as AssetLineChart, lt as PnLBarChart, bt as PnlLineChart, qt as VolBarChart, ee as chartPlugin };
10
10
  //# sourceMappingURL=out.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/lib/util/createPlugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/lib/public/create-plugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2_@swc+core@1.4.12_@swc+helpers@0.5.15__@types+node@22.9.1_typescript@5.6.3_/node_modules/tailwindcss/plugin.js","../src/orderly/useColors.ts","../src/utils/theme.ts","../src/orderly/pnlBar.tsx","../src/orderly/customTooltip.tsx","../src/utils/yTickFormatter.ts","../src/orderly/pnlLine.tsx","../src/orderly/xAxisLabel.tsx","../src/orderly/assetLine.tsx","../src/orderly/volBar.tsx","../src/tailwindcss/theme.ts"],"names":["require_createPlugin","__commonJSMin","exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","require_create_plugin","_createPlugin","_interop_require_default","obj","require_plugin","module","useMemo","getThemeColors","root","computedStyle","convertToRGB","color","useColors","colors","themeColors","BarChart","XAxis","YAxis","ResponsiveContainer","Bar","Cell","Tooltip","CartesianGrid","ReferenceLine","Cross","Box","Flex","Text","jsx","jsxs","OrderlyChartTooltip","props","label","value","prefix","unit","coloring","dp","rm","cn","useRef","numberToHumanStyle","tickFormatter","absValue","formatted","RoundedRectangle","fill","x","y","width","height","absHeight","XAxisLabel","stroke","payload","index","containerWidth","_x","CustomizedCross","CustomTooltip","active","todayStr","PnLBarChart","invisible","widthRef","entry","LineChart","Line","PnlLineChart","dataTransfer","data","series","acc","item","AssetLineChart","opacity","tooltip","VolBarChart","isEmpty","b","maxVolume","decimal","number","decimalPlaces","abbreviations","toFixedWithoutRounding","num","fix","numStr","decimalIndex","cutoffIndex","import_plugin","chartPlugin","addComponents","addBase"],"mappings":"ygBAAA,IAAAA,EAAAC,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CACtC,WAAY,GACZ,IAAK,UAAW,CACZ,OAAOC,EACX,CACJ,CAAC,EACD,SAASC,EAAaC,EAAQC,EAAQ,CAClC,MAAO,CACH,QAASD,EACT,OAAAC,CACJ,CACJ,CACAF,EAAa,YAAc,SAASG,EAAgBC,EAAiB,KAAK,CAAC,GAAI,CAC3E,IAAMC,EAAkB,SAASC,EAAS,CACtC,MAAO,CACH,UAAWA,EACX,QAASH,EAAeG,CAAO,EAC/B,OAAQF,EAAeE,CAAO,CAClC,CACJ,EACA,OAAAD,EAAgB,oBAAsB,GAGtCA,EAAgB,iBAAmBF,EACnCE,EAAgB,iBAAmBD,EAC5BC,CACX,EACA,IAAMN,GAAWC,IC/BjB,IAAAO,EAAAV,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CAC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C,EAAc7B,CAAK,CAAC,EAChD,CAEA,SAAS8B,GAAuBC,EAAaC,EAAqB,CAChE,IAAMC,EAASF,EAAI,SAAS,EACtBG,EAAeD,EAAO,QAAQ,GAAG,EAEvC,GAAIC,IAAiB,IAAMF,IAAQ,EACjC,OAAOC,EAAO,MAAM,GAAG,EAAE,CAAC,EAG5B,IAAME,EAAcD,EAAeF,EAAM,EAEzC,OAAOC,EAAO,MAAM,EAAGE,CAAW,CACpC,CCxMA,IAAAC,EAAmB,OAINC,GAA6B,OACxC,EAAAlG,SAAO,SAAU,CAAE,cAAAmG,EAAe,QAAAC,CAAQ,EAAG,CAC3CD,EACE,CACE,SAAU,CACR,iDAAkD,CAChD,cAAe,OACjB,EACA,gDAAiD,CAC/C,cAAe,KACjB,CACF,CACF,EACA,CACE,cAAe,EACjB,CACF,CACF,CAAC","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","import { useMemo } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\n\nexport const useColors = (colors?: { profit: string; loss: string }) => {\n const _colors = useMemo(() => {\n const themeColors = getThemeColors();\n return {\n profit: colors?.profit || themeColors.profit,\n loss: colors?.loss || themeColors.loss,\n primary: themeColors.primary,\n primaryLight: themeColors.primaryLight,\n };\n }, [colors]);\n\n return _colors;\n};\n","export const getThemeColors = () => {\n const root = document.documentElement;\n const computedStyle = getComputedStyle(root);\n\n const colors = {\n primary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary\")\n ),\n primaryLight: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary-light\")\n ),\n secondary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-secondary\")\n ),\n success: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-success\")\n ),\n warning: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-warning\")\n ),\n danger: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-danger\")),\n info: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-info\")),\n loss: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-loss\")\n ),\n profit: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-profit\")\n ),\n };\n\n return colors;\n};\n\nconst convertToRGB = (color: string) => {\n return `rgb(${color.split(\" \").join(\",\")})`;\n};\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\nimport { Flex } from \"@orderly.network/ui\";\n// import { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnLChartDataItem = {\n date: string;\n pnl: number;\n};\n\nexport type PnLChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: PnLChartDataItem[];\n invisible?: boolean;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height } = props;\n\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n />\n );\n};\n\nexport const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index, width, containerWidth } = props;\n\n const _x =\n index === 0\n ? 48\n : containerWidth > 0\n ? containerWidth - 10\n : width + payload.offset;\n\n return (\n <g transform={`translate(${_x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor={index === 0 ? \"start\" : \"end\"}\n // textAnchor={\"start\"}\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, stroke, fill } = props;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nexport const PnLBarChart = (props: PnLChartProps) => {\n const { invisible } = props;\n const colors = useColors(props.colors);\n const widthRef = useRef(0);\n\n return (\n // @ts-ignore\n <ResponsiveContainer\n className={cn(invisible && \"chart-invisible\")}\n onResize={(width, height) => {\n // console.log(\"width\", width, height);\n widthRef.current = width;\n }}\n >\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -10, top: 10, right: 10, bottom: 30 }}\n >\n {!invisible && (\n // @ts-ignore\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip />}\n />\n )}\n\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n <ReferenceLine y={0} stroke=\"rgba(0,0,0,0.04)\" />\n\n {!invisible && (\n // @ts-ignore\n <Bar dataKey=\"pnl\" shape={<RoundedRectangle />}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.pnl > 0 ? colors.profit : colors.loss}\n />\n );\n })}\n </Bar>\n )}\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickFormatter={(value) => tickFormatter(value)}\n tickLine={false}\n axisLine={false}\n dataKey={\"pnl\"}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel containerWidth={widthRef.current} />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n />\n </BarChart>\n </ResponsiveContainer>\n );\n};\n","import { Box, Flex, Text } from \"@orderly.network/ui\";\n\nexport const OrderlyChartTooltip = (props: {\n label: string;\n value: string | number;\n unit?: string;\n prefix?: React.ReactNode;\n titleClassName?: string;\n coloring?: boolean;\n dp?: number;\n rm?: number;\n}) => {\n const {\n label,\n value,\n prefix,\n unit = \"USDC\",\n coloring = false,\n dp,\n rm,\n } = props;\n return (\n <Box intensity={600} p={3} r=\"md\">\n <Flex direction={\"row\"} className={props.titleClassName}>\n {prefix}\n <Text.numeral\n unit={unit}\n as=\"div\"\n size=\"sm\"\n coloring={coloring}\n showIdentifier={coloring}\n unitClassName=\"oui-text-base-contrast-54 oui-ml-1\"\n weight=\"semibold\"\n rm={rm}\n dp={dp}\n >\n {value}\n </Text.numeral>\n </Flex>\n <Text size=\"2xs\" intensity={54} weight=\"semibold\">\n {label}\n </Text>\n </Box>\n );\n};\n","import { numberToHumanStyle } from \"@orderly.network/utils\";\n\nexport const tickFormatter = (value: number) => {\n let absValue = Math.abs(value);\n const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;\n\n const formatted = numberToHumanStyle(absValue, dp);\n return value < 0 ? `-${formatted}` : formatted;\n};\n","import { useMemo, useRef } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\nimport { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n ReferenceLine,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: any;\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nconst PnlLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n const dataTransfer = (data: any[]) => {\n const series: any[] = [];\n\n data?.reduce((acc, item) => {\n acc += item.pnl;\n series.push({\n ...item,\n pnl: acc,\n _pnl: item.pnl,\n // date: new Date(item.date).getTime(),\n });\n return acc;\n }, 0);\n\n return series;\n };\n\n const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n data={data}\n margin={{ top: 20, right: 10, left: -10, bottom: 0 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n // scale={\"time\"}\n // type=\"number\"\n // range={}\n />\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"pnl\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <ReferenceLine y={0} stroke=\"#000\" /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"pnl\"\n stroke={colors.primary}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { PnlLineChart };\n","export const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index } = props;\n\n return (\n <g transform={`translate(${x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor=\"end\"\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n","import { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n Tooltip,\n Label,\n ResponsiveContainer,\n} from \"recharts\";\n\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type AssetChartDataItem = {\n date: string;\n account_value: number;\n};\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: AssetChartDataItem[];\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n />\n );\n }\n\n return null;\n};\n\nconst AssetLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n // const dataTransfer = (data: any[]) => {\n // const series: any[] = [];\n\n // data.reduce((acc, item) => {\n // acc += item.pnl;\n // series.push({ ...item, pnl: acc, _pnl: item.pnl });\n // return acc;\n // }, 0);\n\n // return series;\n // };\n\n // const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n width={530}\n height={180}\n data={props.data}\n margin={{ top: 20, right: 10, left: -20, bottom: -10 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n ></XAxis>\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"account_value\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <Legend /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"account_value\"\n stroke={colors.profit}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { AssetLineChart };\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\n\nexport type VolChartDataItem = {\n date: string;\n volume: number;\n opacity?: string | number;\n};\n\nexport type VolChartTooltip = {\n rm?: number;\n dp?: number;\n};\n\nexport type VolChartProps = {\n colors?: {\n fill: string;\n };\n data: VolChartDataItem[];\n tooltip?: VolChartTooltip;\n className?: string;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height, opacity } = props;\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n opacity={opacity}\n />\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, payload, stroke, fill } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (\n props: TooltipProps<any, any> & { tooltip?: VolChartTooltip }\n) => {\n const { active, payload, label, tooltip } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label}\n value={payload[0].value}\n // prefix=\"Commission\"\n titleClassName=\"oui-gap-4\"\n rm={tooltip?.rm}\n dp={tooltip?.dp}\n />\n );\n }\n\n return null;\n};\n\nexport const VolBarChart = (props: VolChartProps) => {\n const colors = useColors(\n props.colors?.fill\n ? { profit: props.colors?.fill, loss: props.colors?.fill }\n : undefined\n );\n\n const isEmpty = props.data.reduce((a, b) => a + b.volume, 0) === 0;\n const maxVolume = props.data.reduce((a,b) => (a > b.volume ? a : b.volume), 0);\n const decimal = maxVolume <= 10 ? 2 : (maxVolume <= 100 ? 1 : 0);\n\n return (\n // @ts-ignore\n <Box className={cn(props.className)}>\n {/* @ts-ignore */}\n <ResponsiveContainer>\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -0, top: 6, right: 0, bottom: 20 }}\n >\n {/* @ts-ignore */}\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip tooltip={props.tooltip} />}\n />\n <CartesianGrid\n vertical={false}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.08}\n repeatCount={6}\n />\n <ReferenceLine y={0} stroke=\"#000\" />\n {/* @ts-ignore */}\n <Bar dataKey=\"volume\" shape={<RoundedRectangle />} minPointSize={1}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.volume > 0 ? colors.profit : colors.loss}\n opacity={entry.opacity}\n />\n );\n })}\n </Bar>\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n dataKey={\"volume\"}\n tickFormatter={(value, index) => {\n if (isEmpty) return `${index * 100}`;\n return numberToHumanStyle(value, decimal);\n }}\n width={45}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n stroke=\"rgb(229, 231, 235)\"\n strokeOpacity={0.2}\n />\n </BarChart>\n </ResponsiveContainer>\n </Box>\n );\n};\nfunction numberToHumanStyle(number: number, decimalPlaces: number = 0): string {\n const abbreviations = [\"\", \"K\", \"M\", \"B\", \"T\"];\n\n let index = 0;\n while (number >= 1000 && index < abbreviations.length - 1) {\n number /= 1000;\n index++;\n }\n\n const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);\n\n return `${roundedNumber}${abbreviations[index]}`;\n}\n\nfunction toFixedWithoutRounding(num: number, fix: number): string {\n const numStr = num.toString();\n const decimalIndex = numStr.indexOf(\".\");\n\n if (decimalIndex === -1 || fix === 0) {\n return numStr.split(\".\")[0];\n }\n\n const cutoffIndex = decimalIndex + fix + 1;\n\n return numStr.slice(0, cutoffIndex);\n}\n","import plugin from \"tailwindcss/plugin\";\n\nimport { PluginCreator } from \"tailwindcss/types/config\";\n\nexport const chartPlugin: PluginCreator = () =>\n plugin(function ({ addComponents, addBase }) {\n addComponents(\n {\n \".xAxis\": {\n \".recharts-cartesian-axis-tick:first-child text\": {\n \"text-anchor\": \"start\",\n },\n \".recharts-cartesian-axis-tick:last-child text\": {\n \"text-anchor\": \"end\",\n },\n },\n },\n {\n respectPrefix: false,\n }\n );\n });\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/lib/util/createPlugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/lib/public/create-plugin.js","../../../node_modules/.pnpm/tailwindcss@3.4.4_ts-node@10.9.2/node_modules/tailwindcss/plugin.js","../src/orderly/useColors.ts","../src/utils/theme.ts","../src/orderly/pnlBar.tsx","../src/orderly/customTooltip.tsx","../src/utils/yTickFormatter.ts","../src/orderly/pnlLine.tsx","../src/orderly/xAxisLabel.tsx","../src/orderly/assetLine.tsx","../src/orderly/volBar.tsx","../src/tailwindcss/theme.ts"],"names":["require_createPlugin","__commonJSMin","exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","require_create_plugin","_createPlugin","_interop_require_default","obj","require_plugin","module","useMemo","getThemeColors","root","computedStyle","convertToRGB","color","useColors","colors","themeColors","BarChart","XAxis","YAxis","ResponsiveContainer","Bar","Cell","Tooltip","CartesianGrid","ReferenceLine","Cross","Box","Flex","Text","jsx","jsxs","OrderlyChartTooltip","props","label","value","prefix","unit","coloring","dp","rm","cn","useRef","numberToHumanStyle","tickFormatter","absValue","formatted","RoundedRectangle","fill","x","y","width","height","absHeight","XAxisLabel","stroke","payload","index","containerWidth","_x","CustomizedCross","CustomTooltip","active","todayStr","PnLBarChart","invisible","widthRef","entry","LineChart","Line","PnlLineChart","dataTransfer","data","series","acc","item","AssetLineChart","opacity","tooltip","VolBarChart","isEmpty","b","maxVolume","decimal","number","decimalPlaces","abbreviations","toFixedWithoutRounding","num","fix","numStr","decimalIndex","cutoffIndex","import_plugin","chartPlugin","addComponents","addBase"],"mappings":"ygBAAA,IAAAA,EAAAC,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CACtC,WAAY,GACZ,IAAK,UAAW,CACZ,OAAOC,EACX,CACJ,CAAC,EACD,SAASC,EAAaC,EAAQC,EAAQ,CAClC,MAAO,CACH,QAASD,EACT,OAAAC,CACJ,CACJ,CACAF,EAAa,YAAc,SAASG,EAAgBC,EAAiB,KAAK,CAAC,GAAI,CAC3E,IAAMC,EAAkB,SAASC,EAAS,CACtC,MAAO,CAC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M,wBAAyB,EACrD,OAAO,qBACP,cAAe,GACjB,GACF,EACF,EACF,CAEJ,EACA,SAASU,GAAmByC,EAAgBC,EAAwB,EAAW,CAC7E,IAAMC,EAAgB,CAAC,GAAI,IAAK,IAAK,IAAK,GAAG,EAEzC7B,EAAQ,EACZ,KAAO2B,GAAU,KAAQ3B,EAAQ6B,EAAc,OAAS,GACtDF,GAAU,IACV3B,IAKF,MAAO,GAFe8B,GAAuBH,EAAQC,CAAa,CAE3C,GAAGC,EAAc7B,CAAK,CAAC,EAChD,CAEA,SAAS8B,GAAuBC,EAAaC,EAAqB,CAChE,IAAMC,EAASF,EAAI,SAAS,EACtBG,EAAeD,EAAO,QAAQ,GAAG,EAEvC,GAAIC,IAAiB,IAAMF,IAAQ,EACjC,OAAOC,EAAO,MAAM,GAAG,EAAE,CAAC,EAG5B,IAAME,EAAcD,EAAeF,EAAM,EAEzC,OAAOC,EAAO,MAAM,EAAGE,CAAW,CACpC,CCxMA,IAAAC,EAAmB,OAINC,GAA6B,OACxC,EAAAlG,SAAO,SAAU,CAAE,cAAAmG,EAAe,QAAAC,CAAQ,EAAG,CAC3CD,EACE,CACE,SAAU,CACR,iDAAkD,CAChD,cAAe,OACjB,EACA,gDAAiD,CAC/C,cAAe,KACjB,CACF,CACF,EACA,CACE,cAAe,EACjB,CACF,CACF,CAAC","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","import { useMemo } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\n\nexport const useColors = (colors?: { profit: string; loss: string }) => {\n const _colors = useMemo(() => {\n const themeColors = getThemeColors();\n return {\n profit: colors?.profit || themeColors.profit,\n loss: colors?.loss || themeColors.loss,\n primary: themeColors.primary,\n primaryLight: themeColors.primaryLight,\n };\n }, [colors]);\n\n return _colors;\n};\n","export const getThemeColors = () => {\n const root = document.documentElement;\n const computedStyle = getComputedStyle(root);\n\n const colors = {\n primary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary\")\n ),\n primaryLight: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-primary-light\")\n ),\n secondary: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-secondary\")\n ),\n success: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-success\")\n ),\n warning: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-warning\")\n ),\n danger: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-danger\")),\n info: convertToRGB(computedStyle.getPropertyValue(\"--oui-color-info\")),\n loss: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-loss\")\n ),\n profit: convertToRGB(\n computedStyle.getPropertyValue(\"--oui-color-trading-profit\")\n ),\n };\n\n return colors;\n};\n\nconst convertToRGB = (color: string) => {\n return `rgb(${color.split(\" \").join(\",\")})`;\n};\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\nimport { Flex } from \"@orderly.network/ui\";\n// import { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnLChartDataItem = {\n date: string;\n pnl: number;\n};\n\nexport type PnLChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: PnLChartDataItem[];\n invisible?: boolean;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height } = props;\n\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n />\n );\n};\n\nexport const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index, width, containerWidth } = props;\n\n const _x =\n index === 0\n ? 48\n : containerWidth > 0\n ? containerWidth - 10\n : width + payload.offset;\n\n return (\n <g transform={`translate(${_x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor={index === 0 ? \"start\" : \"end\"}\n // textAnchor={\"start\"}\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, stroke, fill } = props;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nexport const PnLBarChart = (props: PnLChartProps) => {\n const { invisible } = props;\n const colors = useColors(props.colors);\n const widthRef = useRef(0);\n\n return (\n // @ts-ignore\n <ResponsiveContainer\n className={cn(invisible && \"chart-invisible\")}\n onResize={(width, height) => {\n // console.log(\"width\", width, height);\n widthRef.current = width;\n }}\n >\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -10, top: 10, right: 10, bottom: 30 }}\n >\n {!invisible && (\n // @ts-ignore\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip />}\n />\n )}\n\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n <ReferenceLine y={0} stroke=\"rgba(0,0,0,0.04)\" />\n\n {!invisible && (\n // @ts-ignore\n <Bar dataKey=\"pnl\" shape={<RoundedRectangle />}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.pnl > 0 ? colors.profit : colors.loss}\n />\n );\n })}\n </Bar>\n )}\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickFormatter={(value) => tickFormatter(value)}\n tickLine={false}\n axisLine={false}\n dataKey={\"pnl\"}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel containerWidth={widthRef.current} />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n />\n </BarChart>\n </ResponsiveContainer>\n );\n};\n","import { Box, Flex, Text } from \"@orderly.network/ui\";\n\nexport const OrderlyChartTooltip = (props: {\n label: string;\n value: string | number;\n unit?: string;\n prefix?: React.ReactNode;\n titleClassName?: string;\n coloring?: boolean;\n dp?: number;\n rm?: number;\n}) => {\n const {\n label,\n value,\n prefix,\n unit = \"USDC\",\n coloring = false,\n dp,\n rm,\n } = props;\n return (\n <Box intensity={600} p={3} r=\"md\">\n <Flex direction={\"row\"} className={props.titleClassName}>\n {prefix}\n <Text.numeral\n unit={unit}\n as=\"div\"\n size=\"sm\"\n coloring={coloring}\n showIdentifier={coloring}\n unitClassName=\"oui-text-base-contrast-54 oui-ml-1\"\n weight=\"semibold\"\n rm={rm}\n dp={dp}\n >\n {value}\n </Text.numeral>\n </Flex>\n <Text size=\"2xs\" intensity={54} weight=\"semibold\">\n {label}\n </Text>\n </Box>\n );\n};\n","import { numberToHumanStyle } from \"@orderly.network/utils\";\n\nexport const tickFormatter = (value: number) => {\n let absValue = Math.abs(value);\n const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;\n\n const formatted = numberToHumanStyle(absValue, dp);\n return value < 0 ? `-${formatted}` : formatted;\n};\n","import { useMemo, useRef } from \"react\";\nimport { getThemeColors } from \"../utils/theme\";\nimport { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n ReferenceLine,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: any;\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n coloring\n />\n );\n }\n\n return null;\n};\n\nconst PnlLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n const dataTransfer = (data: any[]) => {\n const series: any[] = [];\n\n data?.reduce((acc, item) => {\n acc += item.pnl;\n series.push({\n ...item,\n pnl: acc,\n _pnl: item.pnl,\n // date: new Date(item.date).getTime(),\n });\n return acc;\n }, 0);\n\n return series;\n };\n\n const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n data={data}\n margin={{ top: 20, right: 10, left: -10, bottom: 0 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n // scale={\"time\"}\n // type=\"number\"\n // range={}\n />\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"pnl\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <ReferenceLine y={0} stroke=\"#000\" /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"pnl\"\n stroke={colors.primary}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { PnlLineChart };\n","export const XAxisLabel = (props: any) => {\n const { x, y, stroke, payload, index } = props;\n\n return (\n <g transform={`translate(${x},${y - 6})`}>\n <text\n x={0}\n y={0}\n dy={16}\n textAnchor=\"end\"\n fontSize={10}\n fill={\"rgba(255,255,255,0.54)\"}\n >\n {index === 0 ? payload.value : \"Now\"}\n </text>\n </g>\n );\n};\n","import { useColors } from \"./useColors\";\n// import { Line } from \"../line/line\";\nimport {\n LineChart,\n XAxis,\n YAxis,\n Line,\n CartesianGrid,\n Tooltip,\n Label,\n ResponsiveContainer,\n} from \"recharts\";\n\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { XAxisLabel } from \"./xAxisLabel\";\nimport { useRef } from \"react\";\nimport { numberToHumanStyle } from \"@orderly.network/utils\";\nimport { tickFormatter } from \"../utils/yTickFormatter\";\n\nexport type AssetChartDataItem = {\n date: string;\n account_value: number;\n};\n\nexport type PnlLineChartProps = {\n colors?: {\n profit: string;\n loss: string;\n };\n data: AssetChartDataItem[];\n invisible?: boolean;\n};\n\nconst CustomTooltip = (props: TooltipProps<any, any>) => {\n const { active, payload, label } = props;\n\n const todayStr = useRef(new Date().toISOString().split(\"T\")[0]);\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label === todayStr.current ? \"Now\" : label}\n value={payload[0].value}\n />\n );\n }\n\n return null;\n};\n\nconst AssetLineChart = (props: PnlLineChartProps) => {\n const colors = useColors(props.colors);\n\n // const dataTransfer = (data: any[]) => {\n // const series: any[] = [];\n\n // data.reduce((acc, item) => {\n // acc += item.pnl;\n // series.push({ ...item, pnl: acc, _pnl: item.pnl });\n // return acc;\n // }, 0);\n\n // return series;\n // };\n\n // const data = useMemo(() => dataTransfer(props.data), [props.data]);\n\n return (\n // @ts-ignore\n <ResponsiveContainer className={props.invisible ? \"chart-invisible\" : \"\"}>\n {/* @ts-ignore */}\n <LineChart\n width={530}\n height={180}\n data={props.data}\n margin={{ top: 20, right: 10, left: -20, bottom: -10 }}\n >\n <CartesianGrid vertical={false} stroke=\"#FFFFFF\" strokeOpacity={0.04} />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n interval={props.data.length - 2}\n // tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tick={<XAxisLabel />}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.04}\n ></XAxis>\n {/* @ts-ignore */}\n <YAxis\n dataKey=\"account_value\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n tickFormatter={(value) => tickFormatter(value)}\n />\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Tooltip\n cursor={{ strokeDasharray: \"3 2\", strokeOpacity: 0.16 }}\n content={<CustomTooltip />}\n />\n )}\n\n {/* <Legend /> */}\n {/* @ts-ignore */}\n {!props.invisible && (\n // @ts-ignore\n <Line\n type=\"natural\"\n dataKey=\"account_value\"\n stroke={colors.profit}\n strokeWidth={2}\n dot={false}\n isAnimationActive={false}\n />\n )}\n </LineChart>\n </ResponsiveContainer>\n );\n};\n\nexport { AssetLineChart };\n","import { useColors } from \"./useColors\";\nimport {\n BarChart,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Bar,\n Cell,\n Tooltip,\n CartesianGrid,\n ReferenceLine,\n Cross,\n} from \"recharts\";\nimport type { TooltipProps } from \"recharts\";\nimport { OrderlyChartTooltip } from \"./customTooltip\";\nimport { Box, cn } from \"@orderly.network/ui\";\n\nexport type VolChartDataItem = {\n date: string;\n volume: number;\n opacity?: string | number;\n};\n\nexport type VolChartTooltip = {\n rm?: number;\n dp?: number;\n};\n\nexport type VolChartProps = {\n colors?: {\n fill: string;\n };\n data: VolChartDataItem[];\n tooltip?: VolChartTooltip;\n className?: string;\n};\n\nconst RoundedRectangle = (props: any) => {\n const { fill, x, y, width, height, opacity } = props;\n const absHeight = Math.abs(height);\n\n return (\n <rect\n rx={2}\n x={x}\n y={height > 0 ? y : y + height}\n width={width}\n height={absHeight}\n stroke=\"none\"\n fill={fill}\n opacity={opacity}\n />\n );\n};\n\nconst CustomizedCross = (props: any) => {\n const { width, height, payload, stroke, fill } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n return (\n // @ts-ignore\n <Cross\n // y={props.y + props.top}\n x={props.x + props.width / 2}\n top={props.top}\n height={height}\n width={1}\n stroke={\"rgba(255,255,255,0.16)\"}\n strokeDasharray={\"3 2\"}\n fill={\"none\"}\n />\n );\n};\n\nconst CustomTooltip = (\n props: TooltipProps<any, any> & { tooltip?: VolChartTooltip }\n) => {\n const { active, payload, label, tooltip } = props;\n\n if (payload?.[0]?.value === 0) return null;\n\n if (active && payload && payload.length) {\n return (\n <OrderlyChartTooltip\n label={label}\n value={payload[0].value}\n // prefix=\"Commission\"\n titleClassName=\"oui-gap-4\"\n rm={tooltip?.rm}\n dp={tooltip?.dp}\n />\n );\n }\n\n return null;\n};\n\nexport const VolBarChart = (props: VolChartProps) => {\n const colors = useColors(\n props.colors?.fill\n ? { profit: props.colors?.fill, loss: props.colors?.fill }\n : undefined\n );\n\n const isEmpty = props.data.reduce((a, b) => a + b.volume, 0) === 0;\n const maxVolume = props.data.reduce((a,b) => (a > b.volume ? a : b.volume), 0);\n const decimal = maxVolume <= 10 ? 2 : (maxVolume <= 100 ? 1 : 0);\n\n return (\n // @ts-ignore\n <Box className={cn(props.className)}>\n {/* @ts-ignore */}\n <ResponsiveContainer>\n {/* @ts-ignore */}\n <BarChart\n data={props.data}\n margin={{ left: -0, top: 6, right: 0, bottom: 20 }}\n >\n {/* @ts-ignore */}\n <Tooltip\n // cursor={{ fillOpacity: 0.1 }}\n cursor={<CustomizedCross />}\n content={<CustomTooltip tooltip={props.tooltip} />}\n />\n <CartesianGrid\n vertical={false}\n stroke=\"#FFFFFF\"\n strokeOpacity={0.08}\n repeatCount={6}\n />\n <ReferenceLine y={0} stroke=\"#000\" />\n {/* @ts-ignore */}\n <Bar dataKey=\"volume\" shape={<RoundedRectangle />} minPointSize={1}>\n {props.data.map((entry, index) => {\n return (\n // @ts-ignore\n <Cell\n key={`cell-${index}`}\n fill={entry.volume > 0 ? colors.profit : colors.loss}\n opacity={entry.opacity}\n />\n );\n })}\n </Bar>\n {/* @ts-ignore */}\n <YAxis\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n tickLine={false}\n axisLine={false}\n dataKey={\"volume\"}\n tickFormatter={(value, index) => {\n if (isEmpty) return `${index * 100}`;\n return numberToHumanStyle(value, decimal);\n }}\n width={45}\n />\n {/* @ts-ignore */}\n <XAxis\n dataKey=\"date\"\n // axisLine={false}\n tickLine={false}\n interval={props.data.length - 2}\n // tick={renderQuarterTick}\n height={1}\n // scale=\"time\"\n tick={{ fontSize: 10, fill: \"rgba(255,255,255,0.54)\" }}\n stroke=\"rgb(229, 231, 235)\"\n strokeOpacity={0.2}\n />\n </BarChart>\n </ResponsiveContainer>\n </Box>\n );\n};\nfunction numberToHumanStyle(number: number, decimalPlaces: number = 0): string {\n const abbreviations = [\"\", \"K\", \"M\", \"B\", \"T\"];\n\n let index = 0;\n while (number >= 1000 && index < abbreviations.length - 1) {\n number /= 1000;\n index++;\n }\n\n const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);\n\n return `${roundedNumber}${abbreviations[index]}`;\n}\n\nfunction toFixedWithoutRounding(num: number, fix: number): string {\n const numStr = num.toString();\n const decimalIndex = numStr.indexOf(\".\");\n\n if (decimalIndex === -1 || fix === 0) {\n return numStr.split(\".\")[0];\n }\n\n const cutoffIndex = decimalIndex + fix + 1;\n\n return numStr.slice(0, cutoffIndex);\n}\n","import plugin from \"tailwindcss/plugin\";\n\nimport { PluginCreator } from \"tailwindcss/types/config\";\n\nexport const chartPlugin: PluginCreator = () =>\n plugin(function ({ addComponents, addBase }) {\n addComponents(\n {\n \".xAxis\": {\n \".recharts-cartesian-axis-tick:first-child text\": {\n \"text-anchor\": \"start\",\n },\n \".recharts-cartesian-axis-tick:last-child text\": {\n \"text-anchor\": \"end\",\n },\n },\n },\n {\n respectPrefix: false,\n }\n );\n });\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orderly.network/chart",
3
- "version": "2.0.3",
3
+ "version": "2.0.4-alpha.0",
4
4
  "description": "Charting library for Orderly Network",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -23,7 +23,7 @@
23
23
  "react-dom": "^18.2.0",
24
24
  "tailwindcss": "^3.4.4",
25
25
  "tsup": "^8.1.0",
26
- "tsconfig": "0.3.19"
26
+ "tsconfig": "0.3.20-alpha.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": ">=18",
@@ -36,8 +36,8 @@
36
36
  "d3-selection": "^3.0.0",
37
37
  "d3-shape": "^3.2.0",
38
38
  "recharts": "^2.12.7",
39
- "@orderly.network/utils": "2.0.3",
40
- "@orderly.network/ui": "2.0.3"
39
+ "@orderly.network/ui": "2.0.4-alpha.0",
40
+ "@orderly.network/utils": "2.0.4-alpha.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsup",