fix: show 4 decimal places for prices under 00 (XRP/SOL)
This commit is contained in:
parent
2c28d660ce
commit
fb37dfb288
@ -32,6 +32,12 @@ interface SummaryBar {
|
|||||||
type Symbol = "BTC" | "ETH" | "XRP" | "SOL";
|
type Symbol = "BTC" | "ETH" | "XRP" | "SOL";
|
||||||
type Interval = "1m" | "5m" | "15m" | "1h";
|
type Interval = "1m" | "5m" | "15m" | "1h";
|
||||||
|
|
||||||
|
// 价格格式化:<100显示4位小数,>=100显示1位
|
||||||
|
function fmtPrice(p: number): string {
|
||||||
|
const digits = p < 100 ? 4 : 1;
|
||||||
|
return p.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits });
|
||||||
|
}
|
||||||
|
|
||||||
const INTERVALS: { label: string; value: Interval }[] = [
|
const INTERVALS: { label: string; value: Interval }[] = [
|
||||||
{ label: "1m", value: "1m" },
|
{ label: "1m", value: "1m" },
|
||||||
{ label: "5m", value: "5m" },
|
{ label: "5m", value: "5m" },
|
||||||
@ -117,7 +123,7 @@ function LiveTrades({ symbol }: { symbol: Symbol }) {
|
|||||||
{trades.map(t => (
|
{trades.map(t => (
|
||||||
<tr key={t.agg_id} className="border-b border-slate-50 hover:bg-slate-50">
|
<tr key={t.agg_id} className="border-b border-slate-50 hover:bg-slate-50">
|
||||||
<td className={`px-3 py-1.5 font-mono font-semibold ${t.is_buyer_maker === 0 ? "text-emerald-600" : "text-red-500"}`}>
|
<td className={`px-3 py-1.5 font-mono font-semibold ${t.is_buyer_maker === 0 ? "text-emerald-600" : "text-red-500"}`}>
|
||||||
{t.is_buyer_maker === 0 ? "▲" : "▼"} {t.price.toLocaleString("en-US", { minimumFractionDigits: 1, maximumFractionDigits: 1 })}
|
{t.is_buyer_maker === 0 ? "▲" : "▼"} {fmtPrice(t.price)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-1.5 text-right font-mono text-slate-600">
|
<td className="px-3 py-1.5 text-right font-mono text-slate-600">
|
||||||
{t.qty >= 1000 ? `${(t.qty/1000).toFixed(2)}K` : t.qty.toFixed(symbol === "BTC" ? 4 : 3)}
|
{t.qty >= 1000 ? `${(t.qty/1000).toFixed(2)}K` : t.qty.toFixed(symbol === "BTC" ? 4 : 3)}
|
||||||
@ -273,12 +279,12 @@ function FlowAnalysis({ symbol }: { symbol: Symbol }) {
|
|||||||
{/* 右轴:价格,自适应波动范围 */}
|
{/* 右轴:价格,自适应波动范围 */}
|
||||||
<YAxis yAxisId="price" orientation="right" tick={{ fill: "#f59e0b", fontSize: 10 }} tickLine={false} axisLine={false} width={65}
|
<YAxis yAxisId="price" orientation="right" tick={{ fill: "#f59e0b", fontSize: 10 }} tickLine={false} axisLine={false} width={65}
|
||||||
domain={[priceYMin, priceYMax]}
|
domain={[priceYMin, priceYMax]}
|
||||||
tickFormatter={(v: number) => v >= 1000 ? `$${(v/1000).toFixed(1)}k` : `$${v.toFixed(0)}`}
|
tickFormatter={(v: number) => v >= 1000 ? `$${(v/1000).toFixed(1)}k` : `$${fmtPrice(v)}`}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
formatter={(v: any, name: any) => {
|
formatter={(v: any, name: any) => {
|
||||||
if (name === "price") return [`$${Number(v).toLocaleString("en-US", { minimumFractionDigits: 1, maximumFractionDigits: 1 })}`, "币价(VWAP)"];
|
if (name === "price") return [`$${fmtPrice(Number(v))}`, "币价(VWAP)"];
|
||||||
return [`${Number(v).toFixed(2)}`, "Delta"];
|
return [`${Number(v).toFixed(2)}`, "Delta"];
|
||||||
}}
|
}}
|
||||||
contentStyle={{ background: "#fff", border: "1px solid #e2e8f0", borderRadius: 8, fontSize: 11 }}
|
contentStyle={{ background: "#fff", border: "1px solid #e2e8f0", borderRadius: 8, fontSize: 11 }}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user