전략평가 화면 캔들 선택봉 이동시 위치고정
This commit is contained in:
@@ -531,27 +531,6 @@ const StrategyEvaluationChart: React.FC<Props> = ({
|
|||||||
emitEvalWindowMeta,
|
emitEvalWindowMeta,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const scrollToBar = useCallback((barIdx: number) => {
|
|
||||||
const mgr = managerRef.current;
|
|
||||||
if (!mgr?.hasMainSeries() || barIdx < 0 || barIdx >= bars.length) return;
|
|
||||||
const bar = bars[barIdx];
|
|
||||||
const barSec = timeframeBarSeconds(timeframe);
|
|
||||||
const pad = Math.max(barSec * 48, 3600);
|
|
||||||
mgr.applyVisibleTimeRange(bar.time - pad, bar.time + Math.max(barSec * 8, 600));
|
|
||||||
}, [bars, timeframe]);
|
|
||||||
|
|
||||||
const prevSelectedBarIndexRef = useRef(selectedBarIndex);
|
|
||||||
useEffect(() => {
|
|
||||||
prevSelectedBarIndexRef.current = -1;
|
|
||||||
}, [market, timeframe, strategy?.id, paramsRevision]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (bars.length === 0) return;
|
|
||||||
if (prevSelectedBarIndexRef.current === selectedBarIndex) return;
|
|
||||||
prevSelectedBarIndexRef.current = selectedBarIndex;
|
|
||||||
scrollToBar(selectedBarIndex);
|
|
||||||
}, [selectedBarIndex, bars.length, scrollToBar]);
|
|
||||||
|
|
||||||
const onManagerReady = useCallback((mgr: ChartManager) => {
|
const onManagerReady = useCallback((mgr: ChartManager) => {
|
||||||
managerRef.current = mgr;
|
managerRef.current = mgr;
|
||||||
setChartMgr(mgr);
|
setChartMgr(mgr);
|
||||||
|
|||||||
Reference in New Issue
Block a user