行情区:现价标签固定于右侧10根留白区,倒计时在现价下方
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2072,10 +2072,35 @@ body.login-page {
|
||||
line-height: 1.25;
|
||||
text-align: center;
|
||||
transform: translate(-50%, -50%);
|
||||
min-width: 68px;
|
||||
min-width: 72px;
|
||||
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.market-price-tag-head {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.market-price-tag-label {
|
||||
font-size: 0.62rem;
|
||||
font-weight: 500;
|
||||
opacity: 0.9;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.market-price-tag.is-up .market-price-tag-label {
|
||||
color: rgba(10, 16, 24, 0.75);
|
||||
}
|
||||
|
||||
.market-price-tag.is-down .market-price-tag-label {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
.market-price-tag.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -183,8 +183,8 @@
|
||||
color: up ? "#00ff9d" : "#ff4d6d",
|
||||
lineWidth: 1,
|
||||
lineStyle: 2,
|
||||
axisLabelVisible: true,
|
||||
title: "现价",
|
||||
axisLabelVisible: false,
|
||||
title: "",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,33 +222,24 @@
|
||||
return 6;
|
||||
}
|
||||
|
||||
function priceTagX() {
|
||||
if (!chart || !lastCandles.length) return null;
|
||||
const bar = latestCandle();
|
||||
if (!bar) return null;
|
||||
function plotAreaWidth() {
|
||||
if (!chart) return chartHost.clientWidth || 0;
|
||||
const ts = chart.timeScale();
|
||||
const spacing = getBarSpacing(ts);
|
||||
const hostW = chartHost.clientWidth || 0;
|
||||
let x = null;
|
||||
try {
|
||||
const lastIdx = lastCandles.length - 1;
|
||||
const lastX = ts.logicalToCoordinate(lastIdx);
|
||||
if (lastX != null && Number.isFinite(lastX)) {
|
||||
x = lastX + (RIGHT_OFFSET_BARS * spacing) / 2;
|
||||
if (typeof ts.width === "function") {
|
||||
const w = ts.width();
|
||||
if (Number.isFinite(w) && w > 0) return w;
|
||||
}
|
||||
} catch (e) {}
|
||||
if (x == null) {
|
||||
try {
|
||||
const tx = ts.timeToCoordinate(bar.time);
|
||||
if (tx != null && Number.isFinite(tx)) {
|
||||
x = tx + (RIGHT_OFFSET_BARS * spacing) / 2;
|
||||
return chartHost.clientWidth || 0;
|
||||
}
|
||||
} catch (e2) {}
|
||||
}
|
||||
if (x == null && hostW > 0 && spacing > 0) {
|
||||
x = hostW - (RIGHT_OFFSET_BARS * spacing) / 2;
|
||||
}
|
||||
return x;
|
||||
|
||||
/** 固定在右侧 10 根 K 线留白区中央,不随 K 线横向滚动 */
|
||||
function priceTagX() {
|
||||
const spacing = getBarSpacing(chart && chart.timeScale());
|
||||
const plotW = plotAreaWidth();
|
||||
if (plotW <= 0 || spacing <= 0) return null;
|
||||
return plotW - (RIGHT_OFFSET_BARS * spacing) / 2;
|
||||
}
|
||||
|
||||
function updatePriceTag() {
|
||||
@@ -280,6 +271,7 @@
|
||||
elPriceTag.classList.add(up ? "is-up" : "is-down");
|
||||
elPriceTag.setAttribute("aria-hidden", "false");
|
||||
elPriceTag.style.left = x + "px";
|
||||
elPriceTag.style.right = "auto";
|
||||
elPriceTag.style.top = y + "px";
|
||||
if (elPriceTagValue) elPriceTagValue.textContent = fmtPrice(bar.close);
|
||||
} catch (e) {
|
||||
|
||||
@@ -117,7 +117,10 @@
|
||||
<div id="market-exchange-badge" class="market-exchange-badge" aria-hidden="true"></div>
|
||||
<div id="market-chart" class="market-chart-host"></div>
|
||||
<div id="market-price-tag" class="market-price-tag hidden" aria-hidden="true">
|
||||
<div id="market-price-tag-value" class="market-price-tag-value"></div>
|
||||
<div class="market-price-tag-head">
|
||||
<span class="market-price-tag-label">现价</span>
|
||||
<span id="market-price-tag-value" class="market-price-tag-value"></span>
|
||||
</div>
|
||||
<div id="market-price-tag-time" class="market-price-tag-time"></div>
|
||||
</div>
|
||||
<button type="button" id="market-price-auto" class="market-price-auto is-on" title="价格轴自动缩放">自动</button>
|
||||
@@ -190,7 +193,7 @@
|
||||
|
||||
<div id="toast"></div>
|
||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<script src="/assets/chart.js?v=20260528-hub-market10"></script>
|
||||
<script src="/assets/app.js?v=20260528-hub-market10"></script>
|
||||
<script src="/assets/chart.js?v=20260528-hub-market11"></script>
|
||||
<script src="/assets/app.js?v=20260528-hub-market11"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user