@orderly.network/chart 2.8.1 → 2.8.2

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.mjs CHANGED
@@ -1,2 +1,909 @@
1
- import {useMemo,useRef,useId}from'react';import {ResponsiveContainer,BarChart,Tooltip,CartesianGrid,ReferenceLine,Bar,Cell,YAxis,XAxis,LineChart,Line,AreaChart,Area,Cross}from'recharts';export{Area,AreaChart,Bar,BarChart,Cell,Line,LineChart}from'recharts';import {useTranslation}from'@orderly.network/i18n';import {cn,useScreen,Box,Flex,Text}from'@orderly.network/ui';import {numberToHumanStyle}from'@orderly.network/utils';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Y=Object.create;var L=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var F=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var J=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of q(r))!U.call(t,a)&&a!==e&&L(t,a,{get:()=>r[a],enumerable:!(o=H(r,a))||o.enumerable});return t};var Z=(t,r,e)=>(e=t!=null?Y(Q(t)):{},J(!t||!t.__esModule?L(e,"default",{value:t,enumerable:true}):e,t));var $=F(R=>{Object.defineProperty(R,"__esModule",{value:true});Object.defineProperty(R,"default",{enumerable:true,get:function(){return Xe}});function M(t,r){return {handler:t,config:r}}M.withOptions=function(t,r=()=>({})){let e=function(o){return {__options:o,handler:t(o),config:r(o)}};return e.__isOptionsFunction=true,e.__pluginFunction=t,e.__configFunction=r,e};var Xe=M;});var G=F(A=>{Object.defineProperty(A,"__esModule",{value:true});Object.defineProperty(A,"default",{enumerable:true,get:function(){return Ye}});var We=Ee($());function Ee(t){return t&&t.__esModule?t:{default:t}}var Ye=We.default;});var W=F((ho,X)=>{var T=G();X.exports=(T.__esModule?T:{default:T}).default;});var d=t=>{let r=Math.abs(t),e=r===0?0:r<=10?2:r<=100?1:0,o=numberToHumanStyle(r,e);return t<0?`-${o}`:o};var p=t=>{let{label:r,value:e,prefix:o,unit:a="USDC",coloring:i=false,dp:n,rm:y}=t;return jsxs(Box,{intensity:600,p:3,r:"md",children:[jsxs(Flex,{direction:"row",className:t.titleClassName,children:[o,jsx(Text.numeral,{unit:a,as:"div",size:"sm",coloring:i,showIdentifier:i,unitClassName:"oui-text-base-contrast-54 oui-ml-1",weight:"semibold",rm:y,dp:n,children:e})]}),jsx(Text,{size:"2xs",intensity:54,weight:"semibold",children:r})]})};var _=()=>{let t=document.documentElement,r=getComputedStyle(t);return {primary:h(r.getPropertyValue("--oui-color-primary")),primaryLight:h(r.getPropertyValue("--oui-color-primary-light")),secondary:h(r.getPropertyValue("--oui-color-secondary")),success:h(r.getPropertyValue("--oui-color-success")),warning:h(r.getPropertyValue("--oui-color-warning")),danger:h(r.getPropertyValue("--oui-color-danger")),info:h(r.getPropertyValue("--oui-color-info")),loss:h(r.getPropertyValue("--oui-color-trading-loss")),profit:h(r.getPropertyValue("--oui-color-trading-profit"))}},h=t=>`rgb(${t.split(" ").join(",")})`;var m=t=>useMemo(()=>{let e=_();return {profit:t?.profit||e.profit,loss:t?.loss||e.loss,primary:e.primary,primaryLight:e.primaryLight}},[t]);var dt=t=>{let{fill:r,x:e,y:o,width:a,height:i}=t,n=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?o:o+i,width:a,height:n,stroke:"none",fill:r})},yt=t=>{let{x:r,y:e,stroke:o,payload:a,index:i,width:n,containerWidth:y}=t,{t:v}=useTranslation(),x=i===0?48:y>0?y-10:n+a.offset;return jsx("g",{transform:`translate(${x},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:i===0?"start":"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?a.value:v("chart.now")})})},ht=t=>{let{width:r,height:e,stroke:o,fill:a}=t;return jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},Ct=t=>{let{active:r,payload:e,label:o}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return r&&e&&e.length?jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},gt=t=>{let{invisible:r,data:e,responsiveContainerProps:o}=t,a=m(t.colors),i=useRef(0);return jsx(ResponsiveContainer,{className:cn(r&&"chart-invisible"),onResize:n=>{i.current=n;},...o,children:jsxs(BarChart,{data:e,margin:{left:-10,top:10,right:10,bottom:30},children:[!r&&jsx(Tooltip,{cursor:jsx(ht,{}),content:jsx(Ct,{})}),jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(ReferenceLine,{y:0,stroke:"rgba(0,0,0,0.04)"}),!r&&jsx(Bar,{dataKey:"pnl",shape:jsx(dt,{}),children:e.map((n,y)=>jsx(Cell,{fill:n.pnl>0?a.profit:a.loss},`cell-${y}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickFormatter:n=>d(n),tickLine:false,axisLine:false,dataKey:"pnl"}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:e.length-2,height:1,tick:jsx(yt,{containerWidth:i.current}),stroke:"#FFFFFF",strokeOpacity:.04})]})})};var C=t=>{let{x:r,y:e,stroke:o,payload:a,index:i}=t,{t:n}=useTranslation();return jsx("g",{transform:`translate(${r},${e-6})`,children:jsx("text",{x:0,y:0,dy:16,textAnchor:"end",fontSize:10,fill:"rgba(255,255,255,0.54)",children:i===0?a.value:n("chart.now")})})};var _t=t=>{let{active:r,payload:e,label:o}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return r&&e&&e.length?jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},Bt=t=>{let r=[];return t?.reduce((e,o)=>(e+=o.pnl,r.push({...o,pnl:e,_pnl:o.pnl}),e),0),r},It=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),{isMobile:o}=useScreen(),a=useMemo(()=>Bt(t.data),[t.data]),i=jsxs(LineChart,{data:a,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(C,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:d}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(_t,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:o?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var Ht=t=>{let{active:r,payload:e,label:o}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return r&&e&&e.length?jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value,coloring:true}):null},qt=t=>{let r=[];return t?.reduce((e,o)=>(e+=o.pnl,r.push({...o,pnl:e,_pnl:o.pnl}),e),0),r},Qt=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),{isMobile:o}=useScreen(),a=useId(),i=useMemo(()=>qt(t.data),[t.data]),n=useMemo(()=>i.map(v=>v.pnl).sort((v,x)=>v-x)[0]||0,[i]),y=jsxs(AreaChart,{data:i,margin:{top:20,right:10,left:-10,bottom:0},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(C,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"pnl",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:d}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(Ht,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:e.primary,offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:e.primary,offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"pnl",stroke:e.primary,strokeWidth:o?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${a})`,baseValue:n||0})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:y})};var se=t=>{let{active:r,payload:e,label:o}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return r&&e&&e.length?jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value}):null},le=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),o=useId(),{isMobile:a}=useScreen(),i=a?jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(C,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:n=>d(n)}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:o,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${o})`})]})]}):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(C,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:d}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(se,{})}),!t.invisible&&jsx(Line,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var xe=t=>{let{active:r,payload:e,label:o}=t,a=useRef(new Date().toISOString().split("T")[0]),{t:i}=useTranslation();return r&&e&&e.length?jsx(p,{label:o===a.current?i("chart.now"):o,value:e[0].value}):null},Fe=t=>{let{responsiveContainerProps:r}=t,e=m(t.colors),o=useId(),{isMobile:a}=useScreen(),i=jsxs(AreaChart,{width:530,height:180,data:t.data,margin:{top:20,right:10,left:-20,bottom:-10},children:[jsx(CartesianGrid,{vertical:false,stroke:"#FFFFFF",strokeOpacity:.04}),jsx(XAxis,{dataKey:"date",interval:t.data.length-2,tick:jsx(C,{}),stroke:"#FFFFFF",strokeOpacity:.04}),jsx(YAxis,{dataKey:"account_value",tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,tickFormatter:d}),!t.invisible&&jsx(Tooltip,{cursor:{strokeDasharray:"3 2",strokeOpacity:.16},content:jsx(xe,{})}),!t.invisible&&jsxs(Fragment,{children:[jsx("defs",{children:jsxs("linearGradient",{id:o,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{stopColor:"#00B49E",offset:"0%",stopOpacity:.5}),jsx("stop",{stopColor:"#00B49E",offset:"100%",stopOpacity:0})]})}),jsx(Area,{type:"natural",dataKey:"account_value",stroke:e.profit,strokeWidth:a?1.5:2,dot:false,isAnimationActive:false,fill:`url(#${o})`})]})]});return jsx(ResponsiveContainer,{className:t.invisible?"chart-invisible":void 0,...r,children:i})};var Ve=t=>{let{fill:r,x:e,y:o,width:a,height:i,opacity:n}=t,y=Math.abs(i);return jsx("rect",{rx:2,x:e,y:i>0?o:o+i,width:a,height:y,stroke:"none",fill:r,opacity:n})},Ke=t=>{let{width:r,height:e,payload:o,stroke:a,fill:i}=t;return o?.[0]?.value===0?null:jsx(Cross,{x:t.x+t.width/2,top:t.top,height:e,width:1,stroke:"rgba(255,255,255,0.16)",strokeDasharray:"3 2",fill:"none"})},ze=t=>{let{active:r,payload:e,label:o,tooltip:a}=t;return e?.[0]?.value===0?null:r&&e&&e.length?jsx(p,{label:o,value:e[0].value,titleClassName:"oui-gap-4",rm:a?.rm,dp:a?.dp}):null},Ne=t=>{let r=m(t.colors?.fill?{profit:t.colors?.fill,loss:t.colors?.fill}:void 0),e=t.data?.reduce((i,n)=>i+n.volume,0)===0,o=t.data?.reduce((i,n)=>i>n.volume?i:n.volume,0),a=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(Ke,{}),content:jsx(ze,{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(Ve,{}),minPointSize:1,children:t.data.map((i,n)=>jsx(Cell,{fill:i.volume>0?r.profit:r.loss,opacity:i.opacity},`cell-${n}`))}),jsx(YAxis,{tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},tickLine:false,axisLine:false,dataKey:"volume",tickFormatter:(i,n)=>e?`${n*100}`:Me(i,a),width:45}),jsx(XAxis,{dataKey:"date",tickLine:false,interval:t.data.length-2,height:1,tick:{fontSize:10,fill:"rgba(255,255,255,0.54)"},stroke:"rgb(229, 231, 235)",strokeOpacity:.2})]})})})};function Me(t,r=0){let e=["","K","M","B","T"],o=0;for(;t>=1e3&&o<e.length-1;)t/=1e3,o++;return `${$e(t,r)}${e[o]}`}function $e(t,r){let e=t.toString(),o=e.indexOf(".");if(o===-1||r===0)return e.split(".")[0];let a=o+r+1;return e.slice(0,a)}var E=Z(W()),He=()=>(0, E.default)(function({addComponents:t,addBase:r}){t({".xAxis":{".recharts-cartesian-axis-tick:first-child text":{"text-anchor":"start"},".recharts-cartesian-axis-tick:last-child text":{"text-anchor":"end"}}},{respectPrefix:false});});export{Fe as AssetAreaChart,le as AssetLineChart,gt as PnLBarChart,Qt as PnlAreaChart,It as PnlLineChart,Ne as VolBarChart,He as chartPlugin};//# sourceMappingURL=index.mjs.map
1
+ import { useRef, useMemo, useId } from 'react';
2
+ import { ResponsiveContainer, BarChart, Tooltip, CartesianGrid, ReferenceLine, Bar, Cell, YAxis, XAxis, LineChart, Line, AreaChart, Area, Cross } from 'recharts';
3
+ export { Area, AreaChart, Bar, BarChart, Cell, Line, LineChart } from 'recharts';
4
+ import { useTranslation } from '@orderly.network/i18n';
5
+ import { cn, useScreen, Box, Flex, Text } from '@orderly.network/ui';
6
+ import { numberToHumanStyle } from '@orderly.network/utils';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+
9
+ var __create = Object.create;
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __commonJS = (cb, mod) => function __require() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/util/createPlugin.js
36
+ var require_createPlugin = __commonJS({
37
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/util/createPlugin.js"(exports) {
38
+ Object.defineProperty(exports, "__esModule", {
39
+ value: true
40
+ });
41
+ Object.defineProperty(exports, "default", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return _default;
45
+ }
46
+ });
47
+ function createPlugin(plugin2, config) {
48
+ return {
49
+ handler: plugin2,
50
+ config
51
+ };
52
+ }
53
+ createPlugin.withOptions = function(pluginFunction, configFunction = () => ({})) {
54
+ const optionsFunction = function(options) {
55
+ return {
56
+ __options: options,
57
+ handler: pluginFunction(options),
58
+ config: configFunction(options)
59
+ };
60
+ };
61
+ optionsFunction.__isOptionsFunction = true;
62
+ optionsFunction.__pluginFunction = pluginFunction;
63
+ optionsFunction.__configFunction = configFunction;
64
+ return optionsFunction;
65
+ };
66
+ var _default = createPlugin;
67
+ }
68
+ });
69
+
70
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/public/create-plugin.js
71
+ var require_create_plugin = __commonJS({
72
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/lib/public/create-plugin.js"(exports) {
73
+ Object.defineProperty(exports, "__esModule", {
74
+ value: true
75
+ });
76
+ Object.defineProperty(exports, "default", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return _default;
80
+ }
81
+ });
82
+ var _createPlugin = /* @__PURE__ */ _interop_require_default(require_createPlugin());
83
+ function _interop_require_default(obj) {
84
+ return obj && obj.__esModule ? obj : {
85
+ default: obj
86
+ };
87
+ }
88
+ var _default = _createPlugin.default;
89
+ }
90
+ });
91
+
92
+ // ../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/plugin.js
93
+ var require_plugin = __commonJS({
94
+ "../../node_modules/.pnpm/tailwindcss@3.4.17_ts-node@10.9.2_@swc+core@1.13.2_@swc+helpers@0.5.17__@types+node@24.3.1_typescript@5.8.3_/node_modules/tailwindcss/plugin.js"(exports, module) {
95
+ var createPlugin = require_create_plugin();
96
+ module.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default;
97
+ }
98
+ });
99
+ var tickFormatter = (value) => {
100
+ const absValue = Math.abs(value);
101
+ const dp = absValue === 0 ? 0 : absValue <= 10 ? 2 : absValue <= 100 ? 1 : 0;
102
+ const formatted = numberToHumanStyle(absValue, dp);
103
+ return value < 0 ? `-${formatted}` : formatted;
104
+ };
105
+ var OrderlyChartTooltip = (props) => {
106
+ const {
107
+ label,
108
+ value,
109
+ prefix,
110
+ unit = "USDC",
111
+ coloring = false,
112
+ dp,
113
+ rm
114
+ } = props;
115
+ return /* @__PURE__ */ jsxs(Box, { intensity: 600, p: 3, r: "md", children: [
116
+ /* @__PURE__ */ jsxs(Flex, { direction: "row", className: props.titleClassName, children: [
117
+ prefix,
118
+ /* @__PURE__ */ jsx(
119
+ Text.numeral,
120
+ {
121
+ unit,
122
+ as: "div",
123
+ size: "sm",
124
+ coloring,
125
+ showIdentifier: coloring,
126
+ unitClassName: "oui-text-base-contrast-54 oui-ml-1",
127
+ weight: "semibold",
128
+ rm,
129
+ dp,
130
+ children: value
131
+ }
132
+ )
133
+ ] }),
134
+ /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, weight: "semibold", children: label })
135
+ ] });
136
+ };
137
+
138
+ // src/utils/theme.ts
139
+ var getThemeColors = () => {
140
+ const root = document.documentElement;
141
+ const computedStyle = getComputedStyle(root);
142
+ const colors = {
143
+ primary: convertToRGB(
144
+ computedStyle.getPropertyValue("--oui-color-primary")
145
+ ),
146
+ primaryLight: convertToRGB(
147
+ computedStyle.getPropertyValue("--oui-color-primary-light")
148
+ ),
149
+ secondary: convertToRGB(
150
+ computedStyle.getPropertyValue("--oui-color-secondary")
151
+ ),
152
+ success: convertToRGB(
153
+ computedStyle.getPropertyValue("--oui-color-success")
154
+ ),
155
+ warning: convertToRGB(
156
+ computedStyle.getPropertyValue("--oui-color-warning")
157
+ ),
158
+ danger: convertToRGB(computedStyle.getPropertyValue("--oui-color-danger")),
159
+ info: convertToRGB(computedStyle.getPropertyValue("--oui-color-info")),
160
+ loss: convertToRGB(
161
+ computedStyle.getPropertyValue("--oui-color-trading-loss")
162
+ ),
163
+ profit: convertToRGB(
164
+ computedStyle.getPropertyValue("--oui-color-trading-profit")
165
+ )
166
+ };
167
+ return colors;
168
+ };
169
+ var convertToRGB = (color) => {
170
+ return `rgb(${color.split(" ").join(",")})`;
171
+ };
172
+
173
+ // src/orderly/useColors.ts
174
+ var useColors = (colors) => {
175
+ const _colors = useMemo(() => {
176
+ const themeColors = getThemeColors();
177
+ return {
178
+ profit: colors?.profit || themeColors.profit,
179
+ loss: colors?.loss || themeColors.loss,
180
+ primary: themeColors.primary,
181
+ primaryLight: themeColors.primaryLight
182
+ };
183
+ }, [colors]);
184
+ return _colors;
185
+ };
186
+ var RoundedRectangle = (props) => {
187
+ const { fill, x, y, width, height } = props;
188
+ const absHeight = Math.abs(height);
189
+ return /* @__PURE__ */ jsx(
190
+ "rect",
191
+ {
192
+ rx: 2,
193
+ x,
194
+ y: height > 0 ? y : y + height,
195
+ width,
196
+ height: absHeight,
197
+ stroke: "none",
198
+ fill
199
+ }
200
+ );
201
+ };
202
+ var XAxisLabel = (props) => {
203
+ const { x, y, stroke, payload, index, width, containerWidth } = props;
204
+ const { t } = useTranslation();
205
+ const _x = index === 0 ? 48 : containerWidth > 0 ? containerWidth - 10 : width + payload.offset;
206
+ return /* @__PURE__ */ jsx("g", { transform: `translate(${_x},${y - 6})`, children: /* @__PURE__ */ jsx(
207
+ "text",
208
+ {
209
+ x: 0,
210
+ y: 0,
211
+ dy: 16,
212
+ textAnchor: index === 0 ? "start" : "end",
213
+ fontSize: 10,
214
+ fill: "rgba(255,255,255,0.54)",
215
+ children: index === 0 ? payload.value : t("chart.now")
216
+ }
217
+ ) });
218
+ };
219
+ var CustomizedCross = (props) => {
220
+ const { width, height, stroke, fill } = props;
221
+ return /* @__PURE__ */ jsx(
222
+ Cross,
223
+ {
224
+ x: props.x + props.width / 2,
225
+ top: props.top,
226
+ height,
227
+ width: 1,
228
+ stroke: "rgba(255,255,255,0.16)",
229
+ strokeDasharray: "3 2",
230
+ fill: "none"
231
+ }
232
+ );
233
+ };
234
+ var CustomTooltip = (props) => {
235
+ const { active, payload, label } = props;
236
+ const todayStr = useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
237
+ const { t } = useTranslation();
238
+ if (active && payload && payload.length) {
239
+ return /* @__PURE__ */ jsx(
240
+ OrderlyChartTooltip,
241
+ {
242
+ label: label === todayStr.current ? t("chart.now") : label,
243
+ value: payload[0].value,
244
+ coloring: true
245
+ }
246
+ );
247
+ }
248
+ return null;
249
+ };
250
+ var PnLBarChart = (props) => {
251
+ const { invisible, data, responsiveContainerProps } = props;
252
+ const colors = useColors(props.colors);
253
+ const widthRef = useRef(0);
254
+ return /* @__PURE__ */ jsx(
255
+ ResponsiveContainer,
256
+ {
257
+ className: cn(invisible && "chart-invisible"),
258
+ onResize: (width) => {
259
+ widthRef.current = width;
260
+ },
261
+ ...responsiveContainerProps,
262
+ children: /* @__PURE__ */ jsxs(
263
+ BarChart,
264
+ {
265
+ data,
266
+ margin: { left: -10, top: 10, right: 10, bottom: 30 },
267
+ children: [
268
+ !invisible && /* @__PURE__ */ jsx(
269
+ Tooltip,
270
+ {
271
+ cursor: /* @__PURE__ */ jsx(CustomizedCross, {}),
272
+ content: /* @__PURE__ */ jsx(CustomTooltip, {})
273
+ }
274
+ ),
275
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
276
+ /* @__PURE__ */ jsx(ReferenceLine, { y: 0, stroke: "rgba(0,0,0,0.04)" }),
277
+ !invisible && /* @__PURE__ */ jsx(Bar, { dataKey: "pnl", shape: /* @__PURE__ */ jsx(RoundedRectangle, {}), children: data.map((entry, index) => {
278
+ return /* @__PURE__ */ jsx(
279
+ Cell,
280
+ {
281
+ fill: entry.pnl > 0 ? colors.profit : colors.loss
282
+ },
283
+ `cell-${index}`
284
+ );
285
+ }) }),
286
+ /* @__PURE__ */ jsx(
287
+ YAxis,
288
+ {
289
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
290
+ tickFormatter: (value) => tickFormatter(value),
291
+ tickLine: false,
292
+ axisLine: false,
293
+ dataKey: "pnl"
294
+ }
295
+ ),
296
+ /* @__PURE__ */ jsx(
297
+ XAxis,
298
+ {
299
+ dataKey: "date",
300
+ tickLine: false,
301
+ interval: data.length - 2,
302
+ height: 1,
303
+ tick: /* @__PURE__ */ jsx(XAxisLabel, { containerWidth: widthRef.current }),
304
+ stroke: "#FFFFFF",
305
+ strokeOpacity: 0.04
306
+ }
307
+ )
308
+ ]
309
+ }
310
+ )
311
+ }
312
+ );
313
+ };
314
+ var XAxisLabel2 = (props) => {
315
+ const { x, y, stroke, payload, index } = props;
316
+ const { t } = useTranslation();
317
+ return /* @__PURE__ */ jsx("g", { transform: `translate(${x},${y - 6})`, children: /* @__PURE__ */ jsx(
318
+ "text",
319
+ {
320
+ x: 0,
321
+ y: 0,
322
+ dy: 16,
323
+ textAnchor: "end",
324
+ fontSize: 10,
325
+ fill: "rgba(255,255,255,0.54)",
326
+ children: index === 0 ? payload.value : t("chart.now")
327
+ }
328
+ ) });
329
+ };
330
+ var CustomTooltip2 = (props) => {
331
+ const { active, payload, label } = props;
332
+ const todayStr = useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
333
+ const { t } = useTranslation();
334
+ if (active && payload && payload.length) {
335
+ return /* @__PURE__ */ jsx(
336
+ OrderlyChartTooltip,
337
+ {
338
+ label: label === todayStr.current ? t("chart.now") : label,
339
+ value: payload[0].value,
340
+ coloring: true
341
+ }
342
+ );
343
+ }
344
+ return null;
345
+ };
346
+ var dataTransfer = (data) => {
347
+ const series = [];
348
+ data?.reduce((acc, item) => {
349
+ acc += item.pnl;
350
+ series.push({ ...item, pnl: acc, _pnl: item.pnl });
351
+ return acc;
352
+ }, 0);
353
+ return series;
354
+ };
355
+ var PnlLineChart = (props) => {
356
+ const { responsiveContainerProps } = props;
357
+ const colors = useColors(props.colors);
358
+ const { isMobile } = useScreen();
359
+ const data = useMemo(() => dataTransfer(props.data), [props.data]);
360
+ const chartComponent = /* @__PURE__ */ jsxs(
361
+ LineChart,
362
+ {
363
+ data,
364
+ margin: { top: 20, right: 10, left: -10, bottom: 0 },
365
+ children: [
366
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
367
+ /* @__PURE__ */ jsx(
368
+ XAxis,
369
+ {
370
+ dataKey: "date",
371
+ interval: props.data.length - 2,
372
+ tick: /* @__PURE__ */ jsx(XAxisLabel2, {}),
373
+ stroke: "#FFFFFF",
374
+ strokeOpacity: 0.04
375
+ }
376
+ ),
377
+ /* @__PURE__ */ jsx(
378
+ YAxis,
379
+ {
380
+ dataKey: "pnl",
381
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
382
+ tickLine: false,
383
+ axisLine: false,
384
+ tickFormatter
385
+ }
386
+ ),
387
+ !props.invisible && /* @__PURE__ */ jsx(
388
+ Tooltip,
389
+ {
390
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
391
+ content: /* @__PURE__ */ jsx(CustomTooltip2, {})
392
+ }
393
+ ),
394
+ !props.invisible && /* @__PURE__ */ jsx(
395
+ Line,
396
+ {
397
+ type: "natural",
398
+ dataKey: "pnl",
399
+ stroke: colors.primary,
400
+ strokeWidth: isMobile ? 1.5 : 2,
401
+ dot: false,
402
+ isAnimationActive: false
403
+ }
404
+ )
405
+ ]
406
+ }
407
+ );
408
+ return /* @__PURE__ */ jsx(
409
+ ResponsiveContainer,
410
+ {
411
+ className: props.invisible ? "chart-invisible" : void 0,
412
+ ...responsiveContainerProps,
413
+ children: chartComponent
414
+ }
415
+ );
416
+ };
417
+ var CustomTooltip3 = (props) => {
418
+ const { active, payload, label } = props;
419
+ const todayStr = useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
420
+ const { t } = useTranslation();
421
+ if (active && payload && payload.length) {
422
+ return /* @__PURE__ */ jsx(
423
+ OrderlyChartTooltip,
424
+ {
425
+ label: label === todayStr.current ? t("chart.now") : label,
426
+ value: payload[0].value,
427
+ coloring: true
428
+ }
429
+ );
430
+ }
431
+ return null;
432
+ };
433
+ var dataTransfer2 = (data) => {
434
+ const series = [];
435
+ data?.reduce((acc, item) => {
436
+ acc += item.pnl;
437
+ series.push({ ...item, pnl: acc, _pnl: item.pnl });
438
+ return acc;
439
+ }, 0);
440
+ return series;
441
+ };
442
+ var PnlAreaChart = (props) => {
443
+ const { responsiveContainerProps } = props;
444
+ const colors = useColors(props.colors);
445
+ const { isMobile } = useScreen();
446
+ const colorId = useId();
447
+ const data = useMemo(() => dataTransfer2(props.data), [props.data]);
448
+ const baseValue = useMemo(
449
+ () => data.map((item) => item.pnl).sort((a, b) => a - b)[0] || 0,
450
+ [data]
451
+ );
452
+ const chartComponent = /* @__PURE__ */ jsxs(
453
+ AreaChart,
454
+ {
455
+ data,
456
+ margin: { top: 20, right: 10, left: -10, bottom: 0 },
457
+ children: [
458
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
459
+ /* @__PURE__ */ jsx(
460
+ XAxis,
461
+ {
462
+ dataKey: "date",
463
+ interval: props.data.length - 2,
464
+ tick: /* @__PURE__ */ jsx(XAxisLabel2, {}),
465
+ stroke: "#FFFFFF",
466
+ strokeOpacity: 0.04
467
+ }
468
+ ),
469
+ /* @__PURE__ */ jsx(
470
+ YAxis,
471
+ {
472
+ dataKey: "pnl",
473
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
474
+ tickLine: false,
475
+ axisLine: false,
476
+ tickFormatter
477
+ }
478
+ ),
479
+ !props.invisible && /* @__PURE__ */ jsx(
480
+ Tooltip,
481
+ {
482
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
483
+ content: /* @__PURE__ */ jsx(CustomTooltip3, {})
484
+ }
485
+ ),
486
+ !props.invisible && /* @__PURE__ */ jsxs(Fragment, { children: [
487
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
488
+ /* @__PURE__ */ jsx("stop", { stopColor: colors.primary, offset: "0%", stopOpacity: 0.5 }),
489
+ /* @__PURE__ */ jsx("stop", { stopColor: colors.primary, offset: "100%", stopOpacity: 0 })
490
+ ] }) }),
491
+ /* @__PURE__ */ jsx(
492
+ Area,
493
+ {
494
+ type: "natural",
495
+ dataKey: "pnl",
496
+ stroke: colors.primary,
497
+ strokeWidth: isMobile ? 1.5 : 2,
498
+ dot: false,
499
+ isAnimationActive: false,
500
+ fill: `url(#${colorId})`,
501
+ baseValue: baseValue || 0
502
+ }
503
+ )
504
+ ] })
505
+ ]
506
+ }
507
+ );
508
+ return /* @__PURE__ */ jsx(
509
+ ResponsiveContainer,
510
+ {
511
+ className: props.invisible ? "chart-invisible" : void 0,
512
+ ...responsiveContainerProps,
513
+ children: chartComponent
514
+ }
515
+ );
516
+ };
517
+ var CustomTooltip4 = (props) => {
518
+ const { active, payload, label } = props;
519
+ const todayStr = useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
520
+ const { t } = useTranslation();
521
+ if (active && payload && payload.length) {
522
+ return /* @__PURE__ */ jsx(
523
+ OrderlyChartTooltip,
524
+ {
525
+ label: label === todayStr.current ? t("chart.now") : label,
526
+ value: payload[0].value
527
+ }
528
+ );
529
+ }
530
+ return null;
531
+ };
532
+ var AssetLineChart = (props) => {
533
+ const { responsiveContainerProps } = props;
534
+ const colors = useColors(props.colors);
535
+ const colorId = useId();
536
+ const { isMobile } = useScreen();
537
+ const chartComponent = isMobile ? /* @__PURE__ */ jsxs(
538
+ AreaChart,
539
+ {
540
+ width: 530,
541
+ height: 180,
542
+ data: props.data,
543
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
544
+ children: [
545
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
546
+ /* @__PURE__ */ jsx(
547
+ XAxis,
548
+ {
549
+ dataKey: "date",
550
+ interval: props.data.length - 2,
551
+ tick: /* @__PURE__ */ jsx(XAxisLabel2, {}),
552
+ stroke: "#FFFFFF",
553
+ strokeOpacity: 0.04
554
+ }
555
+ ),
556
+ /* @__PURE__ */ jsx(
557
+ YAxis,
558
+ {
559
+ dataKey: "account_value",
560
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
561
+ tickLine: false,
562
+ axisLine: false,
563
+ tickFormatter: (value) => tickFormatter(value)
564
+ }
565
+ ),
566
+ !props.invisible && /* @__PURE__ */ jsxs(Fragment, { children: [
567
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
568
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
569
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
570
+ ] }) }),
571
+ /* @__PURE__ */ jsx(
572
+ Area,
573
+ {
574
+ type: "natural",
575
+ dataKey: "account_value",
576
+ stroke: colors.profit,
577
+ strokeWidth: isMobile ? 1.5 : 2,
578
+ dot: false,
579
+ isAnimationActive: false,
580
+ fill: `url(#${colorId})`
581
+ }
582
+ )
583
+ ] })
584
+ ]
585
+ }
586
+ ) : /* @__PURE__ */ jsxs(
587
+ LineChart,
588
+ {
589
+ width: 530,
590
+ height: 180,
591
+ data: props.data,
592
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
593
+ children: [
594
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
595
+ /* @__PURE__ */ jsx(
596
+ XAxis,
597
+ {
598
+ dataKey: "date",
599
+ interval: props.data.length - 2,
600
+ tick: /* @__PURE__ */ jsx(XAxisLabel2, {}),
601
+ stroke: "#FFFFFF",
602
+ strokeOpacity: 0.04
603
+ }
604
+ ),
605
+ /* @__PURE__ */ jsx(
606
+ YAxis,
607
+ {
608
+ dataKey: "account_value",
609
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
610
+ tickLine: false,
611
+ axisLine: false,
612
+ tickFormatter
613
+ }
614
+ ),
615
+ !props.invisible && /* @__PURE__ */ jsx(
616
+ Tooltip,
617
+ {
618
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
619
+ content: /* @__PURE__ */ jsx(CustomTooltip4, {})
620
+ }
621
+ ),
622
+ !props.invisible && /* @__PURE__ */ jsx(
623
+ Line,
624
+ {
625
+ type: "natural",
626
+ dataKey: "account_value",
627
+ stroke: colors.profit,
628
+ strokeWidth: isMobile ? 1.5 : 2,
629
+ dot: false,
630
+ isAnimationActive: false
631
+ }
632
+ )
633
+ ]
634
+ }
635
+ );
636
+ return /* @__PURE__ */ jsx(
637
+ ResponsiveContainer,
638
+ {
639
+ className: props.invisible ? "chart-invisible" : void 0,
640
+ ...responsiveContainerProps,
641
+ children: chartComponent
642
+ }
643
+ );
644
+ };
645
+ var CustomTooltip5 = (props) => {
646
+ const { active, payload, label } = props;
647
+ const todayStr = useRef((/* @__PURE__ */ new Date()).toISOString().split("T")[0]);
648
+ const { t } = useTranslation();
649
+ if (active && payload && payload.length) {
650
+ return /* @__PURE__ */ jsx(
651
+ OrderlyChartTooltip,
652
+ {
653
+ label: label === todayStr.current ? t("chart.now") : label,
654
+ value: payload[0].value
655
+ }
656
+ );
657
+ }
658
+ return null;
659
+ };
660
+ var AssetAreaChart = (props) => {
661
+ const { responsiveContainerProps } = props;
662
+ const colors = useColors(props.colors);
663
+ const colorId = useId();
664
+ const { isMobile } = useScreen();
665
+ const chartComponent = /* @__PURE__ */ jsxs(
666
+ AreaChart,
667
+ {
668
+ width: 530,
669
+ height: 180,
670
+ data: props.data,
671
+ margin: { top: 20, right: 10, left: -20, bottom: -10 },
672
+ children: [
673
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "#FFFFFF", strokeOpacity: 0.04 }),
674
+ /* @__PURE__ */ jsx(
675
+ XAxis,
676
+ {
677
+ dataKey: "date",
678
+ interval: props.data.length - 2,
679
+ tick: /* @__PURE__ */ jsx(XAxisLabel2, {}),
680
+ stroke: "#FFFFFF",
681
+ strokeOpacity: 0.04
682
+ }
683
+ ),
684
+ /* @__PURE__ */ jsx(
685
+ YAxis,
686
+ {
687
+ dataKey: "account_value",
688
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
689
+ tickLine: false,
690
+ axisLine: false,
691
+ tickFormatter
692
+ }
693
+ ),
694
+ !props.invisible && /* @__PURE__ */ jsx(
695
+ Tooltip,
696
+ {
697
+ cursor: { strokeDasharray: "3 2", strokeOpacity: 0.16 },
698
+ content: /* @__PURE__ */ jsx(CustomTooltip5, {})
699
+ }
700
+ ),
701
+ !props.invisible && /* @__PURE__ */ jsxs(Fragment, { children: [
702
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
703
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00B49E", offset: "0%", stopOpacity: 0.5 }),
704
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00B49E", offset: "100%", stopOpacity: 0 })
705
+ ] }) }),
706
+ /* @__PURE__ */ jsx(
707
+ Area,
708
+ {
709
+ type: "natural",
710
+ dataKey: "account_value",
711
+ stroke: colors.profit,
712
+ strokeWidth: isMobile ? 1.5 : 2,
713
+ dot: false,
714
+ isAnimationActive: false,
715
+ fill: `url(#${colorId})`
716
+ }
717
+ )
718
+ ] })
719
+ ]
720
+ }
721
+ );
722
+ return /* @__PURE__ */ jsx(
723
+ ResponsiveContainer,
724
+ {
725
+ className: props.invisible ? "chart-invisible" : void 0,
726
+ ...responsiveContainerProps,
727
+ children: chartComponent
728
+ }
729
+ );
730
+ };
731
+ var RoundedRectangle2 = (props) => {
732
+ const { fill, x, y, width, height, opacity } = props;
733
+ const absHeight = Math.abs(height);
734
+ return /* @__PURE__ */ jsx(
735
+ "rect",
736
+ {
737
+ rx: 2,
738
+ x,
739
+ y: height > 0 ? y : y + height,
740
+ width,
741
+ height: absHeight,
742
+ stroke: "none",
743
+ fill,
744
+ opacity
745
+ }
746
+ );
747
+ };
748
+ var CustomizedCross2 = (props) => {
749
+ const { width, height, payload, stroke, fill } = props;
750
+ if (payload?.[0]?.value === 0) {
751
+ return null;
752
+ }
753
+ return (
754
+ // @ts-ignore
755
+ /* @__PURE__ */ jsx(
756
+ Cross,
757
+ {
758
+ x: props.x + props.width / 2,
759
+ top: props.top,
760
+ height,
761
+ width: 1,
762
+ stroke: "rgba(255,255,255,0.16)",
763
+ strokeDasharray: "3 2",
764
+ fill: "none"
765
+ }
766
+ )
767
+ );
768
+ };
769
+ var CustomTooltip6 = (props) => {
770
+ const { active, payload, label, tooltip } = props;
771
+ if (payload?.[0]?.value === 0) {
772
+ return null;
773
+ }
774
+ if (active && payload && payload.length) {
775
+ return /* @__PURE__ */ jsx(
776
+ OrderlyChartTooltip,
777
+ {
778
+ label,
779
+ value: payload[0].value,
780
+ titleClassName: "oui-gap-4",
781
+ rm: tooltip?.rm,
782
+ dp: tooltip?.dp
783
+ }
784
+ );
785
+ }
786
+ return null;
787
+ };
788
+ var VolBarChart = (props) => {
789
+ const colors = useColors(
790
+ props.colors?.fill ? { profit: props.colors?.fill, loss: props.colors?.fill } : void 0
791
+ );
792
+ const isEmpty = props.data?.reduce((pre, cur) => pre + cur.volume, 0) === 0;
793
+ const maxVolume = props.data?.reduce(
794
+ (pre, cur) => pre > cur.volume ? pre : cur.volume,
795
+ 0
796
+ );
797
+ const decimal = maxVolume <= 10 ? 2 : maxVolume <= 100 ? 1 : 0;
798
+ return (
799
+ // @ts-ignore
800
+ /* @__PURE__ */ jsx(Box, { className: cn(props.className), children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(
801
+ BarChart,
802
+ {
803
+ data: props.data,
804
+ margin: { left: -0, top: 6, right: 0, bottom: 20 },
805
+ children: [
806
+ /* @__PURE__ */ jsx(
807
+ Tooltip,
808
+ {
809
+ cursor: /* @__PURE__ */ jsx(CustomizedCross2, {}),
810
+ content: /* @__PURE__ */ jsx(CustomTooltip6, { tooltip: props.tooltip })
811
+ }
812
+ ),
813
+ /* @__PURE__ */ jsx(
814
+ CartesianGrid,
815
+ {
816
+ vertical: false,
817
+ stroke: "#FFFFFF",
818
+ strokeOpacity: 0.08,
819
+ repeatCount: 6
820
+ }
821
+ ),
822
+ /* @__PURE__ */ jsx(ReferenceLine, { y: 0, stroke: "#000" }),
823
+ /* @__PURE__ */ jsx(Bar, { dataKey: "volume", shape: /* @__PURE__ */ jsx(RoundedRectangle2, {}), minPointSize: 1, children: props.data.map((entry, index) => {
824
+ return (
825
+ // @ts-ignore
826
+ /* @__PURE__ */ jsx(
827
+ Cell,
828
+ {
829
+ fill: entry.volume > 0 ? colors.profit : colors.loss,
830
+ opacity: entry.opacity
831
+ },
832
+ `cell-${index}`
833
+ )
834
+ );
835
+ }) }),
836
+ /* @__PURE__ */ jsx(
837
+ YAxis,
838
+ {
839
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
840
+ tickLine: false,
841
+ axisLine: false,
842
+ dataKey: "volume",
843
+ tickFormatter: (value, index) => {
844
+ if (isEmpty) return `${index * 100}`;
845
+ return numberToHumanStyle2(value, decimal);
846
+ },
847
+ width: 45
848
+ }
849
+ ),
850
+ /* @__PURE__ */ jsx(
851
+ XAxis,
852
+ {
853
+ dataKey: "date",
854
+ tickLine: false,
855
+ interval: props.data.length - 2,
856
+ height: 1,
857
+ tick: { fontSize: 10, fill: "rgba(255,255,255,0.54)" },
858
+ stroke: "rgb(229, 231, 235)",
859
+ strokeOpacity: 0.2
860
+ }
861
+ )
862
+ ]
863
+ }
864
+ ) }) })
865
+ );
866
+ };
867
+ function numberToHumanStyle2(number, decimalPlaces = 0) {
868
+ const abbreviations = ["", "K", "M", "B", "T"];
869
+ let index = 0;
870
+ while (number >= 1e3 && index < abbreviations.length - 1) {
871
+ number /= 1e3;
872
+ index++;
873
+ }
874
+ const roundedNumber = toFixedWithoutRounding(number, decimalPlaces);
875
+ return `${roundedNumber}${abbreviations[index]}`;
876
+ }
877
+ function toFixedWithoutRounding(num, fix) {
878
+ const numStr = num.toString();
879
+ const decimalIndex = numStr.indexOf(".");
880
+ if (decimalIndex === -1 || fix === 0) {
881
+ return numStr.split(".")[0];
882
+ }
883
+ const cutoffIndex = decimalIndex + fix + 1;
884
+ return numStr.slice(0, cutoffIndex);
885
+ }
886
+
887
+ // src/tailwindcss/theme.ts
888
+ var import_plugin = __toESM(require_plugin());
889
+ var chartPlugin = () => (0, import_plugin.default)(function({ addComponents, addBase }) {
890
+ addComponents(
891
+ {
892
+ ".xAxis": {
893
+ ".recharts-cartesian-axis-tick:first-child text": {
894
+ "text-anchor": "start"
895
+ },
896
+ ".recharts-cartesian-axis-tick:last-child text": {
897
+ "text-anchor": "end"
898
+ }
899
+ }
900
+ },
901
+ {
902
+ respectPrefix: false
903
+ }
904
+ );
905
+ });
906
+
907
+ export { AssetAreaChart, AssetLineChart, PnLBarChart, PnlAreaChart, PnlLineChart, VolBarChart, chartPlugin };
908
+ //# sourceMappingURL=index.mjs.map
2
909
  //# sourceMappingURL=index.mjs.map