실시간 차트 갱신시 화면떨림 문제 해결
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
import { normalizeIchimokuConfig } from './ichimokuConfig';
|
||||
import type { IchimokuCloudColors } from './ichimokuConfig';
|
||||
import { isMainIndicatorType } from './indicatorMainTab';
|
||||
import { indicatorDefaultsFingerprint } from './indicatorDefaultsFingerprint';
|
||||
|
||||
export type MainIndicatorDraftMap = Record<string, IndicatorConfig>;
|
||||
|
||||
@@ -93,6 +94,42 @@ function finalizeMainIndicatorConfig(cfg: IndicatorConfig, isNew: boolean): Indi
|
||||
return out;
|
||||
}
|
||||
|
||||
/** DB에 저장된 전역 기본값 → 차트 인스턴스에 반영 (id·hidden·pane 병합 상태 유지) */
|
||||
export function mergeGlobalDefaultsOntoChartIndicators(
|
||||
activeIndicators: IndicatorConfig[],
|
||||
getParams: (type: string, defaults: Record<string, number | string | boolean>) => Record<string, number | string | boolean>,
|
||||
getVisualConfig: (
|
||||
type: string,
|
||||
defaultPlots?: PlotDef[],
|
||||
defaultHlines?: HLineDef[],
|
||||
) => { plots: PlotDef[]; hlines: HLineDef[]; cloudColors?: IchimokuCloudColors },
|
||||
): IndicatorConfig[] {
|
||||
return activeIndicators.map(ind => {
|
||||
const cfg = buildMainIndicatorConfig(ind.type, [ind], getParams, getVisualConfig);
|
||||
if (!cfg) return enrichIndicatorConfig(ind);
|
||||
return finalizeMainIndicatorConfig(
|
||||
{
|
||||
...cfg,
|
||||
id: ind.id,
|
||||
hidden: ind.hidden,
|
||||
mergedWith: ind.mergedWith,
|
||||
},
|
||||
false,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/** 전역 기본값 병합 후 실제 렌더 설정이 바뀌었는지 */
|
||||
export function chartIndicatorsNeedDefaultsRefresh(
|
||||
before: IndicatorConfig[],
|
||||
after: IndicatorConfig[],
|
||||
): boolean {
|
||||
if (before.length !== after.length) return true;
|
||||
return before.some((ind, i) =>
|
||||
indicatorDefaultsFingerprint(ind) !== indicatorDefaultsFingerprint(after[i]),
|
||||
);
|
||||
}
|
||||
|
||||
/** Main 탭 설정 → 현재 차트에 올라간 동일 type 인스턴스에 반영 (id·hidden 유지) */
|
||||
export function mergeMainDraftOntoChart(
|
||||
activeIndicators: IndicatorConfig[],
|
||||
|
||||
Reference in New Issue
Block a user