feat: add trading day split lines on hub market chart
Add toggle before technical indicators to show blue dashed vertical lines at Beijing 8:00 day boundaries. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -193,6 +193,8 @@
|
||||
const elIndEma = document.getElementById("market-ind-ema");
|
||||
const elIndMacd = document.getElementById("market-ind-macd");
|
||||
const elIndRsi = document.getElementById("market-ind-rsi");
|
||||
const elDaySplit = document.getElementById("market-day-split");
|
||||
const DAY_SPLIT_STORAGE_KEY = "hub-market-day-split";
|
||||
const elFsToolbar = document.getElementById("market-fs-toolbar");
|
||||
const elFsExchange = document.getElementById("market-fs-exchange");
|
||||
const elFsSymbol = document.getElementById("market-fs-symbol");
|
||||
@@ -308,6 +310,33 @@
|
||||
syncChartWrapLayout();
|
||||
}
|
||||
|
||||
function loadDaySplitPref() {
|
||||
try {
|
||||
const raw = localStorage.getItem(DAY_SPLIT_STORAGE_KEY);
|
||||
if (raw === "1" || raw === "true") return true;
|
||||
if (raw === "0" || raw === "false") return false;
|
||||
} catch (_) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveDaySplitPref(on) {
|
||||
try {
|
||||
localStorage.setItem(DAY_SPLIT_STORAGE_KEY, on ? "1" : "0");
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function applyTradingDaySplit(enabled) {
|
||||
if (window.HubChartDraw && typeof window.HubChartDraw.setTradingDaySplit === "function") {
|
||||
window.HubChartDraw.setTradingDaySplit(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
function syncTradingDaySplitUi() {
|
||||
const on = !!(elDaySplit && elDaySplit.checked);
|
||||
saveDaySplitPref(on);
|
||||
applyTradingDaySplit(on);
|
||||
}
|
||||
|
||||
function ensureDrawLayer() {
|
||||
if (drawAttached || !window.HubChartDraw || !chart || !candleSeries) return;
|
||||
window.HubChartDraw.attach({
|
||||
@@ -322,6 +351,7 @@
|
||||
},
|
||||
});
|
||||
window.HubChartDraw.setViewKey(currentChartViewKey());
|
||||
applyTradingDaySplit(elDaySplit ? elDaySplit.checked : loadDaySplitPref());
|
||||
drawAttached = true;
|
||||
}
|
||||
|
||||
@@ -3006,6 +3036,11 @@
|
||||
updateIndicators();
|
||||
});
|
||||
});
|
||||
if (elDaySplit) {
|
||||
elDaySplit.checked = loadDaySplitPref();
|
||||
elDaySplit.addEventListener("change", syncTradingDaySplitUi);
|
||||
applyTradingDaySplit(elDaySplit.checked);
|
||||
}
|
||||
const pageMarket = document.getElementById("page-market");
|
||||
const fsKeyTargets = [window, pageMarket, elChartWrap, chartHost].filter(Boolean);
|
||||
fsKeyTargets.forEach(function (el) {
|
||||
|
||||
Reference in New Issue
Block a user