修复行情区 K 线右侧 10 根留白被可见范围覆盖的问题
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -386,13 +386,22 @@
|
|||||||
return (exKey || "") + "|" + (sym || "") + "|" + (tf || "");
|
return (exKey || "") + "|" + (sym || "") + "|" + (tf || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyChartRightGap() {
|
||||||
|
if (!chart) return;
|
||||||
|
chart.timeScale().applyOptions({
|
||||||
|
rightOffset: RIGHT_OFFSET_BARS,
|
||||||
|
fixRightEdge: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function applyDefaultVisibleRange() {
|
function applyDefaultVisibleRange() {
|
||||||
if (!chart || !lastCandles.length) return;
|
if (!chart || !lastCandles.length) return;
|
||||||
const n = lastCandles.length;
|
const n = lastCandles.length;
|
||||||
const visible = Math.min(DEFAULT_VISIBLE_BARS, n);
|
const visible = Math.min(DEFAULT_VISIBLE_BARS, n);
|
||||||
const from = Math.max(0, n - visible);
|
const from = Math.max(0, n - visible);
|
||||||
const to = n - 1;
|
// to 延伸到最后一根 K 线之后,留出 RIGHT_OFFSET_BARS 根空白(K 线与价格轴间距)
|
||||||
chart.timeScale().applyOptions({ rightOffset: RIGHT_OFFSET_BARS });
|
const to = n - 1 + RIGHT_OFFSET_BARS;
|
||||||
|
applyChartRightGap();
|
||||||
chart.timeScale().setVisibleLogicalRange({ from: from, to: to });
|
chart.timeScale().setVisibleLogicalRange({ from: from, to: to });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,6 +544,7 @@
|
|||||||
indexCandles(lastCandles);
|
indexCandles(lastCandles);
|
||||||
candleSeries.setData(lastCandles);
|
candleSeries.setData(lastCandles);
|
||||||
volumeSeries.setData(buildVolumeData(lastCandles));
|
volumeSeries.setData(buildVolumeData(lastCandles));
|
||||||
|
applyChartRightGap();
|
||||||
if (resetView) {
|
if (resetView) {
|
||||||
lastViewKey = vKey;
|
lastViewKey = vKey;
|
||||||
applyDefaultVisibleRange();
|
applyDefaultVisibleRange();
|
||||||
|
|||||||
@@ -193,7 +193,7 @@
|
|||||||
|
|
||||||
<div id="toast"></div>
|
<div id="toast"></div>
|
||||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
<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-market12"></script>
|
<script src="/assets/chart.js?v=20260528-hub-market13"></script>
|
||||||
<script src="/assets/app.js?v=20260528-hub-market12"></script>
|
<script src="/assets/app.js?v=20260528-hub-market13"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user