fix: UTC+8 market chart times and archive full history K-line load
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -605,7 +605,10 @@
|
||||
chart.timeScale().setVisibleLogicalRange({ from: candles.length - 120, to: candles.length + 5 });
|
||||
}
|
||||
const markHint = markAuto && trades.length > 1 ? " · 自动标注 " + trades.length + " 笔" : tr ? " · 已标注开/平" : "";
|
||||
const histHint = openMs && closeMs ? " · 可拖动/滚轮缩放查看建仓前走势" : "";
|
||||
const histHint =
|
||||
openMs && closeMs
|
||||
? " · 建档30天历史 · 可拖动/滚轮缩放查看建仓前走势"
|
||||
: "";
|
||||
setStatus("K 线 " + candles.length + " 根 · " + timeframe + markHint + histHint);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,69 @@
|
||||
"1w": "周线",
|
||||
};
|
||||
const TF_DIGIT_TIMEOUT_MS = 650;
|
||||
const CHART_TZ_OFFSET_SEC = 8 * 60 * 60;
|
||||
|
||||
function pad2(n) {
|
||||
return n < 10 ? "0" + n : String(n);
|
||||
}
|
||||
|
||||
function utcSecToBjDate(utcSec) {
|
||||
return new Date((Number(utcSec) + CHART_TZ_OFFSET_SEC) * 1000);
|
||||
}
|
||||
|
||||
function formatChartTimeBj(utcSec, withDate) {
|
||||
const d = utcSecToBjDate(utcSec);
|
||||
const h = pad2(d.getUTCHours());
|
||||
const mi = pad2(d.getUTCMinutes());
|
||||
if (!withDate) return h + ":" + mi;
|
||||
return (
|
||||
d.getUTCFullYear() +
|
||||
"-" +
|
||||
pad2(d.getUTCMonth() + 1) +
|
||||
"-" +
|
||||
pad2(d.getUTCDate()) +
|
||||
" " +
|
||||
h +
|
||||
":" +
|
||||
mi
|
||||
);
|
||||
}
|
||||
|
||||
function chartLocalizationBj() {
|
||||
return {
|
||||
locale: "zh-CN",
|
||||
dateFormat: "yyyy-MM-dd",
|
||||
timeFormatter: function (time) {
|
||||
if (typeof time === "number") return formatChartTimeBj(time, true);
|
||||
if (time && typeof time === "object" && time.year) {
|
||||
return time.year + "-" + pad2(time.month) + "-" + pad2(time.day);
|
||||
}
|
||||
return "";
|
||||
},
|
||||
tickMarkFormatter: function (time, tickMarkType) {
|
||||
if (typeof time !== "number") {
|
||||
if (time && typeof time === "object" && time.year) {
|
||||
return time.year + "-" + pad2(time.month) + "-" + pad2(time.day);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const d = utcSecToBjDate(time);
|
||||
if (tickMarkType === 0) return String(d.getUTCFullYear());
|
||||
if (tickMarkType === 1) return pad2(d.getUTCMonth() + 1);
|
||||
if (tickMarkType === 2) return pad2(d.getUTCDate());
|
||||
return formatChartTimeBj(time, false);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildChartLocalization() {
|
||||
const loc = chartLocalizationBj();
|
||||
loc.priceFormatter = function (p) {
|
||||
return fmtPrice(p);
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
|
||||
const chartHost = document.getElementById("market-chart");
|
||||
if (!chartHost) return;
|
||||
|
||||
@@ -1649,11 +1712,7 @@
|
||||
applyPriceFormatToSeries(indSeries.ema55, pf);
|
||||
if (chart) {
|
||||
chart.applyOptions({
|
||||
localization: {
|
||||
priceFormatter: function (p) {
|
||||
return fmtPrice(p);
|
||||
},
|
||||
},
|
||||
localization: buildChartLocalization(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1933,6 +1992,7 @@
|
||||
horzLines: { visible: false },
|
||||
},
|
||||
rightPriceScale: { borderColor: tp.border, autoScale: true },
|
||||
localization: buildChartLocalization(),
|
||||
timeScale: {
|
||||
borderColor: tp.border,
|
||||
timeVisible: true,
|
||||
|
||||
@@ -417,8 +417,8 @@
|
||||
<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_draw.js?v=20260608-market-vol-rank"></script>
|
||||
<script src="/assets/chart.js?v=20260608-market-vol-rank-v5"></script>
|
||||
<script src="/assets/archive.js?v=20260608-hub-archive-tz8"></script>
|
||||
<script src="/assets/chart.js?v=20260608-market-tz8"></script>
|
||||
<script src="/assets/archive.js?v=20260608-hub-archive-history"></script>
|
||||
<script src="/assets/ai_review_render.js?v=2"></script>
|
||||
<script src="/assets/app.js?v=20260607-hub-archive-v1"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user