일목균형표 수정
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import type { Theme } from '../types';
|
||||
import type { HLineStyle } from '../utils/indicatorRegistry';
|
||||
|
||||
/** 캔들·거래량·보조지표 pane 사이 구분선 */
|
||||
export interface ChartPaneSeparatorOptions {
|
||||
visible: boolean;
|
||||
color: string;
|
||||
width: 1 | 2 | 3 | 4;
|
||||
lineStyle: HLineStyle;
|
||||
}
|
||||
|
||||
export const DEFAULT_CHART_PANE_SEPARATOR: ChartPaneSeparatorOptions = {
|
||||
visible: true,
|
||||
color: '#2a2e3a',
|
||||
width: 1,
|
||||
lineStyle: 'solid',
|
||||
};
|
||||
|
||||
const THEME_DEFAULT_COLORS: Record<Theme, string> = {
|
||||
dark: 'rgba(122, 162, 247, 0.15)',
|
||||
light: 'rgba(0, 0, 0, 0.08)',
|
||||
blue: 'rgba(94, 181, 255, 0.15)',
|
||||
};
|
||||
|
||||
export function themeDefaultPaneSeparatorColor(theme: Theme): string {
|
||||
return THEME_DEFAULT_COLORS[theme] ?? THEME_DEFAULT_COLORS.dark;
|
||||
}
|
||||
|
||||
export function resolveChartPaneSeparatorOptions(
|
||||
raw?: Partial<ChartPaneSeparatorOptions> | null,
|
||||
theme: Theme = 'dark',
|
||||
): ChartPaneSeparatorOptions {
|
||||
const base = { ...DEFAULT_CHART_PANE_SEPARATOR };
|
||||
if (!raw || typeof raw !== 'object') {
|
||||
return { ...base, color: themeDefaultPaneSeparatorColor(theme) };
|
||||
}
|
||||
if (typeof raw.visible === 'boolean') base.visible = raw.visible;
|
||||
if (typeof raw.color === 'string' && raw.color.trim()) base.color = raw.color.trim();
|
||||
else base.color = themeDefaultPaneSeparatorColor(theme);
|
||||
const w = Number(raw.width);
|
||||
if (w >= 1 && w <= 4) base.width = Math.round(w) as 1 | 2 | 3 | 4;
|
||||
if (raw.lineStyle === 'solid' || raw.lineStyle === 'dashed' || raw.lineStyle === 'dotted') {
|
||||
base.lineStyle = raw.lineStyle;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/** LWC pane 구분선 — 커스텀 오버레이 사용 시 투명 처리 */
|
||||
export function applyPaneSeparatorToChartOptions(opts: ChartPaneSeparatorOptions) {
|
||||
return {
|
||||
layout: {
|
||||
panes: {
|
||||
enableResize: false,
|
||||
separatorColor: 'transparent',
|
||||
separatorHoverColor: 'transparent',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
}
|
||||
Reference in New Issue
Block a user