增加K线

This commit is contained in:
dekun
2026-05-30 11:08:12 +08:00
parent aa0103c634
commit 3053527504
+16 -2
View File
@@ -32,6 +32,8 @@ const COLORS = {
const MINI_SIZE = { w: 380, h: 100 };
/** 弹窗 K 线区域固定尺寸(带鱼屏居中大图) */
const MODAL_CHART_SIZE = { w: 1920, h: 1080 };
/** 自动模式下右侧留空的 K 线根数 */
const CHART_RIGHT_OFFSET_BARS = 10;
const DEFAULT_MINI_INTERVAL = "1d";
let chartModalSymbol = "";
@@ -198,10 +200,21 @@ function updateOhlcFromTime(time, modeLabel) {
if (candle) renderOhlcPanel(candle, modeLabel);
}
function applyChartRightOffset() {
if (!lwcChart) return;
lwcChart.timeScale().applyOptions({ rightOffset: CHART_RIGHT_OFFSET_BARS });
}
function fitChartContent() {
if (!lwcChart) return;
applyChartRightOffset();
lwcChart.timeScale().fitContent();
}
function onChartAutoscale() {
if (!lwcChart) return;
lwcPinnedCandleTime = null;
lwcChart.timeScale().fitContent();
fitChartContent();
lwcChart.priceScale("right").applyOptions({ autoScale: true });
requestAnimationFrame(() => {
updateHighLowForVisibleWindow();
@@ -672,6 +685,7 @@ function ensureLwcChart(container) {
borderColor: COLORS.grid,
timeVisible: true,
secondsVisible: false,
rightOffset: CHART_RIGHT_OFFSET_BARS,
},
});
@@ -725,7 +739,7 @@ function renderLwcChart(candles, interval, priceMeta) {
const { ohlc, vol } = candlesToLwc(candles, interval);
lwcCandleSeries.setData(ohlc);
lwcVolumeSeries.setData(vol);
lwcChart.timeScale().fitContent();
fitChartContent();
requestAnimationFrame(() => {
updateHighLowForVisibleWindow();
showLatestOhlcPanel();