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