From c66727f84d3b5fd3beea5d678bca38d26a1de15d Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 20:55:14 +0800 Subject: [PATCH 01/10] refactor(indicator): remove BOLL band fill feature Completely remove the BOLL band (upper-lower fill) rendering, including the GPU fill pipeline path and the Canvas2D fill fallback. Only the upper/middle/lower line tracks remain. - drop showBand config from BOLLSchedulerConfig and BOLLRenderState - remove band point-pool building in the renderer - sync tests for the removed fill behavior --- .../__tests__/registerBuiltins.test.ts | 1 - .../indicators/__tests__/scheduler.test.ts | 2 - .../src/engine/indicators/state/bollState.ts | 4 +- .../src/engine/indicators/workerProtocol.ts | 1 - .../src/engine/renderers/Indicator/boll.ts | 86 +++---------------- .../renderers/__tests__/boll.renderer.test.ts | 30 ------- 6 files changed, 15 insertions(+), 109 deletions(-) diff --git a/packages/core/src/engine/indicators/__tests__/registerBuiltins.test.ts b/packages/core/src/engine/indicators/__tests__/registerBuiltins.test.ts index c8d47681..40cf4054 100644 --- a/packages/core/src/engine/indicators/__tests__/registerBuiltins.test.ts +++ b/packages/core/src/engine/indicators/__tests__/registerBuiltins.test.ts @@ -349,7 +349,6 @@ describe('builtin indicator registration', () => { showUpper: false, showMiddle: false, showLower: false, - showBand: false, }) expect( getRegisteredIndicatorDefinition('EXPMA')?.mainPane?.toActiveConfig?.({}, false), diff --git a/packages/core/src/engine/indicators/__tests__/scheduler.test.ts b/packages/core/src/engine/indicators/__tests__/scheduler.test.ts index 1e6be18f..1dc1133a 100644 --- a/packages/core/src/engine/indicators/__tests__/scheduler.test.ts +++ b/packages/core/src/engine/indicators/__tests__/scheduler.test.ts @@ -507,7 +507,6 @@ describe('BOLL State in scheduler', () => { expect(state!.params.showUpper).toBe(true) expect(state!.params.showMiddle).toBe(true) expect(state!.params.showLower).toBe(true) - expect(state!.params.showBand).toBe(true) }) it('should update BOLL config via updateBOLLConfig', () => { @@ -755,7 +754,6 @@ describe('EMPTY_BOLL_STATE', () => { showUpper: true, showMiddle: true, showLower: true, - showBand: true, }, visibleMin: Infinity, visibleMax: -Infinity, diff --git a/packages/core/src/engine/indicators/state/bollState.ts b/packages/core/src/engine/indicators/state/bollState.ts index 5ffdb982..ea93b2ed 100644 --- a/packages/core/src/engine/indicators/state/bollState.ts +++ b/packages/core/src/engine/indicators/state/bollState.ts @@ -13,14 +13,13 @@ export interface BOLLRenderState extends BaseIndicatorState { timestamp: number /** 全量 BOLL 数组(稀疏:前 period-1 个为 undefined) */ series: BOLLPoint[] - /** 计算和渲染参数(渲染器从此读取 showUpper/showMiddle/showLower/showBand) */ + /** 计算和渲染参数(渲染器从此读取 showUpper/showMiddle/showLower) */ params: { period: number multiplier: number showUpper: boolean showMiddle: boolean showLower: boolean - showBand: boolean } /** 视口内所有 BOLL 线的最低价 */ visibleMin: number @@ -47,7 +46,6 @@ export const EMPTY_BOLL_STATE: BOLLRenderState = { showUpper: true, showMiddle: true, showLower: true, - showBand: true, }, visibleMin: Infinity, visibleMax: -Infinity, diff --git a/packages/core/src/engine/indicators/workerProtocol.ts b/packages/core/src/engine/indicators/workerProtocol.ts index 708622c1..2465762f 100644 --- a/packages/core/src/engine/indicators/workerProtocol.ts +++ b/packages/core/src/engine/indicators/workerProtocol.ts @@ -36,7 +36,6 @@ export interface BOLLSchedulerConfig { showUpper: boolean showMiddle: boolean showLower: boolean - showBand: boolean } export interface EXPMASchedulerConfig { diff --git a/packages/core/src/engine/renderers/Indicator/boll.ts b/packages/core/src/engine/renderers/Indicator/boll.ts index 5fc9bf1f..23237df7 100644 --- a/packages/core/src/engine/renderers/Indicator/boll.ts +++ b/packages/core/src/engine/renderers/Indicator/boll.ts @@ -20,8 +20,7 @@ import type { import type { BOLLSchedulerConfig, IndicatorScheduler } from '../../indicators/scheduler' import { BOLL_STATE_KEY, type BOLLRenderState } from '../../indicators/state/bollState' -import { getRgbaAlpha, toOpaqueRgba } from './shared/webglBand' -import { tryDrawFilledBandGpu, tryDrawLinesGpu } from '../linesViaRenderer' +import { tryDrawLinesGpu } from '../linesViaRenderer' type LinePoint = { x: number; y: number } @@ -34,8 +33,7 @@ interface PriceData { } /** - * BOLL GPU:先 band fill(半透明 composite)再三轨折线。 - * 仅 sceneRenderer;失败返回 false 走 2D。 + * BOLL GPU:三轨折线;仅 sceneRenderer,失败返回 false 走 2D。 */ function drawBOLLWithWebGL( context: RenderContext, @@ -43,12 +41,9 @@ function drawBOLLWithWebGL( showUpper: boolean showMiddle: boolean showLower: boolean - showBand: boolean upperPoints: LinePoint[] middlePoints: LinePoint[] lowerPoints: LinePoint[] - bandUpperPoints: LinePoint[] - bandLowerPoints: LinePoint[] }, ): boolean { const colors = resolveThemeColors( @@ -56,18 +51,6 @@ function drawBOLLWithWebGL( context.isAsiaMarket, context.colorPresetSettings, ) - // band:画完立即 composite(alpha),再画线(MSAA 会 clear FBO,band 已在 2D) - let bandOk = false - if (data.showBand && data.bandUpperPoints.length >= 2 && data.bandLowerPoints.length >= 2) { - bandOk = tryDrawFilledBandGpu( - context, - data.bandUpperPoints, - data.bandLowerPoints, - toOpaqueRgba(colors.boll.bandFill), - context.scrollLeft, - getRgbaAlpha(colors.boll.bandFill), - ) - } const lineStrips: Array<{ points: LinePoint[]; width: number; color: string }> = [] if (data.showUpper && data.upperPoints.length >= 2) { @@ -84,7 +67,7 @@ function drawBOLLWithWebGL( lineStrips.push({ points: data.lowerPoints, width: BOLL_LINE_WIDTH, color: colors.boll.lower }) } - if (lineStrips.length === 0) return bandOk + if (lineStrips.length === 0) return false return tryDrawLinesGpu(context, lineStrips, context.scrollLeft) } @@ -184,7 +167,7 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( toActiveConfig: (params, active) => active ? params - : { ...params, showUpper: false, showMiddle: false, showLower: false, showBand: false }, + : { ...params, showUpper: false, showMiddle: false, showLower: false }, computePriceRange: computeBOLLPriceRange, composeRenderState: composeBOLLRenderState, }, @@ -197,15 +180,14 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( }) }, }, - runtime: { - defaultConfig: { - period: 20, - multiplier: 2, - showUpper: true, - showMiddle: true, - showLower: true, - showBand: true, - }, + runtime: { + defaultConfig: { + period: 20, + multiplier: 2, + showUpper: true, + showMiddle: true, + showLower: true, + }, computeKey: 'calcBOLLData', compute: (data, c) => calcBOLLData(data, c.period, c.multiplier), }, @@ -222,8 +204,6 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { const _upperPool: LinePoint[] = [] const _middlePool: LinePoint[] = [] const _lowerPool: LinePoint[] = [] - const _bandUpperPool: LinePoint[] = [] - const _bandLowerPool: LinePoint[] = [] let _poolSize = 0 function _growPool(size: number) { @@ -232,8 +212,6 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { _upperPool[i] = { x: 0, y: 0 } _middlePool[i] = { x: 0, y: 0 } _lowerPool[i] = { x: 0, y: 0 } - _bandUpperPool[i] = { x: 0, y: 0 } - _bandLowerPool[i] = { x: 0, y: 0 } } _poolSize = size } @@ -275,7 +253,7 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { return } - const { period, showUpper, showMiddle, showLower, showBand } = state.params + const { period, showUpper, showMiddle, showLower } = state.params const bollData = state.series if (klineData.length < period) return @@ -295,13 +273,10 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { const upperPoints: LinePoint[] = new Array(pointCount) const middlePoints: LinePoint[] = new Array(pointCount) const lowerPoints: LinePoint[] = new Array(pointCount) - const bandUpperPoints: LinePoint[] = showBand ? new Array(pointCount) : [] - const bandLowerPoints: LinePoint[] = showBand ? new Array(pointCount) : [] let upperIdx = 0, middleIdx = 0, - lowerIdx = 0, - bandIdx = 0 + lowerIdx = 0 for (let i = drawStart; i < drawEnd; i++) { const boll = bollData[i] @@ -328,28 +303,12 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { p.x = centerX p.y = lowerY lowerPoints[lowerIdx++] = p - - if (showBand) { - p = _bandUpperPool[bandIdx] - p.x = centerX - p.y = upperY - bandUpperPoints[bandIdx] = p - p = _bandLowerPool[bandIdx] - p.x = centerX - p.y = lowerY - bandLowerPoints[bandIdx] = p - bandIdx++ - } } // 截断到实际长度 upperPoints.length = upperIdx middlePoints.length = middleIdx lowerPoints.length = lowerIdx - if (showBand) { - bandUpperPoints.length = bandIdx - bandLowerPoints.length = bandIdx - } // ====== 渲染 ====== if ( @@ -357,12 +316,9 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { showUpper, showMiddle, showLower, - showBand, upperPoints, middlePoints, lowerPoints, - bandUpperPoints, - bandLowerPoints, }) ) { return @@ -375,20 +331,6 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost { ctx.lineJoin = 'round' ctx.lineCap = 'round' - if (showBand && bandUpperPoints.length >= 2) { - const bandPath = new Path2D() - bandPath.moveTo(bandUpperPoints[0].x, bandUpperPoints[0].y) - for (let i = 1; i < bandUpperPoints.length; i++) { - bandPath.lineTo(bandUpperPoints[i].x, bandUpperPoints[i].y) - } - for (let i = bandLowerPoints.length - 1; i >= 0; i--) { - bandPath.lineTo(bandLowerPoints[i].x, bandLowerPoints[i].y) - } - bandPath.closePath() - ctx.fillStyle = colors.boll.bandFill - ctx.fill(bandPath) - } - const drawLine = (points: LinePoint[], color: string) => { if (points.length < 2) return ctx.beginPath() diff --git a/packages/core/src/engine/renderers/__tests__/boll.renderer.test.ts b/packages/core/src/engine/renderers/__tests__/boll.renderer.test.ts index 489d6bb4..a279fe0f 100644 --- a/packages/core/src/engine/renderers/__tests__/boll.renderer.test.ts +++ b/packages/core/src/engine/renderers/__tests__/boll.renderer.test.ts @@ -137,7 +137,6 @@ function createTestBOLLState(overrides: Partial = {}): BOLLRend showUpper: true, showMiddle: true, showLower: true, - showBand: true, }, visibleMin: 90, visibleMax: 120, @@ -216,34 +215,6 @@ describe('BOLL renderer draw', () => { expect(ctx.restore).toHaveBeenCalledTimes(1) }) - it('should draw band when showBand is true', () => { - const state = createTestBOLLState({ - params: { ...createTestBOLLState().params, showBand: true }, - }) - const mockHost = createMockPluginHost(state) - plugin = createBOLLRendererPlugin() as TestableBOLLRenderer - plugin.onInstall(mockHost) - - const context = createMockRenderContext(ctx) - plugin.draw(context) - - expect(ctx.fill).toHaveBeenCalled() - }) - - it('should not draw band when showBand is false', () => { - const state = createTestBOLLState({ - params: { ...createTestBOLLState().params, showBand: false }, - }) - const mockHost = createMockPluginHost(state) - plugin = createBOLLRendererPlugin() as TestableBOLLRenderer - plugin.onInstall(mockHost) - - const context = createMockRenderContext(ctx) - plugin.draw(context) - - expect(ctx.fill).not.toHaveBeenCalled() - }) - it('should draw upper line when showUpper is true', () => { const state = createTestBOLLState({ params: { ...createTestBOLLState().params, showUpper: true }, @@ -297,7 +268,6 @@ describe('BOLL renderer config', () => { showUpper: false, showMiddle: true, showLower: false, - showBand: false, }, }) const mockHost = createMockPluginHost(state) From 53714027d03a10e5b9cae8f90e20243a46b4475a Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:14:59 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix(ma):=20=E5=9B=BE=E4=BE=8B=E4=B8=8E?= =?UTF-8?q?=E7=BA=BF=E6=9D=A1=E7=BB=9F=E4=B8=80=E8=B5=B0=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=20MA=20=E9=85=8D=E8=89=B2=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getTitleInfo 此前硬编码 MA 周期颜色,与 draw 使用的主题 token 不一致, 导致左上角图例文本颜色与线条颜色不符。现为 GetTitleInfoFn 增加 colors 参数并贯穿两个调用点,getMATitleInfo 改用 colors.ma.maX;同时将明暗 主题 ma token 统一为高对比度配色(MA10 青色、MA20 深蓝),双主题对比 度均满足 WCAG 3:1。 --- .../src/engine/indicators/indicatorMetadata.ts | 2 ++ packages/core/src/engine/renderers/Indicator/ma.ts | 14 ++++++++------ .../Indicator/mainIndicatorLegendContext.ts | 4 +++- packages/core/src/engine/renderers/paneTitle.ts | 1 + packages/core/src/foundation/tokens/theme-dark.ts | 10 +++++----- packages/core/src/foundation/tokens/theme-light.ts | 10 +++++----- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/core/src/engine/indicators/indicatorMetadata.ts b/packages/core/src/engine/indicators/indicatorMetadata.ts index f16d944d..0f8968c7 100644 --- a/packages/core/src/engine/indicators/indicatorMetadata.ts +++ b/packages/core/src/engine/indicators/indicatorMetadata.ts @@ -7,6 +7,7 @@ import { KLineChartError } from '../../errors' import type { PluginHost, RendererPluginWithHost } from '../../foundation/plugin/index' +import type { ColorTokens } from '../../foundation/tokens/index' import type { KLineData } from '../../foundation/types/price' import type { IndicatorConfigSnapshot, IndicatorSeriesBundle } from './workerProtocol' @@ -158,6 +159,7 @@ export type GetTitleInfoFn = ( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ) => TitleInfo | null /** diff --git a/packages/core/src/engine/renderers/Indicator/ma.ts b/packages/core/src/engine/renderers/Indicator/ma.ts index 6e09b82b..9fd63997 100644 --- a/packages/core/src/engine/renderers/Indicator/ma.ts +++ b/packages/core/src/engine/renderers/Indicator/ma.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import { calcMAData, type MAFlags } from '../../indicators/calculators' @@ -115,6 +116,7 @@ function getMATitleInfo( _params: Record, pluginHost: PluginHost, _paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null @@ -125,11 +127,11 @@ function getMATitleInfo( if (!state || state.visibleMin > state.visibleMax) return null const maColors: Record = { - 5: '#f5a623', - 10: '#4ecdc4', - 20: '#45b7d1', - 30: '#96ceb4', - 60: '#dda0dd', + 5: colors.ma.ma5, + 10: colors.ma.ma10, + 20: colors.ma.ma20, + 30: colors.ma.ma30, + 60: colors.ma.ma60, } const values: TitleValueItem[] = [] @@ -141,7 +143,7 @@ function getMATitleInfo( values.push({ label: `MA${period}`, value, - color: maColors[period] ?? '#f5a623', + color: maColors[period] ?? colors.ma.ma5, }) } diff --git a/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts b/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts index e29b8893..e5526825 100644 --- a/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts +++ b/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts @@ -168,7 +168,7 @@ export function buildLegendTemplateContext( } } - const indicators = collectIndicatorRows(host, klineData, targetIndex) + const indicators = collectIndicatorRows(host, klineData, targetIndex, colors) const comparisons = collectComparisonRows(context, klineData, targetIndex, range, colors) return { @@ -194,6 +194,7 @@ function collectIndicatorRows( host: PluginHost | null, klineData: KLineData[], targetIndex: number, + colors: ReturnType, ): LegendIndicatorRow[] { if (!host || typeof host.getService !== 'function') return [] const scheduler = host.getService('indicatorScheduler') @@ -210,6 +211,7 @@ function collectIndicatorRows( params as Record, host, 'main', + colors, ) if (!titleInfo) continue rows.push({ diff --git a/packages/core/src/engine/renderers/paneTitle.ts b/packages/core/src/engine/renderers/paneTitle.ts index c12cc14f..5310c5ee 100644 --- a/packages/core/src/engine/renderers/paneTitle.ts +++ b/packages/core/src/engine/renderers/paneTitle.ts @@ -113,6 +113,7 @@ export function createPaneTitleRendererPlugin(options: PaneTitleOptions): Render castParams, pluginHost, currentOptions.paneId, + colors, ) } diff --git a/packages/core/src/foundation/tokens/theme-dark.ts b/packages/core/src/foundation/tokens/theme-dark.ts index f023fd11..dd7d3e44 100644 --- a/packages/core/src/foundation/tokens/theme-dark.ts +++ b/packages/core/src/foundation/tokens/theme-dark.ts @@ -129,11 +129,11 @@ export const darkTheme: Theme = { chart: '#3A4048', }, ma: { - ma5: 'rgba(255, 200, 50, 1)', - ma10: 'rgba(200, 150, 30, 1)', - ma20: 'rgba(90, 140, 255, 1)', - ma30: 'rgba(90, 190, 95, 1)', - ma60: 'rgba(170, 60, 195, 1)', + ma5: '#e8590c', + ma10: '#0891b2', + ma20: '#2563eb', + ma30: '#2f9e44', + ma60: '#ae3ec9', }, boll: { upper: 'rgba(200, 60, 60, 1)', diff --git a/packages/core/src/foundation/tokens/theme-light.ts b/packages/core/src/foundation/tokens/theme-light.ts index 50833a9e..98a07802 100644 --- a/packages/core/src/foundation/tokens/theme-light.ts +++ b/packages/core/src/foundation/tokens/theme-light.ts @@ -135,11 +135,11 @@ export const lightTheme: Theme = { chart: '#e5e5e5', }, ma: { - ma5: 'rgba(255, 193, 37, 1)', - ma10: 'rgba(190, 131, 12, 1)', - ma20: 'rgba(69, 112, 249, 1)', - ma30: 'rgba(76, 175, 80, 1)', - ma60: 'rgba(156, 39, 176, 1)', + ma5: '#e8590c', + ma10: '#0891b2', + ma20: '#2563eb', + ma30: '#2f9e44', + ma60: '#ae3ec9', }, boll: { upper: 'rgba(178, 34, 34, 1)', From 54f386a5f57b4d65bae13cec5b719dfa2b9fdade Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:03 +0800 Subject: [PATCH 03/10] =?UTF-8?q?refactor(indicator):=20=E5=9B=BE=E4=BE=8B?= =?UTF-8?q?/=E6=A0=87=E9=A2=98/=E5=9D=90=E6=A0=87=E8=BD=B4=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E7=BB=9F=E4=B8=80=E8=B5=B0=E4=B8=BB=E9=A2=98=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - createSingleLineTitleInfo 改用传入 colors,删除内置 light 主题解析 - 图例比较行 fallback 改用 palette.i2 - VOL 标题红绿改用 volumeUp/volumeDown,顺带修复亚太红涨绿跌 - 对比线删除 DEFAULT_COMPARISON_COLOR - yAxis 默认标签色改用 label token --- .../Indicator/mainIndicatorLegendContext.ts | 2 +- .../engine/renderers/Indicator/shared/titleInfo.ts | 7 ++++--- .../core/src/engine/renderers/comparisonLine.ts | 13 +++++++++---- packages/core/src/engine/renderers/paneTitle.ts | 5 ++++- packages/core/src/engine/renderers/yAxis.ts | 11 +++++++++-- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts b/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts index e5526825..4fa5656b 100644 --- a/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts +++ b/packages/core/src/engine/renderers/Indicator/mainIndicatorLegendContext.ts @@ -263,7 +263,7 @@ function collectComparisonRows( if (!currentItem || !Number.isFinite(currentItem.close)) continue const percent = ((currentItem.close - baseline.close) / baseline.close) * 100 - const color = comparisonColors?.get(spec.symbol) ?? '#f59e0b' + const color = comparisonColors?.get(spec.symbol) ?? colors.palette.i2 rows.push({ symbol: spec.symbol, percent, diff --git a/packages/core/src/engine/renderers/Indicator/shared/titleInfo.ts b/packages/core/src/engine/renderers/Indicator/shared/titleInfo.ts index ac3a8bef..d4488936 100644 --- a/packages/core/src/engine/renderers/Indicator/shared/titleInfo.ts +++ b/packages/core/src/engine/renderers/Indicator/shared/titleInfo.ts @@ -1,5 +1,5 @@ import type { PluginHost } from '../../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../../foundation/tokens/index' +import type { ColorTokens } from '../../../../foundation/tokens/index' import type { KLineData } from '../../../../foundation/types/price' import type { GetTitleInfoFn, TitleInfo } from '../../../indicators/indicatorMetadata' @@ -14,7 +14,7 @@ interface SingleLineTitleInfoConfig { name: string label?: string defaultPeriod?: number - getColor?: (colors: ReturnType) => string + getColor?: (colors: ColorTokens) => string color?: string getParams?: (stateParams: Record) => number[] } @@ -28,6 +28,7 @@ export function createSingleLineTitleInfo(config: SingleLineTitleInfoConfig): Ge _params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null => { if (index === null) return null @@ -38,7 +39,7 @@ export function createSingleLineTitleInfo(config: SingleLineTitleInfoConfig): Ge const val = state.series[index] if (val === undefined) return null - const resolvedColor = color ?? (getColor ? getColor(resolveThemeColors('light')) : 'inherit') + const resolvedColor = color ?? (getColor ? getColor(colors) : 'inherit') const resolvedParams = getParams ? getParams(state.params as Record) : defaultPeriod !== undefined diff --git a/packages/core/src/engine/renderers/comparisonLine.ts b/packages/core/src/engine/renderers/comparisonLine.ts index 1c550741..09d80153 100644 --- a/packages/core/src/engine/renderers/comparisonLine.ts +++ b/packages/core/src/engine/renderers/comparisonLine.ts @@ -1,10 +1,9 @@ import type { RendererPlugin, RenderContext } from '../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../foundation/plugin/index' +import { resolveThemeColors } from '../../foundation/tokens/index' import type { KLineData } from '../../foundation/types/price' import { symbolSpecIdentityKey } from '../data/symbolIdentity' -const DEFAULT_COMPARISON_COLOR = '#f59e0b' - export function createComparisonLineRenderer(): RendererPlugin { return { name: 'comparisonLine', @@ -33,6 +32,12 @@ export function createComparisonLineRenderer(): RendererPlugin { ctx.translate(-context.scrollLeft, 0) ctx.lineWidth = Math.max(1, 1.5 / context.dpr) + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) + for (let symbolIndex = 0; symbolIndex < comparisonSymbols.length; symbolIndex++) { const spec = comparisonSymbols[symbolIndex]! const identity = symbolSpecIdentityKey(spec) @@ -50,10 +55,10 @@ export function createComparisonLineRenderer(): RendererPlugin { else byDate.set(String(item.timestamp), item) } - const colors = context.comparisonColors + const comparisonColors = context.comparisonColors ctx.beginPath() - ctx.strokeStyle = colors?.get(identity) ?? DEFAULT_COMPARISON_COLOR + ctx.strokeStyle = comparisonColors?.get(identity) ?? colors.palette.i2 let hasPath = false let previousHadPoint = false diff --git a/packages/core/src/engine/renderers/paneTitle.ts b/packages/core/src/engine/renderers/paneTitle.ts index 5310c5ee..10a45ce9 100644 --- a/packages/core/src/engine/renderers/paneTitle.ts +++ b/packages/core/src/engine/renderers/paneTitle.ts @@ -5,6 +5,7 @@ import type { } from '../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../foundation/plugin/index' import { resolveThemeColors } from '../../foundation/tokens/index' +import type { ColorTokens } from '../../foundation/tokens/index' import type { KLineData } from '../../foundation/types/price' import type { TitleInfo } from '../indicators/indicatorMetadata' import type { IndicatorScheduler } from '../indicators/scheduler' @@ -23,11 +24,12 @@ function getVolumeTitleInfo( _params: Record, _host: PluginHost, _paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const kline = data[index] if (!kline || kline.volume === undefined) return null - const color = kline.open < kline.close ? '#ef4444' : '#22c55e' + const color = kline.open < kline.close ? colors.volumeUp : colors.volumeDown return { name: 'VOL', params: [], @@ -125,6 +127,7 @@ export function createPaneTitleRendererPlugin(options: PaneTitleOptions): Render castParams, pluginHost, currentOptions.paneId, + colors, ) } diff --git a/packages/core/src/engine/renderers/yAxis.ts b/packages/core/src/engine/renderers/yAxis.ts index a8c05a27..0acc25e2 100644 --- a/packages/core/src/engine/renderers/yAxis.ts +++ b/packages/core/src/engine/renderers/yAxis.ts @@ -104,6 +104,13 @@ export function createYAxisOverlayRendererPlugin(options: YAxisOptions): Rendere const targetCtx = yAxisOverlayCtx ?? yAxisCtx if (!targetCtx) return + // 标签默认底色/文字色统一取自 theme tokens,与静态层一致 + const tokenColors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) + const axisWidth = targetCtx.canvas ? targetCtx.canvas.width / dpr : options.axisWidth targetCtx.clearRect(0, 0, axisWidth, pane.height) @@ -126,9 +133,9 @@ export function createYAxisOverlayRendererPlugin(options: YAxisOptions): Rendere priceY: label.y + pane.top, price: label.price, dpr, - bgColor: label.style?.bgColor ?? 'rgba(0, 0, 0, 0.8)', + bgColor: label.style?.bgColor ?? tokenColors.label.bg, borderColor: label.style?.borderColor, - textColor: label.style?.textColor ?? '#ffffff', + textColor: label.style?.textColor ?? tokenColors.label.text, fontSize: isLastPrice ? 12 : 11, }, context.theme, From 33678d8b426f0870b84dc25dfbcfb809ad151cca Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:07 +0800 Subject: [PATCH 04/10] =?UTF-8?q?refactor(indicator):=20rsi/kst/stoch/macd?= =?UTF-8?q?/structure=20=E6=A0=87=E9=A2=98=E9=A2=9C=E8=89=B2=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉 getTitleInfo 内联 resolveThemeColors('light'),改读 colors.rsi/kst/kdj/macd/structure;rsi/kst 零线改用 wmsrGrid, rsi 离屏虚线缓存 key 纳入 color 参数 --- .../src/engine/renderers/Indicator/kst.ts | 5 ++-- .../src/engine/renderers/Indicator/macd.ts | 7 ++--- .../src/engine/renderers/Indicator/rsi.ts | 28 +++++++++++++++---- .../src/engine/renderers/Indicator/stoch.ts | 3 +- .../engine/renderers/Indicator/structure.ts | 3 +- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/kst.ts b/packages/core/src/engine/renderers/Indicator/kst.ts index 9467fdff..fe326212 100644 --- a/packages/core/src/engine/renderers/Indicator/kst.ts +++ b/packages/core/src/engine/renderers/Indicator/kst.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcKSTData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -140,7 +141,7 @@ function createKSTRendererPlugin(options: KSTRendererOptions = {}): RendererPlug const lineStartX = scrollLeft const lineEndX = scrollLeft + context.paneWidth - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.beginPath() ctx.moveTo(lineStartX, zeroY) @@ -273,6 +274,7 @@ function getKSTTitleInfo( params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): { name: string params: number[] @@ -284,7 +286,6 @@ function getKSTTitleInfo( const roc3 = (params.roc3 as number) ?? 20 const roc4 = (params.roc4 as number) ?? 30 const signalPeriod = (params.signalPeriod as number) ?? 9 - const colors = resolveThemeColors('light') const state = pluginHost.getSharedState(createKSTStateKey(paneId)) if (!state) return null diff --git a/packages/core/src/engine/renderers/Indicator/macd.ts b/packages/core/src/engine/renderers/Indicator/macd.ts index 037cb883..c143d383 100644 --- a/packages/core/src/engine/renderers/Indicator/macd.ts +++ b/packages/core/src/engine/renderers/Indicator/macd.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import type { MACDPoint } from '../../indicators/calculators' @@ -322,9 +323,7 @@ function createMACDRendererPlugin(options: MACDRendererOptions = {}): RendererPl if (config.showDEA && cachedDeaPoints.length >= 2) { lines.push({ points: cachedDeaPoints, width: 1, color: colors.macd.dea }) } - if ( - !tryDrawLinesGpu(context, lines, scrollLeft) - ) { + if (!tryDrawLinesGpu(context, lines, scrollLeft)) { drawMacdLinesWithCanvas2D( ctx, scrollLeft, @@ -473,6 +472,7 @@ function getMACDTitleInfo( params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): { name: string params: number[] @@ -482,7 +482,6 @@ function getMACDTitleInfo( const fastPeriod = (params.fastPeriod as number) ?? 12 const slowPeriod = (params.slowPeriod as number) ?? 26 const signalPeriod = (params.signalPeriod as number) ?? 9 - const colors = resolveThemeColors('light') const state = pluginHost.getSharedState(createMACDStateKey(paneId)) if (!state) return null diff --git a/packages/core/src/engine/renderers/Indicator/rsi.ts b/packages/core/src/engine/renderers/Indicator/rsi.ts index 99d6e71c..e87b2d43 100644 --- a/packages/core/src/engine/renderers/Indicator/rsi.ts +++ b/packages/core/src/engine/renderers/Indicator/rsi.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import { calcRSIData } from '../../indicators/calculators' @@ -94,8 +95,9 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug displayMin: number, displayMax: number, dpr: number, + color: string, ): string { - return `${paneWidth}|${paneHeight}|${displayMin.toFixed(4)}|${displayMax.toFixed(4)}|${dpr}` + return `${paneWidth}|${paneHeight}|${displayMin.toFixed(4)}|${displayMax.toFixed(4)}|${dpr}|${color}` } /** @@ -108,6 +110,7 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug displayMin: number, displayMax: number, dpr: number, + color: string, ): void { const displayValueRange = displayMax - displayMin || 1 @@ -129,7 +132,7 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug ctx.save() ctx.scale(dpr, dpr) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = color ctx.lineWidth = 1 ctx.setLineDash([4, 4]) @@ -221,7 +224,14 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug clearLineCache() return } - const dashedLinesKey = buildDashedLinesKey(paneWidth, paneHeight, displayMin, displayMax, dpr) + const dashedLinesKey = buildDashedLinesKey( + paneWidth, + paneHeight, + displayMin, + displayMax, + dpr, + colors.wmsrGrid, + ) if (cachedDashedLinesKey !== dashedLinesKey) { cachedDashedLinesKey = dashedLinesKey @@ -229,7 +239,15 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug Math.ceil(paneWidth * dpr), Math.ceil(paneHeight * dpr), ) - renderDashedLinesToOffscreen(offCtx, paneWidth, paneHeight, displayMin, displayMax, dpr) + renderDashedLinesToOffscreen( + offCtx, + paneWidth, + paneHeight, + displayMin, + displayMax, + dpr, + colors.wmsrGrid, + ) } // 绘制离屏缓存的虚线(只需 drawImage,无需 setLineDash) @@ -374,6 +392,7 @@ function getRSITitleInfo( params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): { name: string params: number[] @@ -383,7 +402,6 @@ function getRSITitleInfo( const period1 = (params.period1 as number) ?? 6 const period2 = (params.period2 as number) ?? 12 const period3 = (params.period3 as number) ?? 24 - const colors = resolveThemeColors('light') const stateKey = createRSIStateKey(paneId) const state = pluginHost.getSharedState(stateKey) diff --git a/packages/core/src/engine/renderers/Indicator/stoch.ts b/packages/core/src/engine/renderers/Indicator/stoch.ts index 796b94d8..0466d67d 100644 --- a/packages/core/src/engine/renderers/Indicator/stoch.ts +++ b/packages/core/src/engine/renderers/Indicator/stoch.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcSTOCHData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -258,6 +259,7 @@ function getSTOCHTitleInfo( params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): { name: string params: number[] @@ -266,7 +268,6 @@ function getSTOCHTitleInfo( if (index === null) return null const n = (params.n as number) ?? 9 const m = (params.m as number) ?? 3 - const colors = resolveThemeColors('light') const state = pluginHost.getSharedState(createSTOCHStateKey(paneId)) if (!state) return null diff --git a/packages/core/src/engine/renderers/Indicator/structure.ts b/packages/core/src/engine/renderers/Indicator/structure.ts index 495141f4..0ba8c86f 100644 --- a/packages/core/src/engine/renderers/Indicator/structure.ts +++ b/packages/core/src/engine/renderers/Indicator/structure.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcStructureData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -142,11 +143,11 @@ function getStructureTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const leftWindow = (params.leftWindow as number) ?? 5 const rightWindow = (params.rightWindow as number) ?? 2 - const colors = resolveThemeColors('light') const state = host.getSharedState(createStructureStateKey(paneId)) const values: Array<{ label: string; value: number; color: string }> = [] From f7b0b92e4e194031fbc9ce4295d864689f1c5e40 Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:12 +0800 Subject: [PATCH 05/10] =?UTF-8?q?refactor(indicator):=20boll/ene/expma/sar?= =?UTF-8?q?/supertrend/zones/volumeProfile=20=E9=A2=9C=E8=89=B2=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 标题硬编码 hex 改 colors.boll/ene/expma/candleUpBody/candleDownBody - zones FVG/OB 填充改 BullFill/BearFill - volumeProfile 填充/POC/VA 改 volumeProfileFill/Poc/ValueArea --- .../src/engine/renderers/Indicator/boll.ts | 29 +++++++++---------- .../src/engine/renderers/Indicator/ene.ts | 9 +++--- .../src/engine/renderers/Indicator/expma.ts | 7 +++-- .../src/engine/renderers/Indicator/sar.ts | 11 +++++-- .../engine/renderers/Indicator/supertrend.ts | 5 ++-- .../renderers/Indicator/volumeProfile.ts | 29 +++++++++---------- .../src/engine/renderers/Indicator/zones.ts | 13 +++++++-- 7 files changed, 59 insertions(+), 44 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/boll.ts b/packages/core/src/engine/renderers/Indicator/boll.ts index 23237df7..221416d2 100644 --- a/packages/core/src/engine/renderers/Indicator/boll.ts +++ b/packages/core/src/engine/renderers/Indicator/boll.ts @@ -4,7 +4,7 @@ import type { RenderContext, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import { calcBOLLData } from '../../indicators/calculators' @@ -135,6 +135,7 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( _params: Record, pluginHost: PluginHost, _paneId: string, + colors: ColorTokens, ): TitleInfo | null => { if (index === null) return null @@ -148,9 +149,9 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( if (!bollPoint) return null const values: TitleValueItem[] = [ - { label: 'UP', value: bollPoint.upper, color: '#C83C3C' }, - { label: 'MID', value: bollPoint.middle, color: '#5A8CFF' }, - { label: 'DN', value: bollPoint.lower, color: '#32AA3C' }, + { label: 'UP', value: bollPoint.upper, color: colors.boll.upper }, + { label: 'MID', value: bollPoint.middle, color: colors.boll.middle }, + { label: 'DN', value: bollPoint.lower, color: colors.boll.lower }, ] return { name: 'BOLL', params: [state.params.period, state.params.multiplier], values } @@ -165,9 +166,7 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( mainPane: { rendererName: 'boll', toActiveConfig: (params, active) => - active - ? params - : { ...params, showUpper: false, showMiddle: false, showLower: false }, + active ? params : { ...params, showUpper: false, showMiddle: false, showLower: false }, computePriceRange: computeBOLLPriceRange, composeRenderState: composeBOLLRenderState, }, @@ -180,14 +179,14 @@ const getBOLLTitleInfo: GetTitleInfoFn = ( }) }, }, - runtime: { - defaultConfig: { - period: 20, - multiplier: 2, - showUpper: true, - showMiddle: true, - showLower: true, - }, + runtime: { + defaultConfig: { + period: 20, + multiplier: 2, + showUpper: true, + showMiddle: true, + showLower: true, + }, computeKey: 'calcBOLLData', compute: (data, c) => calcBOLLData(data, c.period, c.multiplier), }, diff --git a/packages/core/src/engine/renderers/Indicator/ene.ts b/packages/core/src/engine/renderers/Indicator/ene.ts index 2a28890f..3ae3615a 100644 --- a/packages/core/src/engine/renderers/Indicator/ene.ts +++ b/packages/core/src/engine/renderers/Indicator/ene.ts @@ -4,7 +4,7 @@ import type { RenderContext, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import { calcENEData } from '../../indicators/calculators' @@ -287,6 +287,7 @@ const getENETitleInfo: GetTitleInfoFn = ( _params: Record, pluginHost: PluginHost, _paneId: string, + colors: ColorTokens, ): TitleInfo | null => { if (index === null) return null @@ -300,9 +301,9 @@ const getENETitleInfo: GetTitleInfoFn = ( if (!enePoint) return null const values: TitleValueItem[] = [ - { label: 'UP', value: enePoint.upper, color: '#FF5064' }, - { label: 'MID', value: enePoint.middle, color: '#5A8CFF' }, - { label: 'DN', value: enePoint.lower, color: '#3CC8A0' }, + { label: 'UP', value: enePoint.upper, color: colors.ene.upper }, + { label: 'MID', value: enePoint.middle, color: colors.ene.middle }, + { label: 'DN', value: enePoint.lower, color: colors.ene.lower }, ] return { name: 'ENE', params: [state.params.period, state.params.deviation], values } diff --git a/packages/core/src/engine/renderers/Indicator/expma.ts b/packages/core/src/engine/renderers/Indicator/expma.ts index 39d03f1e..b87ba1bf 100644 --- a/packages/core/src/engine/renderers/Indicator/expma.ts +++ b/packages/core/src/engine/renderers/Indicator/expma.ts @@ -4,7 +4,7 @@ import type { RenderContext, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { alignToPhysicalPixelCenter } from '../../../foundation/utils/pixelAlign' import { calcEXPMAData } from '../../indicators/calculators' @@ -229,6 +229,7 @@ const getEXPMATitleInfo: GetTitleInfoFn = ( _params: Record, pluginHost: PluginHost, _paneId: string, + colors: ColorTokens, ): TitleInfo | null => { if (index === null) return null @@ -242,8 +243,8 @@ const getEXPMATitleInfo: GetTitleInfoFn = ( if (!expmaPoint) return null const values: TitleValueItem[] = [ - { label: 'FAST', value: expmaPoint.fast, color: '#FFAA32' }, - { label: 'SLOW', value: expmaPoint.slow, color: '#5A8CFF' }, + { label: 'FAST', value: expmaPoint.fast, color: colors.expma.fast }, + { label: 'SLOW', value: expmaPoint.slow, color: colors.expma.slow }, ] return { name: 'EXPMA', params: [state.params.fastPeriod, state.params.slowPeriod], values } diff --git a/packages/core/src/engine/renderers/Indicator/sar.ts b/packages/core/src/engine/renderers/Indicator/sar.ts index dbc9e1c6..1a578a48 100644 --- a/packages/core/src/engine/renderers/Indicator/sar.ts +++ b/packages/core/src/engine/renderers/Indicator/sar.ts @@ -4,7 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcSARData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -117,6 +117,7 @@ function getSARTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const state = host.getSharedState(createSARStateKey(paneId)) @@ -126,7 +127,13 @@ function getSARTitleInfo( return { name: 'SAR', params: [(params.step as number) ?? 0.02, (params.maxStep as number) ?? 0.2], - values: [{ label: 'SAR', value: p.value, color: p.trend === 'up' ? '#22c55e' : '#ef4444' }], + values: [ + { + label: 'SAR', + value: p.value, + color: p.trend === 'up' ? colors.candleUpBody : colors.candleDownBody, + }, + ], } } diff --git a/packages/core/src/engine/renderers/Indicator/supertrend.ts b/packages/core/src/engine/renderers/Indicator/supertrend.ts index 4d0bcd8b..5b13a037 100644 --- a/packages/core/src/engine/renderers/Indicator/supertrend.ts +++ b/packages/core/src/engine/renderers/Indicator/supertrend.ts @@ -4,7 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcSuperTrendData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -130,6 +130,7 @@ function getSuperTrendTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const state = host.getSharedState(createSuperTrendStateKey(paneId)) @@ -143,7 +144,7 @@ function getSuperTrendTitleInfo( { label: p.trend === 'up' ? 'Up' : 'Down', value: p.value, - color: p.trend === 'up' ? '#22c55e' : '#ef4444', + color: p.trend === 'up' ? colors.candleUpBody : colors.candleDownBody, }, ], } diff --git a/packages/core/src/engine/renderers/Indicator/volumeProfile.ts b/packages/core/src/engine/renderers/Indicator/volumeProfile.ts index 0b4e8e44..4239606a 100644 --- a/packages/core/src/engine/renderers/Indicator/volumeProfile.ts +++ b/packages/core/src/engine/renderers/Indicator/volumeProfile.ts @@ -4,7 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcVolumeProfileData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -18,10 +18,6 @@ import { } from '../../indicators/state/volumeProfileState' import { createVolumeProfileVisibleStateComposer } from '../../indicators/visibleStateComposers' -const BAR_FILL = 'rgba(99, 102, 241, 0.35)' -const POC_COLOR = '#f59e0b' -const VA_COLOR = 'rgba(99, 102, 241, 0.6)' - const PROFILE_WIDTH_PX = 80 function getVolumeProfileStateKey(host: PluginHost | null, paneId: string): string | null { @@ -65,6 +61,12 @@ function createVolumeProfileRendererPlugin( }, draw(context: RenderContext) { const { ctx, pane, scrollLeft } = context + // 颜色统一取自 theme tokens,保证与标题栏一致并支持主题/预设切换 + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -85,7 +87,7 @@ function createVolumeProfileRendererPlugin( ctx.translate(-scrollLeft, 0) const profileX = scrollLeft + context.paneWidth - PROFILE_WIDTH_PX - ctx.fillStyle = BAR_FILL + ctx.fillStyle = colors.volumeProfileFill for (const bin of bins) { const yTop = toY(bin.priceHigh) const yBot = toY(bin.priceLow) @@ -94,7 +96,7 @@ function createVolumeProfileRendererPlugin( } if (showValueArea) { - ctx.strokeStyle = VA_COLOR + ctx.strokeStyle = colors.volumeProfileValueArea ctx.lineWidth = 1 ctx.setLineDash([4, 4]) const vahY = toY(vah) @@ -109,7 +111,7 @@ function createVolumeProfileRendererPlugin( } if (showPOC) { - ctx.strokeStyle = POC_COLOR + ctx.strokeStyle = colors.volumeProfilePoc ctx.lineWidth = 1 const pocY = toY(poc) ctx.beginPath() @@ -130,16 +132,13 @@ function createVolumeProfileRendererPlugin( } } -const VP_POC_COLOR = '#8b5cf6' -const VP_VAH_COLOR = '#6366f1' -const VP_VAL_COLOR = '#818cf8' - function getVolumeProfileTitleInfo( _data: KLineData[], index: number | null, params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const bins = (params.bins as number) ?? 24 @@ -149,11 +148,11 @@ function getVolumeProfileTitleInfo( const values: Array<{ label: string; value: number; color: string }> = [] if (vp && vp.bins.length > 0) { if (state.params.showPOC) { - values.push({ label: 'POC', value: vp.poc, color: VP_POC_COLOR }) + values.push({ label: 'POC', value: vp.poc, color: colors.volumeProfilePoc }) } if (state.params.showValueArea) { - values.push({ label: 'VAH', value: vp.vah, color: VP_VAH_COLOR }) - values.push({ label: 'VAL', value: vp.val, color: VP_VAL_COLOR }) + values.push({ label: 'VAH', value: vp.vah, color: colors.volumeProfileValueArea }) + values.push({ label: 'VAL', value: vp.val, color: colors.volumeProfileValueArea }) } } diff --git a/packages/core/src/engine/renderers/Indicator/zones.ts b/packages/core/src/engine/renderers/Indicator/zones.ts index 3aefb0f7..285ff1ac 100644 --- a/packages/core/src/engine/renderers/Indicator/zones.ts +++ b/packages/core/src/engine/renderers/Indicator/zones.ts @@ -4,7 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' -import { resolveThemeColors } from '../../../foundation/tokens/index' +import { resolveThemeColors, type ColorTokens } from '../../../foundation/tokens/index' import { calcZonesData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { @@ -112,7 +112,7 @@ function createZonesRendererPlugin(options: { paneId?: string } = {}): RendererP } } -const getZonesTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) => { +const getZonesTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId, colors) => { if (index === null) return null const stateKey = createZonesStateKey(paneId) @@ -127,7 +127,14 @@ const getZonesTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) const values: TitleValueItem[] = activeZones.slice(0, 5).map((z) => ({ label: z.kind, value: z.high, - color: z.kind.includes('Bull') ? '#22c55e' : '#ef4444', + color: + z.kind === 'FVG_BULL' + ? colors.zones.fvgBullFill + : z.kind === 'FVG_BEAR' + ? colors.zones.fvgBearFill + : z.kind === 'OB_BULL' + ? colors.zones.obBullFill + : colors.zones.obBearFill, })) return { From ee0b45302316db9fad5ffa3c4c1678856aa89f0a Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:19 +0800 Subject: [PATCH 06/10] =?UTF-8?q?refactor(indicator):=20=E5=8D=95=E7=BA=BF?= =?UTF-8?q?/=E5=A4=9A=E7=BA=BF=E6=8C=87=E6=A0=87=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=B5=B0=E4=B8=BB=E9=A2=98=20palette=20=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 31 个指标 draw 线色与标题色同源 palette.iN token - 零线/超买超卖带等辅助线改 wmsrGrid/cci.overbought/oversold - 红色系及无 palette 对应的 const 颜色有意保留 - 残留 const:gmma/pivot/fib/ichimoku 红棕、atr 深棕、dashedLines --- .../src/engine/renderers/Indicator/alma.ts | 15 ++++-- .../engine/renderers/Indicator/chaikinVol.ts | 17 ++++--- .../src/engine/renderers/Indicator/cmf.ts | 17 ++++--- .../src/engine/renderers/Indicator/dema.ts | 15 ++++-- .../src/engine/renderers/Indicator/dma.ts | 21 +++++--- .../engine/renderers/Indicator/donchian.ts | 32 ++++++------ .../src/engine/renderers/Indicator/fib.ts | 50 +++++++++++++------ .../src/engine/renderers/Indicator/gmma.ts | 49 ++++++++++++------ .../src/engine/renderers/Indicator/hma.ts | 15 ++++-- .../core/src/engine/renderers/Indicator/hv.ts | 14 ++++-- .../engine/renderers/Indicator/ichimoku.ts | 32 ++++++------ .../src/engine/renderers/Indicator/kama.ts | 15 ++++-- .../src/engine/renderers/Indicator/keltner.ts | 32 ++++++------ .../src/engine/renderers/Indicator/lsma.ts | 15 ++++-- .../src/engine/renderers/Indicator/mfi.ts | 21 +++++--- .../src/engine/renderers/Indicator/obv.ts | 15 ++++-- .../engine/renderers/Indicator/parkinson.ts | 14 ++++-- .../src/engine/renderers/Indicator/pivot.ts | 28 +++++++---- .../src/engine/renderers/Indicator/pvt.ts | 15 ++++-- .../src/engine/renderers/Indicator/roc.ts | 16 +++--- .../src/engine/renderers/Indicator/smma.ts | 15 ++++-- .../src/engine/renderers/Indicator/tema.ts | 15 ++++-- .../src/engine/renderers/Indicator/trima.ts | 15 ++++-- .../src/engine/renderers/Indicator/trix.ts | 26 ++++++---- .../src/engine/renderers/Indicator/vma.ts | 15 ++++-- .../src/engine/renderers/Indicator/vwap.ts | 15 ++++-- .../src/engine/renderers/Indicator/vwma.ts | 15 ++++-- .../src/engine/renderers/Indicator/wma.ts | 15 ++++-- .../src/engine/renderers/Indicator/zlema.ts | 15 ++++-- 29 files changed, 381 insertions(+), 213 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/alma.ts b/packages/core/src/engine/renderers/Indicator/alma.ts index 5a16c105..c9f601ac 100644 --- a/packages/core/src/engine/renderers/Indicator/alma.ts +++ b/packages/core/src/engine/renderers/Indicator/alma.ts @@ -8,6 +8,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcALMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -19,8 +20,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const ALMA_COLOR = '#22c55e' - type Point = { x: number; y: number } interface ALMARendererOptions { @@ -68,6 +67,11 @@ function createALMARendererPlugin(options: ALMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -89,11 +93,12 @@ function createALMARendererPlugin(options: ALMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: ALMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i3 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = ALMA_COLOR + ctx.strokeStyle = colors.palette.i3 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -123,7 +128,7 @@ const getALMATitleInfo = createSingleLineTitleInfo({ createStateKey: createALMAStateKey, name: 'ALMA', getParams: (p) => [p.period as number, p.offset as number, p.sigma as number], - color: ALMA_COLOR, + getColor: (colors) => colors.palette.i3, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/chaikinVol.ts b/packages/core/src/engine/renderers/Indicator/chaikinVol.ts index 258afe08..32cc50df 100644 --- a/packages/core/src/engine/renderers/Indicator/chaikinVol.ts +++ b/packages/core/src/engine/renderers/Indicator/chaikinVol.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcChaikinVolData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -18,8 +19,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const CHAIKIN_VOL_COLOR = '#f59e0b' - type LinePoint = { x: number; y: number } function getChaikinVolStateKey(host: PluginHost | null, paneId: string): string | null { @@ -62,6 +61,11 @@ function createChaikinVolRendererPlugin(options: { paneId?: string } = {}): Rend }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -80,7 +84,7 @@ function createChaikinVolRendererPlugin(options: { paneId?: string } = {}): Rend const zeroY = paneH - (0 - displayMin) * invRange ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() @@ -102,11 +106,12 @@ function createChaikinVolRendererPlugin(options: { paneId?: string } = {}): Rend if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: CHAIKIN_VOL_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i2 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = CHAIKIN_VOL_COLOR + ctx.strokeStyle = colors.palette.i2 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -132,7 +137,7 @@ const getChaikinVolTitleInfo = createSingleLineTitleInfo({ createStateKey: createChaikinVolStateKey, name: 'ChaikinVol', getParams: (p) => [(p.emaPeriod as number) ?? 10, (p.rocPeriod as number) ?? 10], - color: CHAIKIN_VOL_COLOR, + getColor: (colors) => colors.palette.i2, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/cmf.ts b/packages/core/src/engine/renderers/Indicator/cmf.ts index e5aaedbe..b74c5af1 100644 --- a/packages/core/src/engine/renderers/Indicator/cmf.ts +++ b/packages/core/src/engine/renderers/Indicator/cmf.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcCMFData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const CMF_COLOR = '#06b6d4' - type LinePoint = { x: number; y: number } function getCMFStateKey(host: PluginHost | null, paneId: string): string | null { @@ -56,6 +55,11 @@ function createCMFRendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -74,7 +78,7 @@ function createCMFRendererPlugin(options: { paneId?: string } = {}): RendererPlu const zeroY = paneH - (0 - displayMin) * invRange ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() @@ -96,11 +100,12 @@ function createCMFRendererPlugin(options: { paneId?: string } = {}): RendererPlu if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: CMF_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = CMF_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -126,7 +131,7 @@ const getCMFTitleInfo = createSingleLineTitleInfo({ createStateKey: createCMFStateKey, name: 'CMF', defaultPeriod: 20, - color: CMF_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/dema.ts b/packages/core/src/engine/renderers/Indicator/dema.ts index fb50bafb..2a436d0c 100644 --- a/packages/core/src/engine/renderers/Indicator/dema.ts +++ b/packages/core/src/engine/renderers/Indicator/dema.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcDEMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const DEMA_COLOR = '#6366f1' - type Point = { x: number; y: number } interface DEMARendererOptions { @@ -64,6 +63,11 @@ function createDEMARendererPlugin(options: DEMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createDEMARendererPlugin(options: DEMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: DEMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i9 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = DEMA_COLOR + ctx.strokeStyle = colors.palette.i9 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getDEMATitleInfo = createSingleLineTitleInfo({ createStateKey: createDEMAStateKey, name: 'DEMA', getParams: (p) => [p.period as number], - color: DEMA_COLOR, + getColor: (colors) => colors.palette.i9, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/dma.ts b/packages/core/src/engine/renderers/Indicator/dma.ts index 685ee151..22b9e905 100644 --- a/packages/core/src/engine/renderers/Indicator/dma.ts +++ b/packages/core/src/engine/renderers/Indicator/dma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcDMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey, type GetTitleInfoFn } from '../../indicators/indicatorMetadata' @@ -13,9 +14,6 @@ import { createDMAStateKey, EMPTY_DMA_STATE } from '../../indicators/state/dmaSt import { createValuePointVisibleStateComposer } from '../../indicators/visibleStateComposers' import { tryDrawLinesGpu } from '../linesViaRenderer' -const DMA_DIF_COLOR = '#3b82f6' -const DMA_AMA_COLOR = '#f59e0b' - type LinePoint = { x: number; y: number } interface DMARendererOptions { @@ -63,6 +61,11 @@ function createDMARendererPlugin(options: DMARendererOptions = {}): RendererPlug draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -99,8 +102,10 @@ function createDMARendererPlugin(options: DMARendererOptions = {}): RendererPlug } const lines: Array<{ points: LinePoint[]; width: number; color: string }> = [] - if (difPoints.length >= 2) lines.push({ points: difPoints, width: 1, color: DMA_DIF_COLOR }) - if (amaPoints.length >= 2) lines.push({ points: amaPoints, width: 1, color: DMA_AMA_COLOR }) + if (difPoints.length >= 2) + lines.push({ points: difPoints, width: 1, color: colors.palette.i9 }) + if (amaPoints.length >= 2) + lines.push({ points: amaPoints, width: 1, color: colors.palette.i2 }) if (lines.length === 0) return // GPU 批量画两条折线,失败回退 Canvas2D @@ -139,7 +144,7 @@ function createDMARendererPlugin(options: DMARendererOptions = {}): RendererPlug } } -const getDMATitleInfo: GetTitleInfoFn = (_data, index, _params, pluginHost, paneId) => { +const getDMATitleInfo: GetTitleInfoFn = (_data, index, _params, pluginHost, paneId, colors) => { if (index === null) return null const key = createDMAStateKey(paneId) const state = pluginHost.getSharedState(key) @@ -150,8 +155,8 @@ const getDMATitleInfo: GetTitleInfoFn = (_data, index, _params, pluginHost, pane name: 'DMA', params: [state.params.p1, state.params.p2, state.params.p3], values: [ - { label: 'DIF', value: p.dif, color: DMA_DIF_COLOR }, - { label: 'AMA', value: p.ama, color: DMA_AMA_COLOR }, + { label: 'DIF', value: p.dif, color: colors.palette.i9 }, + { label: 'AMA', value: p.ama, color: colors.palette.i2 }, ], } } diff --git a/packages/core/src/engine/renderers/Indicator/donchian.ts b/packages/core/src/engine/renderers/Indicator/donchian.ts index b93c6ae9..e5265b23 100644 --- a/packages/core/src/engine/renderers/Indicator/donchian.ts +++ b/packages/core/src/engine/renderers/Indicator/donchian.ts @@ -4,6 +4,8 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcDonchianData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -18,10 +20,6 @@ import { createDonchianStateKey, EMPTY_DONCHIAN_STATE } from '../../indicators/s import { createBandVisibleStateComposer } from '../../indicators/visibleStateComposers' import { tryDrawLinesGpu } from '../linesViaRenderer' -const DONCHIAN_UPPER_COLOR = '#0891b2' -const DONCHIAN_MIDDLE_COLOR = '#94a3b8' -const DONCHIAN_LOWER_COLOR = '#0891b2' - type Point = { x: number; y: number } interface DonchianRendererOptions { @@ -70,6 +68,11 @@ function createDonchianRendererPlugin( draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -96,12 +99,10 @@ function createDonchianRendererPlugin( } const lines: Array<{ points: Point[]; width: number; color: string }> = [] - if (upperPts.length >= 2) - lines.push({ points: upperPts, width: 1, color: DONCHIAN_UPPER_COLOR }) + if (upperPts.length >= 2) lines.push({ points: upperPts, width: 1, color: colors.palette.i6 }) if (middlePts.length >= 2) - lines.push({ points: middlePts, width: 1, color: DONCHIAN_MIDDLE_COLOR }) - if (lowerPts.length >= 2) - lines.push({ points: lowerPts, width: 1, color: DONCHIAN_LOWER_COLOR }) + lines.push({ points: middlePts, width: 1, color: colors.palette.i10 }) + if (lowerPts.length >= 2) lines.push({ points: lowerPts, width: 1, color: colors.palette.i6 }) if (tryDrawLinesGpu(context, lines, scrollLeft)) return @@ -110,9 +111,9 @@ function createDonchianRendererPlugin( ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' - drawLine(ctx, upperPts, DONCHIAN_UPPER_COLOR) - drawLine(ctx, middlePts, DONCHIAN_MIDDLE_COLOR) - drawLine(ctx, lowerPts, DONCHIAN_LOWER_COLOR) + drawLine(ctx, upperPts, colors.palette.i6) + drawLine(ctx, middlePts, colors.palette.i10) + drawLine(ctx, lowerPts, colors.palette.i6) ctx.restore() }, @@ -141,6 +142,7 @@ function getDonchianTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const state = host.getSharedState(createDonchianStateKey(paneId)) @@ -151,9 +153,9 @@ function getDonchianTitleInfo( name: 'Donchian', params: [(params.period as number) ?? 20], values: [ - { label: 'Upper', value: p.upper, color: '#0891b2' }, - { label: 'Mid', value: p.middle, color: '#94a3b8' }, - { label: 'Lower', value: p.lower, color: '#0891b2' }, + { label: 'Upper', value: p.upper, color: colors.palette.i6 }, + { label: 'Mid', value: p.middle, color: colors.palette.i10 }, + { label: 'Lower', value: p.lower, color: colors.palette.i6 }, ], } } diff --git a/packages/core/src/engine/renderers/Indicator/fib.ts b/packages/core/src/engine/renderers/Indicator/fib.ts index b97ea897..d1d32e29 100644 --- a/packages/core/src/engine/renderers/Indicator/fib.ts +++ b/packages/core/src/engine/renderers/Indicator/fib.ts @@ -4,6 +4,8 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import { calcFibData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { @@ -18,16 +20,25 @@ import { createFibStateKey, EMPTY_FIB_STATE } from '../../indicators/state/fibSt import { createExactRangePointVisibleStateComposer } from '../../indicators/visibleStateComposers' import { tryDrawLinesGpu } from '../linesViaRenderer' -const FIB_COLORS = { - high: '#94a3b8', - low: '#94a3b8', - l236: '#fbbf24', - l382: '#f59e0b', - l500: '#d97706', +// 斐波那契回撤线中 palette 无对应映射的颜色(红/深棕)保留 const +const FIB_FIXED_COLORS = { l618: '#dc2626', l786: '#7c2d12', } +/** 构建斐波那契回撤线颜色映射:palette 索引 + 固定 const,draw/title 共用同一来源 */ +function getFibColors(colors: ColorTokens) { + return { + high: colors.palette.i10, + low: colors.palette.i10, + l236: colors.palette.i2, + l382: colors.palette.i2, + l500: colors.palette.i2, + l618: FIB_FIXED_COLORS.l618, + l786: FIB_FIXED_COLORS.l786, + } +} + type Point = { x: number; y: number } function getFibStateKey(host: PluginHost | null, paneId: string): string | null { @@ -68,6 +79,11 @@ function createFibRendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -101,10 +117,15 @@ function createFibRendererPlugin(options: { paneId?: string } = {}): RendererPlu collectors.l786!.push({ x: centerX, y: toY(pt.level786) }) } + const fibColors = getFibColors(colors) const lines: Array<{ points: Point[]; width: number; color: string }> = [] for (const [key, pts] of Object.entries(collectors)) { if (pts.length >= 2) { - lines.push({ points: pts, width: 1, color: FIB_COLORS[key as keyof typeof FIB_COLORS] }) + lines.push({ + points: pts, + width: 1, + color: fibColors[key as keyof typeof fibColors], + }) } } @@ -114,7 +135,7 @@ function createFibRendererPlugin(options: { paneId?: string } = {}): RendererPlu ctx.translate(-scrollLeft, 0) ctx.lineWidth = 1 for (const [key, pts] of Object.entries(collectors)) { - drawLine(ctx, pts, FIB_COLORS[key as keyof typeof FIB_COLORS]) + drawLine(ctx, pts, fibColors[key as keyof typeof fibColors]) } ctx.restore() }, @@ -136,7 +157,7 @@ function drawLine(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v ctx.stroke() } -const getFibTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) => { +const getFibTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId, colors) => { if (index === null || index < 0) return null const stateKey = createFibStateKey(paneId) @@ -146,12 +167,13 @@ const getFibTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) => const p = state.series[index] if (!p) return null + const fibColors = getFibColors(colors) const values: TitleValueItem[] = [ - { label: '236', value: p.level236, color: FIB_COLORS.l236 }, - { label: '382', value: p.level382, color: FIB_COLORS.l382 }, - { label: '500', value: p.level500, color: FIB_COLORS.l500 }, - { label: '618', value: p.level618, color: FIB_COLORS.l618 }, - { label: '786', value: p.level786, color: FIB_COLORS.l786 }, + { label: '236', value: p.level236, color: fibColors.l236 }, + { label: '382', value: p.level382, color: fibColors.l382 }, + { label: '500', value: p.level500, color: fibColors.l500 }, + { label: '618', value: p.level618, color: fibColors.l618 }, + { label: '786', value: p.level786, color: fibColors.l786 }, ] return { diff --git a/packages/core/src/engine/renderers/Indicator/gmma.ts b/packages/core/src/engine/renderers/Indicator/gmma.ts index 3a75891b..c5ac5a50 100644 --- a/packages/core/src/engine/renderers/Indicator/gmma.ts +++ b/packages/core/src/engine/renderers/Indicator/gmma.ts @@ -4,6 +4,8 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcGMMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -21,22 +23,29 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' type LinePoint = { x: number; y: number } -/** 顾比均线 12 周期颜色映射(短组暖色、长组冷色) */ -const GMMA_COLORS: Record = { - 3: '#f59e0b', - 5: '#f97316', +// GMMA 12 个周期色超出 palette 的 10 个槽位:红系(8/10)与末 2 个周期(50/60)保留 const +const GMMA_FIXED_COLORS: Record = { 8: '#ef4444', 10: '#e11d48', - 12: '#ec4899', - 15: '#a855f7', - 30: '#06b6d4', - 35: '#0ea5e9', - 40: '#3b82f6', - 45: '#6366f1', 50: '#8b5cf6', 60: '#6366f1', } +/** 构建 GMMA 周期颜色映射:palette 索引(按色相)+ 固定 const,draw/title 共用同一来源 */ +function getGMMAColors(colors: ColorTokens): Record { + return { + 3: colors.palette.i2, + 5: colors.palette.i5, + 12: colors.palette.i4, + 15: colors.palette.i8, + 30: colors.palette.i6, + 35: colors.palette.i6, + 40: colors.palette.i9, + 45: colors.palette.i9, + ...GMMA_FIXED_COLORS, + } +} + /** * 构建 GMMA 绘制缓存键 * 视口、缩放、周期列表或时间戳任一变化都会触发重算折线点 @@ -82,7 +91,7 @@ function getGMMAStateKey(host: PluginHost | null, paneId: string): string | null /** * GMMA 标题信息:按启用周期取对应 EMA 值 - * 短组用 G{period} 标签、长组用 L{period} 标签,颜色沿用 GMMA_COLORS + * 短组用 G{period} 标签、长组用 L{period} 标签,颜色沿用 getGMMAColors 映射 */ function getGMMATitleInfo( _data: KLineData[], @@ -90,6 +99,7 @@ function getGMMATitleInfo( _params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null @@ -99,6 +109,7 @@ function getGMMATitleInfo( const state = pluginHost?.getSharedState(stateKey) if (!state || state.visibleMin > state.visibleMax) return null + const gmmaColors = getGMMAColors(colors) const values: TitleValueItem[] = [] for (const period of state.enabledPeriods) { const value = state.series[period]?.[index] @@ -108,7 +119,7 @@ function getGMMATitleInfo( values.push({ label: isShort ? `G${period}` : `L${period}`, value, - color: GMMA_COLORS[period] ?? '#f59e0b', + color: gmmaColors[period] ?? colors.palette.i2, }) } @@ -142,7 +153,9 @@ class GMMADefinition { } /** 创建 GMMA 多线渲染器插件(WebGL 优先,失败回退 Canvas2D) */ -export function createGMMARendererPlugin(options: { paneId?: string } = {}): RendererPluginWithHost { +export function createGMMARendererPlugin( + options: { paneId?: string } = {}, +): RendererPluginWithHost { const { paneId = 'main' } = options let pluginHost: PluginHost | null = null let cachedKey = '' @@ -176,6 +189,12 @@ export function createGMMARendererPlugin(options: { paneId?: string } = {}): Ren draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) + const gmmaColors = getGMMAColors(colors) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -225,7 +244,7 @@ export function createGMMARendererPlugin(options: { paneId?: string } = {}): Ren for (const period of state.enabledPeriods) { const points = cachedLines.get(period) if (!points) continue - lines.push({ points, width: 1, color: GMMA_COLORS[period] ?? '#f59e0b' }) + lines.push({ points, width: 1, color: gmmaColors[period] ?? colors.palette.i2 }) } // sceneRenderer → fail-closed 2D @@ -240,7 +259,7 @@ export function createGMMARendererPlugin(options: { paneId?: string } = {}): Ren for (const period of state.enabledPeriods) { const points = cachedLines.get(period) if (!points || points.length < 2) continue - ctx.strokeStyle = GMMA_COLORS[period] ?? '#f59e0b' + ctx.strokeStyle = gmmaColors[period] ?? colors.palette.i2 ctx.beginPath() ctx.moveTo(points[0]!.x, points[0]!.y) for (let i = 1; i < points.length; i++) { diff --git a/packages/core/src/engine/renderers/Indicator/hma.ts b/packages/core/src/engine/renderers/Indicator/hma.ts index 5526768f..fd52be4b 100644 --- a/packages/core/src/engine/renderers/Indicator/hma.ts +++ b/packages/core/src/engine/renderers/Indicator/hma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcHMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const HMA_COLOR = '#f43f5e' - type Point = { x: number; y: number } interface HMARendererOptions { @@ -64,6 +63,11 @@ function createHMARendererPlugin(options: HMARendererOptions = {}): RendererPlug draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createHMARendererPlugin(options: HMARendererOptions = {}): RendererPlug if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: HMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i4 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = HMA_COLOR + ctx.strokeStyle = colors.palette.i4 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getHMATitleInfo = createSingleLineTitleInfo({ createStateKey: createHMAStateKey, name: 'HMA', getParams: (p) => [p.period as number], - color: HMA_COLOR, + getColor: (colors) => colors.palette.i4, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/hv.ts b/packages/core/src/engine/renderers/Indicator/hv.ts index 569a89ed..30bdcbaf 100644 --- a/packages/core/src/engine/renderers/Indicator/hv.ts +++ b/packages/core/src/engine/renderers/Indicator/hv.ts @@ -17,8 +17,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const HV_COLOR = '#7c3aed' - type LinePoint = { x: number; y: number } function getHVStateKey(host: PluginHost | null, paneId: string): string | null { @@ -59,6 +57,11 @@ function createHVRendererPlugin(options: { paneId?: string } = {}): RendererPlug }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -85,11 +88,12 @@ function createHVRendererPlugin(options: { paneId?: string } = {}): RendererPlug if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: HV_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i8 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = HV_COLOR + ctx.strokeStyle = colors.palette.i8 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -115,7 +119,7 @@ const getHVTitleInfo = createSingleLineTitleInfo({ createStateKey: createHVStateKey, name: 'HV', getParams: (p) => [(p.period as number) ?? 20, (p.annualizationFactor as number) ?? 252], - color: HV_COLOR, + getColor: (colors) => colors.palette.i8, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/ichimoku.ts b/packages/core/src/engine/renderers/Indicator/ichimoku.ts index 2cab2114..b86fd8e8 100644 --- a/packages/core/src/engine/renderers/Indicator/ichimoku.ts +++ b/packages/core/src/engine/renderers/Indicator/ichimoku.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcIchimokuData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -22,10 +23,7 @@ import { getPhysicalKLineConfig } from '../../utils/klineConfig' import { tryDrawLinesGpu } from '../linesViaRenderer' const TENKAN_COLOR = '#dc2626' -const KIJUN_COLOR = '#2563eb' -const SPAN_A_COLOR = '#16a34a' const SPAN_B_COLOR = '#dc2626' -const CHIKOU_COLOR = '#7c3aed' type Point = { x: number; y: number } /** @internal 对测试暴露 */ @@ -107,14 +105,15 @@ function renderIchimokuLines( spanAPts: Point[], spanBPts: Point[], chikouPts: Point[], + colors: ReturnType, ): void { const { ctx, scrollLeft } = context const lines: Array<{ points: Point[]; width: number; color: string }> = [] if (tenkanPts.length >= 2) lines.push({ points: tenkanPts, width: 1, color: TENKAN_COLOR }) - if (kijunPts.length >= 2) lines.push({ points: kijunPts, width: 1, color: KIJUN_COLOR }) - if (spanAPts.length >= 2) lines.push({ points: spanAPts, width: 1, color: SPAN_A_COLOR }) + if (kijunPts.length >= 2) lines.push({ points: kijunPts, width: 1, color: colors.palette.i9 }) + if (spanAPts.length >= 2) lines.push({ points: spanAPts, width: 1, color: colors.palette.i3 }) if (spanBPts.length >= 2) lines.push({ points: spanBPts, width: 1, color: SPAN_B_COLOR }) - if (chikouPts.length >= 2) lines.push({ points: chikouPts, width: 1, color: CHIKOU_COLOR }) + if (chikouPts.length >= 2) lines.push({ points: chikouPts, width: 1, color: colors.palette.i8 }) if (tryDrawLinesGpu(context, lines, scrollLeft)) return @@ -124,10 +123,10 @@ function renderIchimokuLines( ctx.lineJoin = 'round' ctx.lineCap = 'round' drawLine(ctx, tenkanPts, TENKAN_COLOR) - drawLine(ctx, kijunPts, KIJUN_COLOR) - drawLine(ctx, spanAPts, SPAN_A_COLOR) + drawLine(ctx, kijunPts, colors.palette.i9) + drawLine(ctx, spanAPts, colors.palette.i3) drawLine(ctx, spanBPts, SPAN_B_COLOR) - drawLine(ctx, chikouPts, CHIKOU_COLOR) + drawLine(ctx, chikouPts, colors.palette.i8) ctx.restore() } @@ -200,6 +199,7 @@ function createIchimokuRendererPlugin( points.spanAPts, points.spanBPts, points.chikouPts, + colors, ) }, @@ -260,6 +260,7 @@ function getIchimokuTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const state = host.getSharedState(createIchimokuStateKey(paneId)) @@ -267,11 +268,14 @@ function getIchimokuTitleInfo( if (!p) return null const values: TitleValueItem[] = [] - if (p.tenkan !== undefined) values.push({ label: 'Tenkan', value: p.tenkan, color: '#dc2626' }) - if (p.kijun !== undefined) values.push({ label: 'Kijun', value: p.kijun, color: '#2563eb' }) - if (p.spanA !== undefined) values.push({ label: 'SpanA', value: p.spanA, color: '#16a34a' }) - if (p.spanB !== undefined) values.push({ label: 'SpanB', value: p.spanB, color: '#dc2626' }) - if (p.chikou !== undefined) values.push({ label: 'Chikou', value: p.chikou, color: '#7c3aed' }) + if (p.tenkan !== undefined) values.push({ label: 'Tenkan', value: p.tenkan, color: TENKAN_COLOR }) + if (p.kijun !== undefined) + values.push({ label: 'Kijun', value: p.kijun, color: colors.palette.i9 }) + if (p.spanA !== undefined) + values.push({ label: 'SpanA', value: p.spanA, color: colors.palette.i3 }) + if (p.spanB !== undefined) values.push({ label: 'SpanB', value: p.spanB, color: SPAN_B_COLOR }) + if (p.chikou !== undefined) + values.push({ label: 'Chikou', value: p.chikou, color: colors.palette.i8 }) return { name: 'Ichimoku', diff --git a/packages/core/src/engine/renderers/Indicator/kama.ts b/packages/core/src/engine/renderers/Indicator/kama.ts index 1245a507..f2e02367 100644 --- a/packages/core/src/engine/renderers/Indicator/kama.ts +++ b/packages/core/src/engine/renderers/Indicator/kama.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcKAMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const KAMA_COLOR = '#0ea5e9' - type Point = { x: number; y: number } interface KAMARendererOptions { @@ -64,6 +63,11 @@ function createKAMARendererPlugin(options: KAMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createKAMARendererPlugin(options: KAMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: KAMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = KAMA_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getKAMATitleInfo = createSingleLineTitleInfo({ createStateKey: createKAMAStateKey, name: 'KAMA', getParams: (p) => [p.period as number, p.fastPeriod as number, p.slowPeriod as number], - color: KAMA_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/keltner.ts b/packages/core/src/engine/renderers/Indicator/keltner.ts index 6a81cbcf..8832dbc5 100644 --- a/packages/core/src/engine/renderers/Indicator/keltner.ts +++ b/packages/core/src/engine/renderers/Indicator/keltner.ts @@ -4,6 +4,8 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcKeltnerData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -18,10 +20,6 @@ import { createKeltnerStateKey, EMPTY_KELTNER_STATE } from '../../indicators/sta import { createBandVisibleStateComposer } from '../../indicators/visibleStateComposers' import { tryDrawLinesGpu } from '../linesViaRenderer' -const KELTNER_UPPER_COLOR = '#7c3aed' -const KELTNER_MIDDLE_COLOR = '#f59e0b' -const KELTNER_LOWER_COLOR = '#7c3aed' - type Point = { x: number; y: number } interface KeltnerRendererOptions { @@ -68,6 +66,11 @@ function createKeltnerRendererPlugin(options: KeltnerRendererOptions = {}): Rend draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -94,12 +97,10 @@ function createKeltnerRendererPlugin(options: KeltnerRendererOptions = {}): Rend } const lines: Array<{ points: Point[]; width: number; color: string }> = [] - if (upperPts.length >= 2) - lines.push({ points: upperPts, width: 1, color: KELTNER_UPPER_COLOR }) + if (upperPts.length >= 2) lines.push({ points: upperPts, width: 1, color: colors.palette.i8 }) if (middlePts.length >= 2) - lines.push({ points: middlePts, width: 1, color: KELTNER_MIDDLE_COLOR }) - if (lowerPts.length >= 2) - lines.push({ points: lowerPts, width: 1, color: KELTNER_LOWER_COLOR }) + lines.push({ points: middlePts, width: 1, color: colors.palette.i2 }) + if (lowerPts.length >= 2) lines.push({ points: lowerPts, width: 1, color: colors.palette.i8 }) if (tryDrawLinesGpu(context, lines, scrollLeft)) return @@ -108,9 +109,9 @@ function createKeltnerRendererPlugin(options: KeltnerRendererOptions = {}): Rend ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' - drawLine(ctx, upperPts, KELTNER_UPPER_COLOR) - drawLine(ctx, middlePts, KELTNER_MIDDLE_COLOR) - drawLine(ctx, lowerPts, KELTNER_LOWER_COLOR) + drawLine(ctx, upperPts, colors.palette.i8) + drawLine(ctx, middlePts, colors.palette.i2) + drawLine(ctx, lowerPts, colors.palette.i8) ctx.restore() }, @@ -139,6 +140,7 @@ function getKeltnerTitleInfo( params: Record, host: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const state = host.getSharedState(createKeltnerStateKey(paneId)) @@ -153,9 +155,9 @@ function getKeltnerTitleInfo( (params.multiplier as number) ?? 2, ], values: [ - { label: 'Upper', value: p.upper, color: '#7c3aed' }, - { label: 'Mid', value: p.middle, color: '#f59e0b' }, - { label: 'Lower', value: p.lower, color: '#7c3aed' }, + { label: 'Upper', value: p.upper, color: colors.palette.i8 }, + { label: 'Mid', value: p.middle, color: colors.palette.i2 }, + { label: 'Lower', value: p.lower, color: colors.palette.i8 }, ], } } diff --git a/packages/core/src/engine/renderers/Indicator/lsma.ts b/packages/core/src/engine/renderers/Indicator/lsma.ts index f086ceb1..c66ed74d 100644 --- a/packages/core/src/engine/renderers/Indicator/lsma.ts +++ b/packages/core/src/engine/renderers/Indicator/lsma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcLSMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const LSMA_COLOR = '#eab308' - type Point = { x: number; y: number } interface LSMARendererOptions { @@ -64,6 +63,11 @@ function createLSMARendererPlugin(options: LSMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createLSMARendererPlugin(options: LSMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: LSMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i7 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = LSMA_COLOR + ctx.strokeStyle = colors.palette.i7 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getLSMATitleInfo = createSingleLineTitleInfo({ createStateKey: createLSMAStateKey, name: 'LSMA', getParams: (p) => [p.period as number], - color: LSMA_COLOR, + getColor: (colors) => colors.palette.i7, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/mfi.ts b/packages/core/src/engine/renderers/Indicator/mfi.ts index 5326b5d4..9cfdade3 100644 --- a/packages/core/src/engine/renderers/Indicator/mfi.ts +++ b/packages/core/src/engine/renderers/Indicator/mfi.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcMFIData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const MFI_COLOR = '#fb923c' - type LinePoint = { x: number; y: number } function getMFIStateKey(host: PluginHost | null, paneId: string): string | null { @@ -56,6 +55,11 @@ function createMFIRendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -71,17 +75,17 @@ function createMFIRendererPlugin(options: { paneId?: string } = {}): RendererPlu const rangeStart = range.start const toY = (v: number) => paneH - (v - displayMin) * invRange - // 80 / 20 reference lines + // 80 / 20 reference lines(复用 CCI 超买超卖 token:语义同为买卖压力带) ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(239, 68, 68, 0.3)' + ctx.strokeStyle = colors.cci.overbought ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() ctx.moveTo(scrollLeft, toY(80)) ctx.lineTo(scrollLeft + context.paneWidth, toY(80)) ctx.stroke() - ctx.strokeStyle = 'rgba(34, 197, 94, 0.3)' + ctx.strokeStyle = colors.cci.oversold ctx.beginPath() ctx.moveTo(scrollLeft, toY(20)) ctx.lineTo(scrollLeft + context.paneWidth, toY(20)) @@ -101,11 +105,12 @@ function createMFIRendererPlugin(options: { paneId?: string } = {}): RendererPlu if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: MFI_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i5 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = MFI_COLOR + ctx.strokeStyle = colors.palette.i5 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -131,7 +136,7 @@ const getMFITitleInfo = createSingleLineTitleInfo({ createStateKey: createMFIStateKey, name: 'MFI', defaultPeriod: 14, - color: MFI_COLOR, + getColor: (colors) => colors.palette.i5, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/obv.ts b/packages/core/src/engine/renderers/Indicator/obv.ts index ac540f7c..869ad63c 100644 --- a/packages/core/src/engine/renderers/Indicator/obv.ts +++ b/packages/core/src/engine/renderers/Indicator/obv.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcOBVData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const OBV_COLOR = '#16a34a' - type LinePoint = { x: number; y: number } function getOBVStateKey(host: PluginHost | null, paneId: string): string | null { @@ -56,6 +55,11 @@ function createOBVRendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -82,11 +86,12 @@ function createOBVRendererPlugin(options: { paneId?: string } = {}): RendererPlu if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: OBV_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i3 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = OBV_COLOR + ctx.strokeStyle = colors.palette.i3 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -111,7 +116,7 @@ function createOBVRendererPlugin(options: { paneId?: string } = {}): RendererPlu const getOBVTitleInfo = createSingleLineTitleInfo({ createStateKey: createOBVStateKey, name: 'OBV', - color: OBV_COLOR, + getColor: (colors) => colors.palette.i3, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/parkinson.ts b/packages/core/src/engine/renderers/Indicator/parkinson.ts index 2ccbe561..75e79b2d 100644 --- a/packages/core/src/engine/renderers/Indicator/parkinson.ts +++ b/packages/core/src/engine/renderers/Indicator/parkinson.ts @@ -17,8 +17,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const PARKINSON_COLOR = '#0891b2' - type LinePoint = { x: number; y: number } function getParkinsonStateKey(host: PluginHost | null, paneId: string): string | null { @@ -59,6 +57,11 @@ function createParkinsonRendererPlugin(options: { paneId?: string } = {}): Rende }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -85,11 +88,12 @@ function createParkinsonRendererPlugin(options: { paneId?: string } = {}): Rende if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: PARKINSON_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = PARKINSON_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -115,7 +119,7 @@ const getParkinsonTitleInfo = createSingleLineTitleInfo({ createStateKey: createParkinsonStateKey, name: 'Parkinson', getParams: (p) => [(p.period as number) ?? 20, (p.annualizationFactor as number) ?? 252], - color: PARKINSON_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/pivot.ts b/packages/core/src/engine/renderers/Indicator/pivot.ts index a384206a..adaea451 100644 --- a/packages/core/src/engine/renderers/Indicator/pivot.ts +++ b/packages/core/src/engine/renderers/Indicator/pivot.ts @@ -4,6 +4,8 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import { calcPivotData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { @@ -17,9 +19,8 @@ import type { PivotRenderState } from '../../indicators/state/pivotState' import { createPivotStateKey, EMPTY_PIVOT_STATE } from '../../indicators/state/pivotState' import { createExactRangePointVisibleStateComposer } from '../../indicators/visibleStateComposers' -const PP_COLOR = '#94a3b8' +// R 阻力线保留红色 const:palette 无红色系,不强配 const R_COLOR = '#dc2626' -const S_COLOR = '#16a34a' type Point = { x: number; y: number } @@ -61,6 +62,11 @@ function createPivotRendererPlugin(options: { paneId?: string } = {}): RendererP }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -97,13 +103,13 @@ function createPivotRendererPlugin(options: { paneId?: string } = {}): RendererP ctx.save() ctx.translate(-scrollLeft, 0) ctx.lineWidth = 1 - drawStep(ctx, ppPts, PP_COLOR) + drawStep(ctx, ppPts, colors.palette.i10) drawStep(ctx, r1Pts, R_COLOR) drawStep(ctx, r2Pts, R_COLOR) drawStep(ctx, r3Pts, R_COLOR) - drawStep(ctx, s1Pts, S_COLOR) - drawStep(ctx, s2Pts, S_COLOR) - drawStep(ctx, s3Pts, S_COLOR) + drawStep(ctx, s1Pts, colors.palette.i3) + drawStep(ctx, s2Pts, colors.palette.i3) + drawStep(ctx, s3Pts, colors.palette.i3) ctx.restore() }, getConfig() { @@ -128,7 +134,7 @@ function drawStep(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v ctx.stroke() } -const getPivotTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) => { +const getPivotTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId, colors) => { if (index === null || index < 0) return null const stateKey = createPivotStateKey(paneId) @@ -141,7 +147,7 @@ const getPivotTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) const values: TitleValueItem[] = [] if (state.params.showPP) { - values.push({ label: 'PP', value: p.pp, color: PP_COLOR }) + values.push({ label: 'PP', value: p.pp, color: colors.palette.i10 }) } if (state.params.showR1) { values.push({ label: 'R1', value: p.r1, color: R_COLOR }) @@ -153,13 +159,13 @@ const getPivotTitleInfo: GetTitleInfoFn = (_data, index, _params, host, paneId) values.push({ label: 'R3', value: p.r3, color: R_COLOR }) } if (state.params.showS1) { - values.push({ label: 'S1', value: p.s1, color: S_COLOR }) + values.push({ label: 'S1', value: p.s1, color: colors.palette.i3 }) } if (state.params.showS2) { - values.push({ label: 'S2', value: p.s2, color: S_COLOR }) + values.push({ label: 'S2', value: p.s2, color: colors.palette.i3 }) } if (state.params.showS3) { - values.push({ label: 'S3', value: p.s3, color: S_COLOR }) + values.push({ label: 'S3', value: p.s3, color: colors.palette.i3 }) } if (values.length === 0) return null diff --git a/packages/core/src/engine/renderers/Indicator/pvt.ts b/packages/core/src/engine/renderers/Indicator/pvt.ts index dffc6b0b..8c8ef96f 100644 --- a/packages/core/src/engine/renderers/Indicator/pvt.ts +++ b/packages/core/src/engine/renderers/Indicator/pvt.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcPVTData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const PVT_COLOR = '#a855f7' - type LinePoint = { x: number; y: number } function getPVTStateKey(host: PluginHost | null, paneId: string): string | null { @@ -56,6 +55,11 @@ function createPVTRendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -82,11 +86,12 @@ function createPVTRendererPlugin(options: { paneId?: string } = {}): RendererPlu if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: PVT_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i8 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = PVT_COLOR + ctx.strokeStyle = colors.palette.i8 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -111,7 +116,7 @@ function createPVTRendererPlugin(options: { paneId?: string } = {}): RendererPlu const getPVTTitleInfo = createSingleLineTitleInfo({ createStateKey: createPVTStateKey, name: 'PVT', - color: PVT_COLOR, + getColor: (colors) => colors.palette.i8, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/roc.ts b/packages/core/src/engine/renderers/Indicator/roc.ts index a165aba0..c19a846e 100644 --- a/packages/core/src/engine/renderers/Indicator/roc.ts +++ b/packages/core/src/engine/renderers/Indicator/roc.ts @@ -16,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const ROC_COLOR = '#0ea5e9' - type LinePoint = { x: number; y: number } interface ROCRendererOptions { @@ -64,6 +62,11 @@ function createROCRendererPlugin(options: ROCRendererOptions = {}): RendererPlug draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -82,7 +85,7 @@ function createROCRendererPlugin(options: ROCRendererOptions = {}): RendererPlug const zeroY = paneH - (0 - displayMin) * invRange ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() @@ -104,11 +107,12 @@ function createROCRendererPlugin(options: ROCRendererOptions = {}): RendererPlug if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: ROC_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = ROC_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -135,7 +139,7 @@ const getROCTitleInfo = createSingleLineTitleInfo({ createStateKey: createROCStateKey, name: 'ROC', defaultPeriod: 12, - color: ROC_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/smma.ts b/packages/core/src/engine/renderers/Indicator/smma.ts index 1e6d6145..d0a7d7c0 100644 --- a/packages/core/src/engine/renderers/Indicator/smma.ts +++ b/packages/core/src/engine/renderers/Indicator/smma.ts @@ -8,6 +8,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcSMMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -19,8 +20,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const SMMA_COLOR = '#8b5cf6' - type Point = { x: number; y: number } interface SMMARendererOptions { @@ -79,6 +78,11 @@ function createSMMARendererPlugin(options: SMMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -102,11 +106,12 @@ function createSMMARendererPlugin(options: SMMARendererOptions = {}): RendererPl if (points.length < 2) return // 优先走 GPU 批量折线,不可用时回退 Canvas2D - if (tryDrawLinesGpu(context, [{ points, width: 1, color: SMMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i8 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = SMMA_COLOR + ctx.strokeStyle = colors.palette.i8 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -136,7 +141,7 @@ const getSMMATitleInfo = createSingleLineTitleInfo({ createStateKey: createSMMAStateKey, name: 'SMMA', getParams: (p) => [p.period as number], - color: SMMA_COLOR, + getColor: (colors) => colors.palette.i8, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/tema.ts b/packages/core/src/engine/renderers/Indicator/tema.ts index 508560f8..90472ee6 100644 --- a/packages/core/src/engine/renderers/Indicator/tema.ts +++ b/packages/core/src/engine/renderers/Indicator/tema.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcTEMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const TEMA_COLOR = '#d946ef' - type Point = { x: number; y: number } interface TEMARendererOptions { @@ -64,6 +63,11 @@ function createTEMARendererPlugin(options: TEMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createTEMARendererPlugin(options: TEMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: TEMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i4 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = TEMA_COLOR + ctx.strokeStyle = colors.palette.i4 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getTEMATitleInfo = createSingleLineTitleInfo({ createStateKey: createTEMAStateKey, name: 'TEMA', getParams: (p) => [p.period as number], - color: TEMA_COLOR, + getColor: (colors) => colors.palette.i4, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/trima.ts b/packages/core/src/engine/renderers/Indicator/trima.ts index 38925275..5e7cebb2 100644 --- a/packages/core/src/engine/renderers/Indicator/trima.ts +++ b/packages/core/src/engine/renderers/Indicator/trima.ts @@ -5,6 +5,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcTRIMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -16,8 +17,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const TRIMA_COLOR = '#f97316' - type Point = { x: number; y: number } interface TRIMARendererOptions { @@ -65,6 +64,11 @@ function createTRIMARendererPlugin(options: TRIMARendererOptions = {}): Renderer draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -86,11 +90,12 @@ function createTRIMARendererPlugin(options: TRIMARendererOptions = {}): Renderer if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: TRIMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i5 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = TRIMA_COLOR + ctx.strokeStyle = colors.palette.i5 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -120,7 +125,7 @@ const getTRIMATitleInfo = createSingleLineTitleInfo({ createStateKey: createTRIMAStateKey, name: 'TRIMA', getParams: (p) => [p.period as number], - color: TRIMA_COLOR, + getColor: (colors) => colors.palette.i5, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/trix.ts b/packages/core/src/engine/renderers/Indicator/trix.ts index 9d68e49c..85a8cc61 100644 --- a/packages/core/src/engine/renderers/Indicator/trix.ts +++ b/packages/core/src/engine/renderers/Indicator/trix.ts @@ -5,6 +5,7 @@ import type { } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' import { resolveThemeColors } from '../../../foundation/tokens/index' +import type { ColorTokens } from '../../../foundation/tokens/index' import type { KLineData } from '../../../foundation/types/price' import { calcTRIXData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' @@ -17,9 +18,6 @@ import { EMPTY_TRIX_STATE } from '../../indicators/state/trixState' import { createDualSparseVisibleStateComposer } from '../../indicators/visibleStateComposers' import { tryDrawLinesGpu } from '../linesViaRenderer' -const TRIX_COLOR = '#e11d48' -const SIGNAL_COLOR = '#f59e0b' - type Point = { x: number; y: number } interface TRIXRendererOptions { @@ -66,6 +64,13 @@ function createTRIXRendererPlugin(options: TRIXRendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) + const trixColor = colors.palette.i4 + const signalColor = colors.palette.i2 const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -87,7 +92,7 @@ function createTRIXRendererPlugin(options: TRIXRendererOptions = {}): RendererPl const zeroY = toY(0) ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() @@ -116,8 +121,8 @@ function createTRIXRendererPlugin(options: TRIXRendererOptions = {}): RendererPl if (trixPts.length < 2 && sigPts.length < 2) return const lines: Array<{ points: Point[]; width: number; color: string }> = [] - if (trixPts.length >= 2) lines.push({ points: trixPts, width: 1, color: TRIX_COLOR }) - if (sigPts.length >= 2) lines.push({ points: sigPts, width: 1, color: SIGNAL_COLOR }) + if (trixPts.length >= 2) lines.push({ points: trixPts, width: 1, color: trixColor }) + if (sigPts.length >= 2) lines.push({ points: sigPts, width: 1, color: signalColor }) if (tryDrawLinesGpu(context, lines, scrollLeft)) return @@ -126,8 +131,8 @@ function createTRIXRendererPlugin(options: TRIXRendererOptions = {}): RendererPl ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' - drawLine(ctx, trixPts, TRIX_COLOR) - drawLine(ctx, sigPts, SIGNAL_COLOR) + drawLine(ctx, trixPts, trixColor) + drawLine(ctx, sigPts, signalColor) ctx.restore() }, @@ -156,6 +161,7 @@ function getTRIXTitleInfo( params: Record, pluginHost: PluginHost, paneId: string, + colors: ColorTokens, ): TitleInfo | null { if (index === null) return null const period = (params.period as number) ?? 15 @@ -167,11 +173,11 @@ function getTRIXTitleInfo( if (state.params.showTRIX) { const v = state.series[index] - if (v !== undefined) values.push({ label: 'TRIX', value: v, color: TRIX_COLOR }) + if (v !== undefined) values.push({ label: 'TRIX', value: v, color: colors.palette.i4 }) } if (state.params.showSignal) { const v = state.signalSeries[index] - if (v !== undefined) values.push({ label: 'Signal', value: v, color: SIGNAL_COLOR }) + if (v !== undefined) values.push({ label: 'Signal', value: v, color: colors.palette.i2 }) } if (values.length === 0) return null diff --git a/packages/core/src/engine/renderers/Indicator/vma.ts b/packages/core/src/engine/renderers/Indicator/vma.ts index 3e811928..40b68062 100644 --- a/packages/core/src/engine/renderers/Indicator/vma.ts +++ b/packages/core/src/engine/renderers/Indicator/vma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcVMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -16,8 +17,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const VMA_COLOR = '#0ea5e9' - type LinePoint = { x: number; y: number } function getVMAStateKey(host: PluginHost | null, paneId: string): string | null { @@ -57,6 +56,11 @@ function createVMARendererPlugin(options: { paneId?: string } = {}): RendererPlu }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -84,11 +88,12 @@ function createVMARendererPlugin(options: { paneId?: string } = {}): RendererPlu if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: VMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = VMA_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -114,7 +119,7 @@ const getVMATitleInfo = createSingleLineTitleInfo({ createStateKey: createVMAStateKey, name: 'VMA', defaultPeriod: 5, - color: VMA_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/vwap.ts b/packages/core/src/engine/renderers/Indicator/vwap.ts index e7e75d4f..3bb65411 100644 --- a/packages/core/src/engine/renderers/Indicator/vwap.ts +++ b/packages/core/src/engine/renderers/Indicator/vwap.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcVWAPData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const VWAP_COLOR = '#ec4899' - type LinePoint = { x: number; y: number } function getVWAPStateKey(host: PluginHost | null, paneId: string): string | null { @@ -56,6 +55,11 @@ function createVWAPRendererPlugin(options: { paneId?: string } = {}): RendererPl }, draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return const state = pluginHost?.getSharedState(stateKey) @@ -82,11 +86,12 @@ function createVWAPRendererPlugin(options: { paneId?: string } = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: VWAP_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i4 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = VWAP_COLOR + ctx.strokeStyle = colors.palette.i4 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -111,7 +116,7 @@ function createVWAPRendererPlugin(options: { paneId?: string } = {}): RendererPl const getVWAPTitleInfo = createSingleLineTitleInfo({ createStateKey: createVWAPStateKey, name: 'VWAP', - color: VWAP_COLOR, + getColor: (colors) => colors.palette.i4, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/vwma.ts b/packages/core/src/engine/renderers/Indicator/vwma.ts index ae98ea85..e142eb9d 100644 --- a/packages/core/src/engine/renderers/Indicator/vwma.ts +++ b/packages/core/src/engine/renderers/Indicator/vwma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcVWMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const VWMA_COLOR = '#a855f7' - type Point = { x: number; y: number } interface VWMARendererOptions { @@ -64,6 +63,11 @@ function createVWMARendererPlugin(options: VWMARendererOptions = {}): RendererPl draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createVWMARendererPlugin(options: VWMARendererOptions = {}): RendererPl if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: VWMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i8 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = VWMA_COLOR + ctx.strokeStyle = colors.palette.i8 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getVWMATitleInfo = createSingleLineTitleInfo({ createStateKey: createVWMAStateKey, name: 'VWMA', getParams: (p) => [p.period as number], - color: VWMA_COLOR, + getColor: (colors) => colors.palette.i8, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/wma.ts b/packages/core/src/engine/renderers/Indicator/wma.ts index 2d65a586..e8c80ec8 100644 --- a/packages/core/src/engine/renderers/Indicator/wma.ts +++ b/packages/core/src/engine/renderers/Indicator/wma.ts @@ -4,6 +4,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcWMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -15,8 +16,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const WMA_COLOR = '#10b981' - type Point = { x: number; y: number } interface WMARendererOptions { @@ -64,6 +63,11 @@ function createWMARendererPlugin(options: WMARendererOptions = {}): RendererPlug draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -85,11 +89,12 @@ function createWMARendererPlugin(options: WMARendererOptions = {}): RendererPlug if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: WMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i3 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = WMA_COLOR + ctx.strokeStyle = colors.palette.i3 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -119,7 +124,7 @@ const getWMATitleInfo = createSingleLineTitleInfo({ createStateKey: createWMAStateKey, name: 'WMA', getParams: (p) => [p.period as number], - color: WMA_COLOR, + getColor: (colors) => colors.palette.i3, }) @Indicator({ diff --git a/packages/core/src/engine/renderers/Indicator/zlema.ts b/packages/core/src/engine/renderers/Indicator/zlema.ts index 816473e3..b96eeb9a 100644 --- a/packages/core/src/engine/renderers/Indicator/zlema.ts +++ b/packages/core/src/engine/renderers/Indicator/zlema.ts @@ -8,6 +8,7 @@ import type { PluginHost, } from '../../../foundation/plugin/index' import { RENDERER_PRIORITY } from '../../../foundation/plugin/index' +import { resolveThemeColors } from '../../../foundation/tokens/index' import { calcZLEMAData } from '../../indicators/calculators' import { Indicator } from '../../indicators/indicatorDefinitionRegistry' import { resolveStateKey } from '../../indicators/indicatorMetadata' @@ -19,8 +20,6 @@ import { tryDrawLinesGpu } from '../linesViaRenderer' import { createSingleLineTitleInfo } from './shared/titleInfo' -const ZLEMA_COLOR = '#06b6d4' - type Point = { x: number; y: number } interface ZLEMARendererOptions { @@ -73,6 +72,11 @@ function createZLEMARendererPlugin(options: ZLEMARendererOptions = {}): Renderer draw(context: RenderContext) { const { ctx, pane, range, scrollLeft, kLineCenters } = context + const colors = resolveThemeColors( + context.theme, + context.isAsiaMarket, + context.colorPresetSettings, + ) const stateKey = resolveKey() if (!stateKey) return @@ -94,11 +98,12 @@ function createZLEMARendererPlugin(options: ZLEMARendererOptions = {}): Renderer if (points.length < 2) return - if (tryDrawLinesGpu(context, [{ points, width: 1, color: ZLEMA_COLOR }], scrollLeft)) return + if (tryDrawLinesGpu(context, [{ points, width: 1, color: colors.palette.i6 }], scrollLeft)) + return ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = ZLEMA_COLOR + ctx.strokeStyle = colors.palette.i6 ctx.lineWidth = 1 ctx.lineJoin = 'round' ctx.lineCap = 'round' @@ -128,7 +133,7 @@ const getZLEMATitleInfo = createSingleLineTitleInfo({ createStateKey: createZLEMAStateKey, name: 'ZLEMA', getParams: (p) => [p.period as number], - color: ZLEMA_COLOR, + getColor: (colors) => colors.palette.i6, }) @Indicator({ From fda8c8f773e011c94377e6c5ea2d2359254b5e13 Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:23 +0800 Subject: [PATCH 07/10] =?UTF-8?q?refactor(indicator):=20atr/cci=20?= =?UTF-8?q?=E9=9B=B6=E7=BA=BF=E9=A2=9C=E8=89=B2=E6=94=B9=20wmsrGrid=20toke?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/engine/renderers/Indicator/atr.ts | 3 ++- packages/core/src/engine/renderers/Indicator/cci.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/atr.ts b/packages/core/src/engine/renderers/Indicator/atr.ts index b8d8fd80..e056af63 100644 --- a/packages/core/src/engine/renderers/Indicator/atr.ts +++ b/packages/core/src/engine/renderers/Indicator/atr.ts @@ -129,7 +129,8 @@ function createATRRendererPlugin(options: ATRRendererOptions = {}): RendererPlug ctx.save() ctx.translate(-scrollLeft, 0) - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + // 零线使用主题 wmsrGrid token,避免硬编码颜色 + ctx.strokeStyle = colors.wmsrGrid ctx.lineWidth = 1 ctx.setLineDash([4, 4]) ctx.beginPath() diff --git a/packages/core/src/engine/renderers/Indicator/cci.ts b/packages/core/src/engine/renderers/Indicator/cci.ts index f54c8c6e..77c745c9 100644 --- a/packages/core/src/engine/renderers/Indicator/cci.ts +++ b/packages/core/src/engine/renderers/Indicator/cci.ts @@ -151,8 +151,8 @@ function createCCIRendererPlugin(options: CCIRendererOptions = {}): RendererPlug ctx.lineTo(lineEndX, yNeg100) ctx.stroke() - // 零轴 - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)' + // 零轴(使用主题 wmsrGrid token,避免硬编码颜色) + ctx.strokeStyle = colors.wmsrGrid ctx.beginPath() ctx.moveTo(lineStartX, zeroY) ctx.lineTo(lineEndX, zeroY) From e46c788b8cd19fee06c58ec9897b7e28593277cf Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:27 +0800 Subject: [PATCH 08/10] =?UTF-8?q?test(tokens):=20=E6=9B=B4=E6=96=B0=20base?= =?UTF-8?q?line=20=E5=BF=AB=E7=85=A7=E4=BB=A5=E5=8C=B9=E9=85=8D=20MA=20?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/baseline.test.ts.snap | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/core/src/foundation/tokens/__tests__/__snapshots__/baseline.test.ts.snap b/packages/core/src/foundation/tokens/__tests__/__snapshots__/baseline.test.ts.snap index 24a50f4b..efa1833f 100644 --- a/packages/core/src/foundation/tokens/__tests__/__snapshots__/baseline.test.ts.snap +++ b/packages/core/src/foundation/tokens/__tests__/__snapshots__/baseline.test.ts.snap @@ -78,11 +78,11 @@ exports[`theme baseline — dark > CSS declaration block (snapshot) 1`] = ` --klc-color-border-separator: rgba(255, 255, 255, 0.10); --klc-color-border-button: #505060; --klc-color-border-chart: #3A4048; - --klc-color-ma-ma5: rgba(255, 200, 50, 1); - --klc-color-ma-ma10: rgba(200, 150, 30, 1); - --klc-color-ma-ma20: rgba(90, 140, 255, 1); - --klc-color-ma-ma30: rgba(90, 190, 95, 1); - --klc-color-ma-ma60: rgba(170, 60, 195, 1); + --klc-color-ma-ma5: #e8590c; + --klc-color-ma-ma10: #0891b2; + --klc-color-ma-ma20: #2563eb; + --klc-color-ma-ma30: #2f9e44; + --klc-color-ma-ma60: #ae3ec9; --klc-color-boll-upper: rgba(200, 60, 60, 1); --klc-color-boll-middle: rgba(90, 140, 255, 1); --klc-color-boll-lower: rgba(50, 170, 60, 1); @@ -278,11 +278,11 @@ exports[`theme baseline — light > CSS declaration block (snapshot) 1`] = ` --klc-color-border-separator: rgba(0, 0, 0, 0.10); --klc-color-border-button: #d0d0d0; --klc-color-border-chart: #e5e5e5; - --klc-color-ma-ma5: rgba(255, 193, 37, 1); - --klc-color-ma-ma10: rgba(190, 131, 12, 1); - --klc-color-ma-ma20: rgba(69, 112, 249, 1); - --klc-color-ma-ma30: rgba(76, 175, 80, 1); - --klc-color-ma-ma60: rgba(156, 39, 176, 1); + --klc-color-ma-ma5: #e8590c; + --klc-color-ma-ma10: #0891b2; + --klc-color-ma-ma20: #2563eb; + --klc-color-ma-ma30: #2f9e44; + --klc-color-ma-ma60: #ae3ec9; --klc-color-boll-upper: rgba(178, 34, 34, 1); --klc-color-boll-middle: rgba(69, 112, 249, 1); --klc-color-boll-lower: rgba(34, 139, 34, 1); From 867dd7060ec1f383dbc281a1117ada3409b3e8ee Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 21:51:33 +0800 Subject: [PATCH 09/10] =?UTF-8?q?build(tsconfig):=20app=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8E=92=E9=99=A4=20*.config.*=20=E4=BB=A5=E8=A7=84?= =?UTF-8?q?=E9=81=BF=20TS=206.0.3=20=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config 文件本就归属 tsconfig.node.json,被 packages/**/*.ts 拉入后 defineConfig(...) 触发 TS 6.0.3 getSignatureApplicabilityError 内部 崩溃;排除后 vue-tsc --build 可正常运行到报错阶段 --- tsconfig.app.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.app.json b/tsconfig.app.json index dbe7ddfd..0b7fbcef 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -7,7 +7,8 @@ "exclude": [ "**/__tests__/**", "**/node_modules", - "**/dist" + "**/dist", + "**/*.config.*" ], "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", From a5e6eb65dcf87a6b79a1a5d184a202009e121196 Mon Sep 17 00:00:00 2001 From: 363045841 <161981174@qq.com> Date: Sat, 1 Aug 2026 22:13:55 +0800 Subject: [PATCH 10/10] =?UTF-8?q?refactor(indicator):=20=E4=B8=BB=E5=9B=BE?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E7=BA=BF=E7=BB=98=E5=88=B6=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=B0=20K=20=E7=BA=BF=E4=B9=8B=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 41 个指标渲染器 priority 由 RENDERER_PRIORITY.MAIN(50) 改为 INDICATOR(30) - K 线(MAIN=50)后画,主图叠加指标线落在 K 线之下,修复指标线覆盖 K 线 - 与文档契约「指标渲染器必须使用 INDICATOR 或 ≤30」一致;副图相对刻度层顺序不变 --- packages/core/src/engine/renderers/Indicator/alma.ts | 2 +- packages/core/src/engine/renderers/Indicator/atr.ts | 2 +- packages/core/src/engine/renderers/Indicator/cci.ts | 2 +- packages/core/src/engine/renderers/Indicator/chaikinVol.ts | 2 +- packages/core/src/engine/renderers/Indicator/cmf.ts | 2 +- packages/core/src/engine/renderers/Indicator/dema.ts | 2 +- packages/core/src/engine/renderers/Indicator/dma.ts | 2 +- packages/core/src/engine/renderers/Indicator/donchian.ts | 2 +- packages/core/src/engine/renderers/Indicator/fastk.ts | 2 +- packages/core/src/engine/renderers/Indicator/fib.ts | 2 +- packages/core/src/engine/renderers/Indicator/gmma.ts | 2 +- packages/core/src/engine/renderers/Indicator/hma.ts | 2 +- packages/core/src/engine/renderers/Indicator/hv.ts | 2 +- packages/core/src/engine/renderers/Indicator/kama.ts | 2 +- packages/core/src/engine/renderers/Indicator/keltner.ts | 2 +- packages/core/src/engine/renderers/Indicator/kst.ts | 2 +- packages/core/src/engine/renderers/Indicator/lsma.ts | 2 +- packages/core/src/engine/renderers/Indicator/mfi.ts | 2 +- packages/core/src/engine/renderers/Indicator/mom.ts | 2 +- packages/core/src/engine/renderers/Indicator/obv.ts | 2 +- packages/core/src/engine/renderers/Indicator/parkinson.ts | 2 +- packages/core/src/engine/renderers/Indicator/pivot.ts | 2 +- packages/core/src/engine/renderers/Indicator/pvt.ts | 2 +- packages/core/src/engine/renderers/Indicator/roc.ts | 2 +- packages/core/src/engine/renderers/Indicator/rsi.ts | 2 +- packages/core/src/engine/renderers/Indicator/sar.ts | 2 +- packages/core/src/engine/renderers/Indicator/smma.ts | 2 +- packages/core/src/engine/renderers/Indicator/stoch.ts | 2 +- packages/core/src/engine/renderers/Indicator/structure.ts | 2 +- packages/core/src/engine/renderers/Indicator/supertrend.ts | 2 +- packages/core/src/engine/renderers/Indicator/tema.ts | 2 +- packages/core/src/engine/renderers/Indicator/trima.ts | 2 +- packages/core/src/engine/renderers/Indicator/trix.ts | 2 +- packages/core/src/engine/renderers/Indicator/vma.ts | 2 +- packages/core/src/engine/renderers/Indicator/volumeProfile.ts | 2 +- packages/core/src/engine/renderers/Indicator/vwap.ts | 2 +- packages/core/src/engine/renderers/Indicator/vwma.ts | 2 +- packages/core/src/engine/renderers/Indicator/wma.ts | 2 +- packages/core/src/engine/renderers/Indicator/wmsr.ts | 2 +- packages/core/src/engine/renderers/Indicator/zlema.ts | 2 +- packages/core/src/engine/renderers/Indicator/zones.ts | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/core/src/engine/renderers/Indicator/alma.ts b/packages/core/src/engine/renderers/Indicator/alma.ts index c9f601ac..82be3b54 100644 --- a/packages/core/src/engine/renderers/Indicator/alma.ts +++ b/packages/core/src/engine/renderers/Indicator/alma.ts @@ -54,7 +54,7 @@ function createALMARendererPlugin(options: ALMARendererOptions = {}): RendererPl description: 'ALMA Arnaud Legoux 移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'ALMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/atr.ts b/packages/core/src/engine/renderers/Indicator/atr.ts index e056af63..2315d2d7 100644 --- a/packages/core/src/engine/renderers/Indicator/atr.ts +++ b/packages/core/src/engine/renderers/Indicator/atr.ts @@ -87,7 +87,7 @@ function createATRRendererPlugin(options: ATRRendererOptions = {}): RendererPlug description: 'ATR 平均真实波幅渲染器(Wilder 平滑)', debugName: 'ATR', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/cci.ts b/packages/core/src/engine/renderers/Indicator/cci.ts index 77c745c9..f415e068 100644 --- a/packages/core/src/engine/renderers/Indicator/cci.ts +++ b/packages/core/src/engine/renderers/Indicator/cci.ts @@ -89,7 +89,7 @@ function createCCIRendererPlugin(options: CCIRendererOptions = {}): RendererPlug description: 'CCI 顺势指标渲染器(WebGL + Canvas2D 回退)', debugName: 'CCI', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/chaikinVol.ts b/packages/core/src/engine/renderers/Indicator/chaikinVol.ts index 32cc50df..16dbb48a 100644 --- a/packages/core/src/engine/renderers/Indicator/chaikinVol.ts +++ b/packages/core/src/engine/renderers/Indicator/chaikinVol.ts @@ -51,7 +51,7 @@ function createChaikinVolRendererPlugin(options: { paneId?: string } = {}): Rend description: 'Chaikin Volatility 渲染器(WebGL + Canvas2D 回退)', debugName: 'ChaikinVol', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/cmf.ts b/packages/core/src/engine/renderers/Indicator/cmf.ts index b74c5af1..64845f48 100644 --- a/packages/core/src/engine/renderers/Indicator/cmf.ts +++ b/packages/core/src/engine/renderers/Indicator/cmf.ts @@ -45,7 +45,7 @@ function createCMFRendererPlugin(options: { paneId?: string } = {}): RendererPlu description: 'CMF Chaikin 资金流渲染器(WebGL + Canvas2D 回退)', debugName: 'CMF', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/dema.ts b/packages/core/src/engine/renderers/Indicator/dema.ts index 2a436d0c..5dfcc062 100644 --- a/packages/core/src/engine/renderers/Indicator/dema.ts +++ b/packages/core/src/engine/renderers/Indicator/dema.ts @@ -50,7 +50,7 @@ function createDEMARendererPlugin(options: DEMARendererOptions = {}): RendererPl description: 'DEMA 双重指数移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'DEMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/dma.ts b/packages/core/src/engine/renderers/Indicator/dma.ts index 22b9e905..93359bd9 100644 --- a/packages/core/src/engine/renderers/Indicator/dma.ts +++ b/packages/core/src/engine/renderers/Indicator/dma.ts @@ -48,7 +48,7 @@ function createDMARendererPlugin(options: DMARendererOptions = {}): RendererPlug description: 'DMA 平行线差渲染器(WebGL + Canvas2D 回退)', debugName: 'DMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/donchian.ts b/packages/core/src/engine/renderers/Indicator/donchian.ts index e5265b23..38f93997 100644 --- a/packages/core/src/engine/renderers/Indicator/donchian.ts +++ b/packages/core/src/engine/renderers/Indicator/donchian.ts @@ -56,7 +56,7 @@ function createDonchianRendererPlugin( description: 'Donchian Channel 渲染器(WebGL + Canvas2D 回退)', debugName: 'Donchian', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/fastk.ts b/packages/core/src/engine/renderers/Indicator/fastk.ts index 81b4cd2d..cd77c296 100644 --- a/packages/core/src/engine/renderers/Indicator/fastk.ts +++ b/packages/core/src/engine/renderers/Indicator/fastk.ts @@ -93,7 +93,7 @@ function createFASTKRendererPlugin(options: FASTKRendererOptions = {}): Renderer description: 'FASTK 快速随机指标渲染器(WebGL + Canvas2D 回退)', debugName: 'FASTK', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/fib.ts b/packages/core/src/engine/renderers/Indicator/fib.ts index d1d32e29..dcbc8bfc 100644 --- a/packages/core/src/engine/renderers/Indicator/fib.ts +++ b/packages/core/src/engine/renderers/Indicator/fib.ts @@ -69,7 +69,7 @@ function createFibRendererPlugin(options: { paneId?: string } = {}): RendererPlu description: '斐波那契回撤线渲染器(WebGL + Canvas2D 回退)', debugName: 'Fib', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/gmma.ts b/packages/core/src/engine/renderers/Indicator/gmma.ts index c5ac5a50..5412f5c2 100644 --- a/packages/core/src/engine/renderers/Indicator/gmma.ts +++ b/packages/core/src/engine/renderers/Indicator/gmma.ts @@ -176,7 +176,7 @@ export function createGMMARendererPlugin( description: 'GMMA 顾比移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'GMMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost): void { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/hma.ts b/packages/core/src/engine/renderers/Indicator/hma.ts index fd52be4b..55fda89d 100644 --- a/packages/core/src/engine/renderers/Indicator/hma.ts +++ b/packages/core/src/engine/renderers/Indicator/hma.ts @@ -50,7 +50,7 @@ function createHMARendererPlugin(options: HMARendererOptions = {}): RendererPlug description: 'HMA Hull 移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'HMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/hv.ts b/packages/core/src/engine/renderers/Indicator/hv.ts index 30bdcbaf..4a63b312 100644 --- a/packages/core/src/engine/renderers/Indicator/hv.ts +++ b/packages/core/src/engine/renderers/Indicator/hv.ts @@ -47,7 +47,7 @@ function createHVRendererPlugin(options: { paneId?: string } = {}): RendererPlug description: 'HV 历史波动率渲染器(WebGL + Canvas2D 回退)', debugName: 'HV', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/kama.ts b/packages/core/src/engine/renderers/Indicator/kama.ts index f2e02367..3474d021 100644 --- a/packages/core/src/engine/renderers/Indicator/kama.ts +++ b/packages/core/src/engine/renderers/Indicator/kama.ts @@ -50,7 +50,7 @@ function createKAMARendererPlugin(options: KAMARendererOptions = {}): RendererPl description: 'KAMA Kaufman 自适应均线渲染器(WebGL + Canvas2D 回退)', debugName: 'KAMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/keltner.ts b/packages/core/src/engine/renderers/Indicator/keltner.ts index 8832dbc5..f9c1f11a 100644 --- a/packages/core/src/engine/renderers/Indicator/keltner.ts +++ b/packages/core/src/engine/renderers/Indicator/keltner.ts @@ -54,7 +54,7 @@ function createKeltnerRendererPlugin(options: KeltnerRendererOptions = {}): Rend description: 'Keltner Channel 渲染器(WebGL + Canvas2D 回退)', debugName: 'Keltner', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/kst.ts b/packages/core/src/engine/renderers/Indicator/kst.ts index fe326212..dd0d797f 100644 --- a/packages/core/src/engine/renderers/Indicator/kst.ts +++ b/packages/core/src/engine/renderers/Indicator/kst.ts @@ -98,7 +98,7 @@ function createKSTRendererPlugin(options: KSTRendererOptions = {}): RendererPlug description: 'KST 确知指标渲染器(WebGL + Canvas2D 回退)', debugName: 'KST', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/lsma.ts b/packages/core/src/engine/renderers/Indicator/lsma.ts index c66ed74d..f653f150 100644 --- a/packages/core/src/engine/renderers/Indicator/lsma.ts +++ b/packages/core/src/engine/renderers/Indicator/lsma.ts @@ -50,7 +50,7 @@ function createLSMARendererPlugin(options: LSMARendererOptions = {}): RendererPl description: 'LSMA 线性回归移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'LSMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/mfi.ts b/packages/core/src/engine/renderers/Indicator/mfi.ts index 9cfdade3..165b0c4c 100644 --- a/packages/core/src/engine/renderers/Indicator/mfi.ts +++ b/packages/core/src/engine/renderers/Indicator/mfi.ts @@ -45,7 +45,7 @@ function createMFIRendererPlugin(options: { paneId?: string } = {}): RendererPlu description: 'MFI 资金流强弱渲染器(WebGL + Canvas2D 回退,80/20 超买超卖线)', debugName: 'MFI', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/mom.ts b/packages/core/src/engine/renderers/Indicator/mom.ts index 2feb8640..816eaeb6 100644 --- a/packages/core/src/engine/renderers/Indicator/mom.ts +++ b/packages/core/src/engine/renderers/Indicator/mom.ts @@ -147,7 +147,7 @@ function createMOMRendererPlugin(options: MOMRendererOptions = {}): RendererPlug description: 'MOM 动量指标渲染器(WebGL + Canvas2D 回退)', debugName: 'MOM', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/obv.ts b/packages/core/src/engine/renderers/Indicator/obv.ts index 869ad63c..c8bd654a 100644 --- a/packages/core/src/engine/renderers/Indicator/obv.ts +++ b/packages/core/src/engine/renderers/Indicator/obv.ts @@ -45,7 +45,7 @@ function createOBVRendererPlugin(options: { paneId?: string } = {}): RendererPlu description: 'OBV 能量潮渲染器(WebGL + Canvas2D 回退)', debugName: 'OBV', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/parkinson.ts b/packages/core/src/engine/renderers/Indicator/parkinson.ts index 75e79b2d..54810d56 100644 --- a/packages/core/src/engine/renderers/Indicator/parkinson.ts +++ b/packages/core/src/engine/renderers/Indicator/parkinson.ts @@ -47,7 +47,7 @@ function createParkinsonRendererPlugin(options: { paneId?: string } = {}): Rende description: 'Parkinson 波动率渲染器(WebGL + Canvas2D 回退)', debugName: 'Parkinson', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/pivot.ts b/packages/core/src/engine/renderers/Indicator/pivot.ts index adaea451..a60db0f0 100644 --- a/packages/core/src/engine/renderers/Indicator/pivot.ts +++ b/packages/core/src/engine/renderers/Indicator/pivot.ts @@ -52,7 +52,7 @@ function createPivotRendererPlugin(options: { paneId?: string } = {}): RendererP description: 'Pivot Points 枢轴点渲染器(PP/R1-3/S1-3 阶梯线)', debugName: 'Pivot', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/pvt.ts b/packages/core/src/engine/renderers/Indicator/pvt.ts index 8c8ef96f..412816dc 100644 --- a/packages/core/src/engine/renderers/Indicator/pvt.ts +++ b/packages/core/src/engine/renderers/Indicator/pvt.ts @@ -45,7 +45,7 @@ function createPVTRendererPlugin(options: { paneId?: string } = {}): RendererPlu description: 'PVT 量价趋势渲染器(WebGL + Canvas2D 回退)', debugName: 'PVT', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/roc.ts b/packages/core/src/engine/renderers/Indicator/roc.ts index c19a846e..052a7291 100644 --- a/packages/core/src/engine/renderers/Indicator/roc.ts +++ b/packages/core/src/engine/renderers/Indicator/roc.ts @@ -50,7 +50,7 @@ function createROCRendererPlugin(options: ROCRendererOptions = {}): RendererPlug description: 'ROC 变化率渲染器(WebGL + Canvas2D 回退)', debugName: 'ROC', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/rsi.ts b/packages/core/src/engine/renderers/Indicator/rsi.ts index e87b2d43..ff2ff13f 100644 --- a/packages/core/src/engine/renderers/Indicator/rsi.ts +++ b/packages/core/src/engine/renderers/Indicator/rsi.ts @@ -180,7 +180,7 @@ function createRSIRendererPlugin(options: RSIRendererOptions = {}): RendererPlug description: 'RSI 相对强弱指标渲染器(WebGL + Canvas2D 回退)', debugName: 'RSI', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/sar.ts b/packages/core/src/engine/renderers/Indicator/sar.ts index 1a578a48..b1b63f6c 100644 --- a/packages/core/src/engine/renderers/Indicator/sar.ts +++ b/packages/core/src/engine/renderers/Indicator/sar.ts @@ -53,7 +53,7 @@ function createSARRendererPlugin(options: SARRendererOptions = {}): RendererPlug description: 'Parabolic SAR 渲染器(绿色 = 多头止损 / 红色 = 空头止损)', debugName: 'SAR', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/smma.ts b/packages/core/src/engine/renderers/Indicator/smma.ts index d0a7d7c0..9e39ecef 100644 --- a/packages/core/src/engine/renderers/Indicator/smma.ts +++ b/packages/core/src/engine/renderers/Indicator/smma.ts @@ -65,7 +65,7 @@ function createSMMARendererPlugin(options: SMMARendererOptions = {}): RendererPl description: 'SMMA Wilder 平滑移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'SMMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/stoch.ts b/packages/core/src/engine/renderers/Indicator/stoch.ts index 0466d67d..be384dfb 100644 --- a/packages/core/src/engine/renderers/Indicator/stoch.ts +++ b/packages/core/src/engine/renderers/Indicator/stoch.ts @@ -98,7 +98,7 @@ function createSTOCHRendererPlugin(options: STOCHRendererOptions = {}): Renderer description: 'STOCH 随机指标渲染器(WebGL + Canvas2D 回退)', debugName: 'STOCH', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/structure.ts b/packages/core/src/engine/renderers/Indicator/structure.ts index 0ba8c86f..55985975 100644 --- a/packages/core/src/engine/renderers/Indicator/structure.ts +++ b/packages/core/src/engine/renderers/Indicator/structure.ts @@ -48,7 +48,7 @@ function createStructureRendererPlugin(options: { paneId?: string } = {}): Rende description: 'SMC 结构渲染器(swing 标签 + BOS/CHOCH 触发线)', debugName: 'Structure', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/supertrend.ts b/packages/core/src/engine/renderers/Indicator/supertrend.ts index 5b13a037..ca61f6f1 100644 --- a/packages/core/src/engine/renderers/Indicator/supertrend.ts +++ b/packages/core/src/engine/renderers/Indicator/supertrend.ts @@ -57,7 +57,7 @@ function createSuperTrendRendererPlugin( description: 'SuperTrend ATR 趋势带渲染器(趋势翻转处颜色切换)', debugName: 'SuperTrend', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/tema.ts b/packages/core/src/engine/renderers/Indicator/tema.ts index 90472ee6..ea80bbff 100644 --- a/packages/core/src/engine/renderers/Indicator/tema.ts +++ b/packages/core/src/engine/renderers/Indicator/tema.ts @@ -50,7 +50,7 @@ function createTEMARendererPlugin(options: TEMARendererOptions = {}): RendererPl description: 'TEMA 三重指数移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'TEMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/trima.ts b/packages/core/src/engine/renderers/Indicator/trima.ts index 5e7cebb2..eef19757 100644 --- a/packages/core/src/engine/renderers/Indicator/trima.ts +++ b/packages/core/src/engine/renderers/Indicator/trima.ts @@ -51,7 +51,7 @@ function createTRIMARendererPlugin(options: TRIMARendererOptions = {}): Renderer description: 'TRIMA 三角移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'TRIMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/trix.ts b/packages/core/src/engine/renderers/Indicator/trix.ts index 85a8cc61..0ae0a494 100644 --- a/packages/core/src/engine/renderers/Indicator/trix.ts +++ b/packages/core/src/engine/renderers/Indicator/trix.ts @@ -52,7 +52,7 @@ function createTRIXRendererPlugin(options: TRIXRendererOptions = {}): RendererPl description: 'TRIX 三重指数平滑振荡器渲染器(WebGL + Canvas2D 回退)', debugName: 'TRIX', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/vma.ts b/packages/core/src/engine/renderers/Indicator/vma.ts index 40b68062..abfc3a73 100644 --- a/packages/core/src/engine/renderers/Indicator/vma.ts +++ b/packages/core/src/engine/renderers/Indicator/vma.ts @@ -46,7 +46,7 @@ function createVMARendererPlugin(options: { paneId?: string } = {}): RendererPlu description: 'VMA 成交量均线渲染器(WebGL + Canvas2D 回退)', debugName: 'VMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/volumeProfile.ts b/packages/core/src/engine/renderers/Indicator/volumeProfile.ts index 4239606a..f8e62a6e 100644 --- a/packages/core/src/engine/renderers/Indicator/volumeProfile.ts +++ b/packages/core/src/engine/renderers/Indicator/volumeProfile.ts @@ -51,7 +51,7 @@ function createVolumeProfileRendererPlugin( description: 'Volume Profile 渲染器(POC + Value Area + 价格-成交量直方图)', debugName: 'VolumeProfile', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/vwap.ts b/packages/core/src/engine/renderers/Indicator/vwap.ts index 3bb65411..d1ca69f5 100644 --- a/packages/core/src/engine/renderers/Indicator/vwap.ts +++ b/packages/core/src/engine/renderers/Indicator/vwap.ts @@ -45,7 +45,7 @@ function createVWAPRendererPlugin(options: { paneId?: string } = {}): RendererPl description: 'VWAP 成交量加权均价渲染器(WebGL + Canvas2D 回退)', debugName: 'VWAP', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host }, diff --git a/packages/core/src/engine/renderers/Indicator/vwma.ts b/packages/core/src/engine/renderers/Indicator/vwma.ts index e142eb9d..1a0d3b3b 100644 --- a/packages/core/src/engine/renderers/Indicator/vwma.ts +++ b/packages/core/src/engine/renderers/Indicator/vwma.ts @@ -50,7 +50,7 @@ function createVWMARendererPlugin(options: VWMARendererOptions = {}): RendererPl description: 'VWMA 成交量加权移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'VWMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/wma.ts b/packages/core/src/engine/renderers/Indicator/wma.ts index e8c80ec8..86372458 100644 --- a/packages/core/src/engine/renderers/Indicator/wma.ts +++ b/packages/core/src/engine/renderers/Indicator/wma.ts @@ -50,7 +50,7 @@ function createWMARendererPlugin(options: WMARendererOptions = {}): RendererPlug description: 'WMA 线性加权移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'WMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/wmsr.ts b/packages/core/src/engine/renderers/Indicator/wmsr.ts index 5fe9be80..687d8232 100644 --- a/packages/core/src/engine/renderers/Indicator/wmsr.ts +++ b/packages/core/src/engine/renderers/Indicator/wmsr.ts @@ -169,7 +169,7 @@ function createWMSRRendererPlugin(options: WMSRRendererOptions = {}): RendererPl description: 'WMSR 威廉指标渲染器(WebGL + Canvas2D 回退)', debugName: 'WMSR', paneId: paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/zlema.ts b/packages/core/src/engine/renderers/Indicator/zlema.ts index b96eeb9a..819a8f99 100644 --- a/packages/core/src/engine/renderers/Indicator/zlema.ts +++ b/packages/core/src/engine/renderers/Indicator/zlema.ts @@ -59,7 +59,7 @@ function createZLEMARendererPlugin(options: ZLEMARendererOptions = {}): Renderer description: 'ZLEMA 零滞后指数移动均线渲染器(WebGL + Canvas2D 回退)', debugName: 'ZLEMA', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host: PluginHost) { pluginHost = host diff --git a/packages/core/src/engine/renderers/Indicator/zones.ts b/packages/core/src/engine/renderers/Indicator/zones.ts index 285ff1ac..0a578e8d 100644 --- a/packages/core/src/engine/renderers/Indicator/zones.ts +++ b/packages/core/src/engine/renderers/Indicator/zones.ts @@ -45,7 +45,7 @@ function createZonesRendererPlugin(options: { paneId?: string } = {}): RendererP description: 'SMC 区域渲染器(FVG 缺口 + Order Blocks 订单块)', debugName: 'Zones', paneId, - priority: RENDERER_PRIORITY.MAIN, + priority: RENDERER_PRIORITY.INDICATOR, onInstall(host) { pluginHost = host },