@363045841yyt/klinechart-core 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/chartSettings.d.ts +27 -2
- package/dist/config/chartSettings.d.ts.map +1 -1
- package/dist/config/chartSettings.js +6 -0
- package/dist/config/chartSettings.js.map +1 -1
- package/dist/engine/chart.d.ts.map +1 -1
- package/dist/engine/chart.js +4 -0
- package/dist/engine/chart.js.map +1 -1
- package/dist/engine/draw/pixelAlign.d.ts.map +1 -1
- package/dist/engine/draw/pixelAlign.js.map +1 -1
- package/dist/engine/drawing/plugin.js +1 -1
- package/dist/engine/drawing/plugin.js.map +1 -1
- package/dist/engine/renderers/Indicator/atr.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/atr.js +7 -4
- package/dist/engine/renderers/Indicator/atr.js.map +1 -1
- package/dist/engine/renderers/Indicator/boll.js +12 -12
- package/dist/engine/renderers/Indicator/boll.js.map +1 -1
- package/dist/engine/renderers/Indicator/cci.d.ts +1 -2
- package/dist/engine/renderers/Indicator/cci.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/cci.js +9 -9
- package/dist/engine/renderers/Indicator/cci.js.map +1 -1
- package/dist/engine/renderers/Indicator/ene.js +12 -12
- package/dist/engine/renderers/Indicator/ene.js.map +1 -1
- package/dist/engine/renderers/Indicator/expma.js +6 -6
- package/dist/engine/renderers/Indicator/expma.js.map +1 -1
- package/dist/engine/renderers/Indicator/fastk.d.ts +1 -2
- package/dist/engine/renderers/Indicator/fastk.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/fastk.js +7 -7
- package/dist/engine/renderers/Indicator/fastk.js.map +1 -1
- package/dist/engine/renderers/Indicator/kst.d.ts +1 -2
- package/dist/engine/renderers/Indicator/kst.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/kst.js +10 -10
- package/dist/engine/renderers/Indicator/kst.js.map +1 -1
- package/dist/engine/renderers/Indicator/ma.js +5 -5
- package/dist/engine/renderers/Indicator/ma.js.map +1 -1
- package/dist/engine/renderers/Indicator/macd.d.ts +1 -2
- package/dist/engine/renderers/Indicator/macd.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/macd.js +24 -24
- package/dist/engine/renderers/Indicator/macd.js.map +1 -1
- package/dist/engine/renderers/Indicator/macdLegend.js +6 -6
- package/dist/engine/renderers/Indicator/macdLegend.js.map +1 -1
- package/dist/engine/renderers/Indicator/mainIndicatorLegend.js +16 -16
- package/dist/engine/renderers/Indicator/mainIndicatorLegend.js.map +1 -1
- package/dist/engine/renderers/Indicator/mom.d.ts +1 -2
- package/dist/engine/renderers/Indicator/mom.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/mom.js +8 -8
- package/dist/engine/renderers/Indicator/mom.js.map +1 -1
- package/dist/engine/renderers/Indicator/rsi.d.ts +2 -3
- package/dist/engine/renderers/Indicator/rsi.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/rsi.js +15 -15
- package/dist/engine/renderers/Indicator/rsi.js.map +1 -1
- package/dist/engine/renderers/Indicator/scale/indicator_scale.d.ts +1 -2
- package/dist/engine/renderers/Indicator/scale/indicator_scale.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/scale/indicator_scale.js +5 -5
- package/dist/engine/renderers/Indicator/scale/indicator_scale.js.map +1 -1
- package/dist/engine/renderers/Indicator/stoch.d.ts +1 -2
- package/dist/engine/renderers/Indicator/stoch.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/stoch.js +10 -10
- package/dist/engine/renderers/Indicator/stoch.js.map +1 -1
- package/dist/engine/renderers/Indicator/structure.js +5 -5
- package/dist/engine/renderers/Indicator/structure.js.map +1 -1
- package/dist/engine/renderers/Indicator/wmsr.d.ts +1 -2
- package/dist/engine/renderers/Indicator/wmsr.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/wmsr.js +10 -10
- package/dist/engine/renderers/Indicator/wmsr.js.map +1 -1
- package/dist/engine/renderers/Indicator/zones.js +6 -6
- package/dist/engine/renderers/Indicator/zones.js.map +1 -1
- package/dist/engine/renderers/candle.d.ts +1 -1
- package/dist/engine/renderers/candle.d.ts.map +1 -1
- package/dist/engine/renderers/candle.js +21 -21
- package/dist/engine/renderers/candle.js.map +1 -1
- package/dist/engine/renderers/crosshair.js +3 -3
- package/dist/engine/renderers/crosshair.js.map +1 -1
- package/dist/engine/renderers/extremaMarkers.d.ts.map +1 -1
- package/dist/engine/renderers/extremaMarkers.js +12 -12
- package/dist/engine/renderers/extremaMarkers.js.map +1 -1
- package/dist/engine/renderers/gridLines.js +3 -3
- package/dist/engine/renderers/gridLines.js.map +1 -1
- package/dist/engine/renderers/lastPrice.js +7 -7
- package/dist/engine/renderers/lastPrice.js.map +1 -1
- package/dist/engine/renderers/paneTitle.js +6 -6
- package/dist/engine/renderers/paneTitle.js.map +1 -1
- package/dist/engine/renderers/subVolume.d.ts.map +1 -1
- package/dist/engine/renderers/subVolume.js +23 -20
- package/dist/engine/renderers/subVolume.js.map +1 -1
- package/dist/engine/renderers/timeAxis.js +9 -9
- package/dist/engine/renderers/timeAxis.js.map +1 -1
- package/dist/engine/renderers/webgl/candleSurface.d.ts.map +1 -1
- package/dist/engine/renderers/webgl/candleSurface.js +39 -7
- package/dist/engine/renderers/webgl/candleSurface.js.map +1 -1
- package/dist/engine/renderers/yAxis.d.ts.map +1 -1
- package/dist/engine/renderers/yAxis.js +5 -5
- package/dist/engine/renderers/yAxis.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/types.d.ts +5 -1
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js.map +1 -1
- package/dist/tokens/colorPresetSettings.d.ts +15 -0
- package/dist/tokens/colorPresetSettings.d.ts.map +1 -0
- package/dist/tokens/colorPresetSettings.js +65 -0
- package/dist/tokens/colorPresetSettings.js.map +1 -0
- package/dist/tokens/index.d.ts +17 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +16 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/mergeTheme.d.ts +17 -0
- package/dist/tokens/mergeTheme.d.ts.map +1 -0
- package/dist/tokens/mergeTheme.js +43 -0
- package/dist/tokens/mergeTheme.js.map +1 -0
- package/dist/tokens/theme-china.d.ts +45 -0
- package/dist/tokens/theme-china.d.ts.map +1 -0
- package/dist/tokens/theme-china.js +116 -0
- package/dist/tokens/theme-china.js.map +1 -0
- package/dist/tokens/theme-dark.d.ts +21 -0
- package/dist/tokens/theme-dark.d.ts.map +1 -0
- package/dist/tokens/theme-dark.js +228 -0
- package/dist/tokens/theme-dark.js.map +1 -0
- package/dist/tokens/theme-light.d.ts +23 -0
- package/dist/tokens/theme-light.d.ts.map +1 -0
- package/dist/tokens/theme-light.js +234 -0
- package/dist/tokens/theme-light.js.map +1 -0
- package/dist/tokens/themeToCssVars.d.ts +74 -0
- package/dist/tokens/themeToCssVars.d.ts.map +1 -0
- package/dist/tokens/themeToCssVars.js +108 -0
- package/dist/tokens/themeToCssVars.js.map +1 -0
- package/dist/tokens/types.d.ts +335 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/dist/tokens/types.js +20 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/utils/kLineDraw/axis.d.ts +8 -7
- package/dist/utils/kLineDraw/axis.d.ts.map +1 -1
- package/dist/utils/kLineDraw/axis.js +24 -24
- package/dist/utils/kLineDraw/axis.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/config/chartSettings.ts +11 -2
- package/src/engine/chart.ts +4 -0
- package/src/engine/draw/pixelAlign.ts +0 -2
- package/src/engine/drawing/plugin.ts +1 -1
- package/src/engine/renderers/Indicator/atr.ts +7 -3
- package/src/engine/renderers/Indicator/boll.ts +12 -12
- package/src/engine/renderers/Indicator/cci.ts +11 -10
- package/src/engine/renderers/Indicator/ene.ts +12 -12
- package/src/engine/renderers/Indicator/expma.ts +6 -6
- package/src/engine/renderers/Indicator/fastk.ts +9 -8
- package/src/engine/renderers/Indicator/kst.ts +12 -11
- package/src/engine/renderers/Indicator/ma.ts +5 -5
- package/src/engine/renderers/Indicator/macd.ts +27 -25
- package/src/engine/renderers/Indicator/macdLegend.ts +6 -6
- package/src/engine/renderers/Indicator/mainIndicatorLegend.ts +16 -16
- package/src/engine/renderers/Indicator/mom.ts +11 -10
- package/src/engine/renderers/Indicator/rsi.ts +18 -15
- package/src/engine/renderers/Indicator/scale/indicator_scale.ts +6 -6
- package/src/engine/renderers/Indicator/stoch.ts +12 -11
- package/src/engine/renderers/Indicator/structure.ts +5 -5
- package/src/engine/renderers/Indicator/wmsr.ts +13 -12
- package/src/engine/renderers/Indicator/zones.ts +7 -7
- package/src/engine/renderers/candle.ts +21 -21
- package/src/engine/renderers/crosshair.ts +3 -3
- package/src/engine/renderers/extremaMarkers.ts +13 -12
- package/src/engine/renderers/gridLines.ts +3 -3
- package/src/engine/renderers/lastPrice.ts +7 -7
- package/src/engine/renderers/paneTitle.ts +6 -6
- package/src/engine/renderers/subVolume.ts +23 -20
- package/src/engine/renderers/timeAxis.ts +9 -9
- package/src/engine/renderers/webgl/candleSurface.ts +43 -7
- package/src/engine/renderers/yAxis.ts +6 -5
- package/src/index.ts +1 -0
- package/src/plugin/types.ts +5 -1
- package/src/tokens/__tests__/__snapshots__/baseline.test.ts.snap +393 -0
- package/src/tokens/__tests__/baseline.test.ts +183 -0
- package/src/tokens/__tests__/themeToCssVars.test.ts +175 -0
- package/src/tokens/__tests__/tokens.test.ts +215 -0
- package/src/tokens/colorPresetSettings.ts +128 -0
- package/src/tokens/index.ts +65 -0
- package/src/tokens/mergeTheme.ts +48 -0
- package/src/tokens/theme-china.ts +132 -0
- package/src/tokens/theme-dark.ts +244 -0
- package/src/tokens/theme-light.ts +250 -0
- package/src/tokens/themeToCssVars.ts +138 -0
- package/src/tokens/types.ts +394 -0
- package/src/utils/kLineDraw/axis.ts +31 -30
- package/src/version.ts +1 -1
- package/dist/engine/theme/colors.d.ts +0 -223
- package/dist/engine/theme/colors.d.ts.map +0 -1
- package/dist/engine/theme/colors.js +0 -375
- package/dist/engine/theme/colors.js.map +0 -1
- package/src/engine/theme/colors.ts +0 -642
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, RenderContext, PluginHost } from '../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../plugin'
|
|
3
3
|
import type { KLineData } from '../../../types/price'
|
|
4
|
-
import {
|
|
5
|
-
import type { ChartTheme, ThemeColors } from '../../theme/colors'
|
|
4
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
6
5
|
import { alignToPhysicalPixelCenter } from '../../draw/pixelAlign'
|
|
7
6
|
import type { MACDRenderState } from '../../indicators/macdState'
|
|
8
7
|
import { createMACDStateKey } from '../../indicators/macdState'
|
|
@@ -131,7 +130,7 @@ export function createMACDRendererPlugin(options: MACDRendererOptions = {}): Ren
|
|
|
131
130
|
draw(context: RenderContext) {
|
|
132
131
|
const { ctx, pane, data, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = context
|
|
133
132
|
const klineData = data as KLineData[]
|
|
134
|
-
const colors =
|
|
133
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
135
134
|
|
|
136
135
|
// 从 StateStore 读取 MACD 状态
|
|
137
136
|
const stateKey = resolveKey()
|
|
@@ -214,7 +213,7 @@ export function createMACDRendererPlugin(options: MACDRendererOptions = {}): Ren
|
|
|
214
213
|
|
|
215
214
|
const usedWebGL = drawMacdBarsWithWebGL(context, barUpBuf, barUpCount, barUpLightBuf, barUpLightCount, barDownBuf, barDownCount, barDownLightBuf, barDownLightCount)
|
|
216
215
|
if (!usedWebGL) {
|
|
217
|
-
drawMacdBarsWithCanvas2D(ctx, scrollLeft, colors, barUpBuf, barUpCount, barUpLightBuf, barUpLightCount, barDownBuf, barDownCount, barDownLightBuf, barDownLightCount)
|
|
216
|
+
drawMacdBarsWithCanvas2D(ctx, scrollLeft, colors.macd.barUp, colors.macd.barUpLight, colors.macd.barDown, colors.macd.barDownLight, barUpBuf, barUpCount, barUpLightBuf, barUpLightCount, barDownBuf, barDownCount, barDownLightBuf, barDownLightCount)
|
|
218
217
|
} else {
|
|
219
218
|
compositeMacdWebGL(ctx, context)
|
|
220
219
|
}
|
|
@@ -256,10 +255,10 @@ export function createMACDRendererPlugin(options: MACDRendererOptions = {}): Ren
|
|
|
256
255
|
if (enableWebGL && lineWebGLSurface?.isAvailable()) {
|
|
257
256
|
const lines: Array<{ points: LinePoint[]; width: number; color: string }> = []
|
|
258
257
|
if (config.showDIF && cachedDifPoints.length >= 2) {
|
|
259
|
-
lines.push({ points: cachedDifPoints, width: 1, color: colors.
|
|
258
|
+
lines.push({ points: cachedDifPoints, width: 1, color: colors.macd.dif })
|
|
260
259
|
}
|
|
261
260
|
if (config.showDEA && cachedDeaPoints.length >= 2) {
|
|
262
|
-
lines.push({ points: cachedDeaPoints, width: 1, color: colors.
|
|
261
|
+
lines.push({ points: cachedDeaPoints, width: 1, color: colors.macd.dea })
|
|
263
262
|
}
|
|
264
263
|
const allOk = lines.length > 0 && lineWebGLSurface.drawLineStrips(lines, scrollLeft)
|
|
265
264
|
if (allOk) {
|
|
@@ -269,7 +268,7 @@ export function createMACDRendererPlugin(options: MACDRendererOptions = {}): Ren
|
|
|
269
268
|
}
|
|
270
269
|
|
|
271
270
|
if (!usedWebGLForLines) {
|
|
272
|
-
drawMacdLinesWithCanvas2D(ctx, scrollLeft, colors, cachedDifPoints, cachedDeaPoints, config)
|
|
271
|
+
drawMacdLinesWithCanvas2D(ctx, scrollLeft, colors.macd.dif, colors.macd.dea, cachedDifPoints, cachedDeaPoints, config)
|
|
273
272
|
}
|
|
274
273
|
},
|
|
275
274
|
|
|
@@ -313,17 +312,17 @@ function drawMacdBarsWithWebGL(
|
|
|
313
312
|
barDownBuf: Float32Array, barDownCount: number,
|
|
314
313
|
barDownLightBuf: Float32Array, barDownLightCount: number
|
|
315
314
|
): boolean {
|
|
316
|
-
const colors =
|
|
315
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
317
316
|
if (context.settings?.enableWebGLRendering === false) return false
|
|
318
317
|
const surface = context.candleWebGLSurface
|
|
319
318
|
if (!surface || !surface.isAvailable()) return false
|
|
320
319
|
|
|
321
320
|
surface.clear()
|
|
322
321
|
|
|
323
|
-
const ok1 = barUpCount === 0 || surface.drawRectBuffer(barUpBuf.subarray(0, barUpCount * 4), barUpCount, colors.
|
|
324
|
-
const ok2 = barUpLightCount === 0 || surface.drawRectBuffer(barUpLightBuf.subarray(0, barUpLightCount * 4), barUpLightCount, colors.
|
|
325
|
-
const ok3 = barDownCount === 0 || surface.drawRectBuffer(barDownBuf.subarray(0, barDownCount * 4), barDownCount, colors.
|
|
326
|
-
const ok4 = barDownLightCount === 0 || surface.drawRectBuffer(barDownLightBuf.subarray(0, barDownLightCount * 4), barDownLightCount, colors.
|
|
322
|
+
const ok1 = barUpCount === 0 || surface.drawRectBuffer(barUpBuf.subarray(0, barUpCount * 4), barUpCount, colors.macd.barUp, context.scrollLeft)
|
|
323
|
+
const ok2 = barUpLightCount === 0 || surface.drawRectBuffer(barUpLightBuf.subarray(0, barUpLightCount * 4), barUpLightCount, colors.macd.barUpLight, context.scrollLeft)
|
|
324
|
+
const ok3 = barDownCount === 0 || surface.drawRectBuffer(barDownBuf.subarray(0, barDownCount * 4), barDownCount, colors.macd.barDown, context.scrollLeft)
|
|
325
|
+
const ok4 = barDownLightCount === 0 || surface.drawRectBuffer(barDownLightBuf.subarray(0, barDownLightCount * 4), barDownLightCount, colors.macd.barDownLight, context.scrollLeft)
|
|
327
326
|
|
|
328
327
|
return ok1 && ok2 && ok3 && ok4
|
|
329
328
|
}
|
|
@@ -331,7 +330,8 @@ function drawMacdBarsWithWebGL(
|
|
|
331
330
|
function drawMacdBarsWithCanvas2D(
|
|
332
331
|
ctx: CanvasRenderingContext2D,
|
|
333
332
|
scrollLeft: number,
|
|
334
|
-
|
|
333
|
+
barUpColor: string, barUpLightColor: string,
|
|
334
|
+
barDownColor: string, barDownLightColor: string,
|
|
335
335
|
barUpBuf: Float32Array, barUpCount: number,
|
|
336
336
|
barUpLightBuf: Float32Array, barUpLightCount: number,
|
|
337
337
|
barDownBuf: Float32Array, barDownCount: number,
|
|
@@ -340,25 +340,25 @@ function drawMacdBarsWithCanvas2D(
|
|
|
340
340
|
ctx.save()
|
|
341
341
|
ctx.translate(-scrollLeft, 0)
|
|
342
342
|
|
|
343
|
-
ctx.fillStyle =
|
|
343
|
+
ctx.fillStyle = barUpColor
|
|
344
344
|
for (let i = 0; i < barUpCount; i++) {
|
|
345
345
|
const off = i * 4
|
|
346
346
|
ctx.fillRect(barUpBuf[off], barUpBuf[off + 1], barUpBuf[off + 2], barUpBuf[off + 3])
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
ctx.fillStyle =
|
|
349
|
+
ctx.fillStyle = barUpLightColor
|
|
350
350
|
for (let i = 0; i < barUpLightCount; i++) {
|
|
351
351
|
const off = i * 4
|
|
352
352
|
ctx.fillRect(barUpLightBuf[off], barUpLightBuf[off + 1], barUpLightBuf[off + 2], barUpLightBuf[off + 3])
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
ctx.fillStyle =
|
|
355
|
+
ctx.fillStyle = barDownColor
|
|
356
356
|
for (let i = 0; i < barDownCount; i++) {
|
|
357
357
|
const off = i * 4
|
|
358
358
|
ctx.fillRect(barDownBuf[off], barDownBuf[off + 1], barDownBuf[off + 2], barDownBuf[off + 3])
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
ctx.fillStyle =
|
|
361
|
+
ctx.fillStyle = barDownLightColor
|
|
362
362
|
for (let i = 0; i < barDownLightCount; i++) {
|
|
363
363
|
const off = i * 4
|
|
364
364
|
ctx.fillRect(barDownLightBuf[off], barDownLightBuf[off + 1], barDownLightBuf[off + 2], barDownLightBuf[off + 3])
|
|
@@ -370,7 +370,8 @@ function drawMacdBarsWithCanvas2D(
|
|
|
370
370
|
function drawMacdLinesWithCanvas2D(
|
|
371
371
|
ctx: CanvasRenderingContext2D,
|
|
372
372
|
scrollLeft: number,
|
|
373
|
-
|
|
373
|
+
difColor: string,
|
|
374
|
+
deaColor: string,
|
|
374
375
|
difPoints: LinePoint[],
|
|
375
376
|
deaPoints: LinePoint[],
|
|
376
377
|
config: { showDIF: boolean; showDEA: boolean }
|
|
@@ -382,7 +383,7 @@ function drawMacdLinesWithCanvas2D(
|
|
|
382
383
|
ctx.lineCap = 'round'
|
|
383
384
|
|
|
384
385
|
if (config.showDIF && difPoints.length >= 2) {
|
|
385
|
-
ctx.strokeStyle =
|
|
386
|
+
ctx.strokeStyle = difColor
|
|
386
387
|
ctx.beginPath()
|
|
387
388
|
ctx.moveTo(difPoints[0]!.x, difPoints[0]!.y)
|
|
388
389
|
for (let i = 1; i < difPoints.length; i++) {
|
|
@@ -393,7 +394,7 @@ function drawMacdLinesWithCanvas2D(
|
|
|
393
394
|
}
|
|
394
395
|
|
|
395
396
|
if (config.showDEA && deaPoints.length >= 2) {
|
|
396
|
-
ctx.strokeStyle =
|
|
397
|
+
ctx.strokeStyle = deaColor
|
|
397
398
|
ctx.beginPath()
|
|
398
399
|
ctx.moveTo(deaPoints[0]!.x, deaPoints[0]!.y)
|
|
399
400
|
for (let i = 1; i < deaPoints.length; i++) {
|
|
@@ -441,9 +442,10 @@ export function getMACDTitleInfo(
|
|
|
441
442
|
signalPeriod: number,
|
|
442
443
|
pluginHost: PluginHost,
|
|
443
444
|
paneId: string = 'sub_MACD',
|
|
444
|
-
theme:
|
|
445
|
+
theme: 'light' | 'dark' = 'light',
|
|
446
|
+
isAsiaMarket?: boolean
|
|
445
447
|
): { name: string; params: number[]; values: Array<{ label: string; value: number; color: string }> } | null {
|
|
446
|
-
const colors =
|
|
448
|
+
const colors = resolveThemeColors(theme, isAsiaMarket)
|
|
447
449
|
const state = pluginHost.getSharedState<MACDRenderState>(createMACDStateKey(paneId))
|
|
448
450
|
if (!state) return null
|
|
449
451
|
|
|
@@ -454,9 +456,9 @@ export function getMACDTitleInfo(
|
|
|
454
456
|
name: 'MACD',
|
|
455
457
|
params: [fastPeriod, slowPeriod, signalPeriod],
|
|
456
458
|
values: [
|
|
457
|
-
{ label: 'DIF', value: point.dif, color: colors.
|
|
458
|
-
{ label: 'DEA', value: point.dea, color: colors.
|
|
459
|
-
{ label: 'MACD', value: point.macd, color: point.macd >= 0 ? colors.
|
|
459
|
+
{ label: 'DIF', value: point.dif, color: colors.macd.dif },
|
|
460
|
+
{ label: 'DEA', value: point.dea, color: colors.macd.dea },
|
|
461
|
+
{ label: 'MACD', value: point.macd, color: point.macd >= 0 ? colors.macd.barUp : colors.macd.barDown },
|
|
460
462
|
],
|
|
461
463
|
}
|
|
462
464
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, PluginHost, RenderContext } from '../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
4
4
|
import { getFont, setCanvasFont } from '../../theme/fonts'
|
|
5
5
|
import type { MACDRenderState } from '../../indicators/macdState'
|
|
6
6
|
import { createMACDStateKey } from '../../indicators/macdState'
|
|
@@ -59,7 +59,7 @@ export function createMACDLegendRendererPlugin(options: MACDLegendOptions = {}):
|
|
|
59
59
|
|
|
60
60
|
draw(context: RenderContext) {
|
|
61
61
|
const { ctx, range } = context
|
|
62
|
-
const colors =
|
|
62
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
63
63
|
|
|
64
64
|
// 从 StateStore 读取 MACD 状态
|
|
65
65
|
const state = pluginHost?.getSharedState<MACDRenderState>(stateKey)
|
|
@@ -103,22 +103,22 @@ export function createMACDLegendRendererPlugin(options: MACDLegendOptions = {}):
|
|
|
103
103
|
ctx.textBaseline = 'top'
|
|
104
104
|
|
|
105
105
|
const paramText = `MACD(${fastPeriod},${slowPeriod},${signalPeriod})`
|
|
106
|
-
ctx.fillStyle = colors.
|
|
106
|
+
ctx.fillStyle = colors.text.tertiary
|
|
107
107
|
ctx.fillText(paramText, x, y)
|
|
108
108
|
x += measureTextWidth(ctx, paramText) + gap
|
|
109
109
|
|
|
110
110
|
const difText = `DIF:${macdValue.dif.toFixed(2)}`
|
|
111
|
-
ctx.fillStyle = colors.
|
|
111
|
+
ctx.fillStyle = colors.macd.dif
|
|
112
112
|
ctx.fillText(difText, x, y)
|
|
113
113
|
x += measureTextWidth(ctx, difText) + gap
|
|
114
114
|
|
|
115
115
|
const deaText = `DEA:${macdValue.dea.toFixed(2)}`
|
|
116
|
-
ctx.fillStyle = colors.
|
|
116
|
+
ctx.fillStyle = colors.macd.dea
|
|
117
117
|
ctx.fillText(deaText, x, y)
|
|
118
118
|
x += measureTextWidth(ctx, deaText) + gap
|
|
119
119
|
|
|
120
120
|
const macdText = `MACD:${macdValue.macd.toFixed(2)}`
|
|
121
|
-
ctx.fillStyle = macdValue.macd >= 0 ? colors.
|
|
121
|
+
ctx.fillStyle = macdValue.macd >= 0 ? colors.macd.barUp : colors.macd.barDown
|
|
122
122
|
ctx.fillText(macdText, x, y)
|
|
123
123
|
|
|
124
124
|
ctx.restore()
|
|
@@ -5,7 +5,7 @@ import { MA_STATE_KEY, type MARenderState } from '../../indicators/maState'
|
|
|
5
5
|
import { BOLL_STATE_KEY, type BOLLRenderState } from '../../indicators/bollState'
|
|
6
6
|
import { EXPMA_STATE_KEY, type EXPMARenderState } from '../../indicators/expmaState'
|
|
7
7
|
import { ENE_STATE_KEY, type ENERenderState } from '../../indicators/eneState'
|
|
8
|
-
import {
|
|
8
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
9
9
|
import { getFont, setCanvasFont } from '../../theme/fonts'
|
|
10
10
|
|
|
11
11
|
const textWidthCache = new Map<string, number>()
|
|
@@ -80,7 +80,7 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
80
80
|
draw(context: RenderContext) {
|
|
81
81
|
const { overlayCtx, data, range, crosshairIndex } = context
|
|
82
82
|
const klineData = data as KLineData[]
|
|
83
|
-
const colors =
|
|
83
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
84
84
|
if (!klineData.length || !overlayCtx) return
|
|
85
85
|
|
|
86
86
|
const fontSize = 12
|
|
@@ -104,13 +104,13 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
104
104
|
|
|
105
105
|
if (state && state.visibleMin <= state.visibleMax) {
|
|
106
106
|
for (const period of state.enabledPeriods) {
|
|
107
|
-
const colorKey = `
|
|
107
|
+
const colorKey = `ma${period}` as keyof typeof colors.ma
|
|
108
108
|
const series = state.series[period]
|
|
109
109
|
const value = series?.[targetIndex]
|
|
110
110
|
|
|
111
111
|
items.push({
|
|
112
112
|
label: `MA${period}`,
|
|
113
|
-
color: colors.
|
|
113
|
+
color: colors.ma[colorKey] || colors.ma.ma5,
|
|
114
114
|
value: value,
|
|
115
115
|
})
|
|
116
116
|
}
|
|
@@ -120,7 +120,7 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
120
120
|
let x = legendX
|
|
121
121
|
const y = config.yPaddingPx / 2 + fontSize + rowIndex * lineHeight
|
|
122
122
|
|
|
123
|
-
overlayCtx.fillStyle = colors.
|
|
123
|
+
overlayCtx.fillStyle = colors.text.primary
|
|
124
124
|
overlayCtx.fillText('MA', x, y)
|
|
125
125
|
x += measureTextWidth(overlayCtx, 'MA') + gap
|
|
126
126
|
|
|
@@ -149,23 +149,23 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
149
149
|
const y = config.yPaddingPx / 2 + fontSize + rowIndex * lineHeight
|
|
150
150
|
const titleText = `BOLL(${period},${multiplier})`
|
|
151
151
|
|
|
152
|
-
overlayCtx.fillStyle = colors.
|
|
152
|
+
overlayCtx.fillStyle = colors.text.primary
|
|
153
153
|
overlayCtx.fillText(titleText, x, y)
|
|
154
154
|
x += measureTextWidth(overlayCtx, titleText) + gap
|
|
155
155
|
|
|
156
156
|
if (boll) {
|
|
157
157
|
const upperText = `上轨:${boll.upper.toFixed(2)}`
|
|
158
|
-
overlayCtx.fillStyle = colors.
|
|
158
|
+
overlayCtx.fillStyle = colors.boll.upper
|
|
159
159
|
overlayCtx.fillText(upperText, x, y)
|
|
160
160
|
x += measureTextWidth(overlayCtx, upperText) + gap
|
|
161
161
|
|
|
162
162
|
const middleText = `中轨:${boll.middle.toFixed(2)}`
|
|
163
|
-
overlayCtx.fillStyle = colors.
|
|
163
|
+
overlayCtx.fillStyle = colors.boll.middle
|
|
164
164
|
overlayCtx.fillText(middleText, x, y)
|
|
165
165
|
x += measureTextWidth(overlayCtx, middleText) + gap
|
|
166
166
|
|
|
167
167
|
const lowerText = `下轨:${boll.lower.toFixed(2)}`
|
|
168
|
-
overlayCtx.fillStyle = colors.
|
|
168
|
+
overlayCtx.fillStyle = colors.boll.lower
|
|
169
169
|
overlayCtx.fillText(lowerText, x, y)
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -185,18 +185,18 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
185
185
|
const y = config.yPaddingPx / 2 + fontSize + rowIndex * lineHeight
|
|
186
186
|
const titleText = `EXPMA(${fastPeriod},${slowPeriod})`
|
|
187
187
|
|
|
188
|
-
overlayCtx.fillStyle = colors.
|
|
188
|
+
overlayCtx.fillStyle = colors.text.primary
|
|
189
189
|
overlayCtx.fillText(titleText, x, y)
|
|
190
190
|
x += measureTextWidth(overlayCtx, titleText) + gap
|
|
191
191
|
|
|
192
192
|
if (expma) {
|
|
193
193
|
const fastText = `快:${expma.fast.toFixed(2)}`
|
|
194
|
-
overlayCtx.fillStyle = colors.
|
|
194
|
+
overlayCtx.fillStyle = colors.expma.fast
|
|
195
195
|
overlayCtx.fillText(fastText, x, y)
|
|
196
196
|
x += measureTextWidth(overlayCtx, fastText) + gap
|
|
197
197
|
|
|
198
198
|
const slowText = `慢:${expma.slow.toFixed(2)}`
|
|
199
|
-
overlayCtx.fillStyle = colors.
|
|
199
|
+
overlayCtx.fillStyle = colors.expma.slow
|
|
200
200
|
overlayCtx.fillText(slowText, x, y)
|
|
201
201
|
}
|
|
202
202
|
}
|
|
@@ -216,23 +216,23 @@ export function createMainIndicatorLegendRendererPlugin(options: {
|
|
|
216
216
|
const y = config.yPaddingPx / 2 + fontSize + rowIndex * lineHeight
|
|
217
217
|
const titleText = `ENE(${period},${deviation})`
|
|
218
218
|
|
|
219
|
-
overlayCtx.fillStyle = colors.
|
|
219
|
+
overlayCtx.fillStyle = colors.text.primary
|
|
220
220
|
overlayCtx.fillText(titleText, x, y)
|
|
221
221
|
x += measureTextWidth(overlayCtx, titleText) + gap
|
|
222
222
|
|
|
223
223
|
if (ene) {
|
|
224
224
|
const upperText = `上轨:${ene.upper.toFixed(2)}`
|
|
225
|
-
overlayCtx.fillStyle = colors.
|
|
225
|
+
overlayCtx.fillStyle = colors.ene.upper
|
|
226
226
|
overlayCtx.fillText(upperText, x, y)
|
|
227
227
|
x += measureTextWidth(overlayCtx, upperText) + gap
|
|
228
228
|
|
|
229
229
|
const middleText = `中轨:${ene.middle.toFixed(2)}`
|
|
230
|
-
overlayCtx.fillStyle = colors.
|
|
230
|
+
overlayCtx.fillStyle = colors.ene.middle
|
|
231
231
|
overlayCtx.fillText(middleText, x, y)
|
|
232
232
|
x += measureTextWidth(overlayCtx, middleText) + gap
|
|
233
233
|
|
|
234
234
|
const lowerText = `下轨:${ene.lower.toFixed(2)}`
|
|
235
|
-
overlayCtx.fillStyle = colors.
|
|
235
|
+
overlayCtx.fillStyle = colors.ene.lower
|
|
236
236
|
overlayCtx.fillText(lowerText, x, y)
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, RenderContext, PluginHost } from '../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
4
4
|
import { alignToPhysicalPixelCenter } from '../../draw/pixelAlign'
|
|
5
5
|
import type { MOMRenderState } from '../../indicators/momState'
|
|
6
6
|
import { createMOMStateKey } from '../../indicators/momState'
|
|
@@ -82,7 +82,7 @@ export function createMOMRendererPlugin(options: MOMRendererOptions = {}): Rende
|
|
|
82
82
|
displayMin: number,
|
|
83
83
|
displayMax: number,
|
|
84
84
|
dpr: number,
|
|
85
|
-
colors: {
|
|
85
|
+
colors: { mom: { zero: string } }
|
|
86
86
|
): void {
|
|
87
87
|
const displayValueRange = displayMax - displayMin || 1
|
|
88
88
|
const zeroY = alignToPhysicalPixelCenter(paneHeight - (0 - displayMin) / displayValueRange * paneHeight, dpr)
|
|
@@ -90,7 +90,7 @@ export function createMOMRendererPlugin(options: MOMRendererOptions = {}): Rende
|
|
|
90
90
|
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height)
|
|
91
91
|
ctx.save()
|
|
92
92
|
ctx.scale(dpr, dpr)
|
|
93
|
-
ctx.strokeStyle = colors.
|
|
93
|
+
ctx.strokeStyle = colors.mom.zero
|
|
94
94
|
ctx.lineWidth = 1
|
|
95
95
|
ctx.beginPath()
|
|
96
96
|
ctx.moveTo(0, zeroY)
|
|
@@ -143,7 +143,7 @@ export function createMOMRendererPlugin(options: MOMRendererOptions = {}): Rende
|
|
|
143
143
|
|
|
144
144
|
draw(context: RenderContext) {
|
|
145
145
|
const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = context
|
|
146
|
-
const colors =
|
|
146
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
147
147
|
|
|
148
148
|
const stateKey = resolveKey()
|
|
149
149
|
if (!stateKey) return
|
|
@@ -213,7 +213,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
213
213
|
if (enableWebGL && lineWebGLSurface?.isAvailable()) {
|
|
214
214
|
if (params.showMOM && cachedMOMPoints.length >= 2) {
|
|
215
215
|
const ok = lineWebGLSurface.drawLineStrips(
|
|
216
|
-
[{ points: cachedMOMPoints, width: 1, color: colors.
|
|
216
|
+
[{ points: cachedMOMPoints, width: 1, color: colors.mom.mom }],
|
|
217
217
|
scrollLeft
|
|
218
218
|
)
|
|
219
219
|
if (ok) {
|
|
@@ -249,13 +249,13 @@ function drawMOMLineWithCanvas2D(
|
|
|
249
249
|
scrollLeft: number,
|
|
250
250
|
momPoints: LinePoint[],
|
|
251
251
|
params: { showMOM: boolean },
|
|
252
|
-
colors: {
|
|
252
|
+
colors: { mom: { mom: string } }
|
|
253
253
|
): void {
|
|
254
254
|
if (!params.showMOM || momPoints.length < 2) return
|
|
255
255
|
|
|
256
256
|
ctx.save()
|
|
257
257
|
ctx.translate(-scrollLeft, 0)
|
|
258
|
-
ctx.strokeStyle = colors.
|
|
258
|
+
ctx.strokeStyle = colors.mom.mom
|
|
259
259
|
ctx.lineWidth = 1
|
|
260
260
|
ctx.lineJoin = 'round'
|
|
261
261
|
ctx.lineCap = 'round'
|
|
@@ -277,9 +277,10 @@ export function getMOMTitleInfo(
|
|
|
277
277
|
period: number,
|
|
278
278
|
pluginHost: PluginHost,
|
|
279
279
|
paneId: string = 'sub_MOM',
|
|
280
|
-
theme:
|
|
280
|
+
theme: 'light' | 'dark' = 'light',
|
|
281
|
+
isAsiaMarket?: boolean
|
|
281
282
|
): { name: string; params: number[]; values: Array<{ label: string; value: number; color: string }> } | null {
|
|
282
|
-
const colors =
|
|
283
|
+
const colors = resolveThemeColors(theme, isAsiaMarket)
|
|
283
284
|
const state = pluginHost.getSharedState<MOMRenderState>(createMOMStateKey(paneId))
|
|
284
285
|
if (!state) return null
|
|
285
286
|
|
|
@@ -290,7 +291,7 @@ export function getMOMTitleInfo(
|
|
|
290
291
|
name: 'MOM',
|
|
291
292
|
params: [period],
|
|
292
293
|
values: [
|
|
293
|
-
{ label: 'MOM', value: mom, color: colors.
|
|
294
|
+
{ label: 'MOM', value: mom, color: colors.mom.mom },
|
|
294
295
|
],
|
|
295
296
|
}
|
|
296
297
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, RenderContext, PluginHost } from '../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
4
4
|
import { alignToPhysicalPixelCenter } from '../../draw/pixelAlign'
|
|
5
5
|
import type { RSIRenderState } from '../../indicators/rsiState'
|
|
6
6
|
import { createRSIStateKey } from '../../indicators/rsiState'
|
|
@@ -168,7 +168,7 @@ export function createRSIRendererPlugin(options: RSIRendererOptions = {}): Rende
|
|
|
168
168
|
|
|
169
169
|
draw(context: RenderContext) {
|
|
170
170
|
const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = context
|
|
171
|
-
const colors =
|
|
171
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
172
172
|
|
|
173
173
|
// 从 StateStore 读取 RSI 状态
|
|
174
174
|
const stateKey = resolveKey()
|
|
@@ -251,13 +251,13 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
251
251
|
if (enableWebGL && lineWebGLSurface?.isAvailable()) {
|
|
252
252
|
const lines: Array<{ points: LinePoint[]; width: number; color: string }> = []
|
|
253
253
|
if (params.showRSI1 && cachedRSI1Points.length >= 2) {
|
|
254
|
-
lines.push({ points: cachedRSI1Points, width: 1, color: colors.
|
|
254
|
+
lines.push({ points: cachedRSI1Points, width: 1, color: colors.rsi.rsi1 })
|
|
255
255
|
}
|
|
256
256
|
if (params.showRSI2 && cachedRSI2Points.length >= 2) {
|
|
257
|
-
lines.push({ points: cachedRSI2Points, width: 1, color: colors.
|
|
257
|
+
lines.push({ points: cachedRSI2Points, width: 1, color: colors.rsi.rsi2 })
|
|
258
258
|
}
|
|
259
259
|
if (params.showRSI3 && cachedRSI3Points.length >= 2) {
|
|
260
|
-
lines.push({ points: cachedRSI3Points, width: 1, color: colors.
|
|
260
|
+
lines.push({ points: cachedRSI3Points, width: 1, color: colors.rsi.rsi3 })
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
const allOk = lines.length > 0 && lineWebGLSurface.drawLineStrips(lines, scrollLeft)
|
|
@@ -269,7 +269,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
if (!usedWebGL) {
|
|
272
|
-
drawRSILinesWithCanvas2D(ctx, scrollLeft, cachedRSI1Points, cachedRSI2Points, cachedRSI3Points, params, colors)
|
|
272
|
+
drawRSILinesWithCanvas2D(ctx, scrollLeft, cachedRSI1Points, cachedRSI2Points, cachedRSI3Points, params, colors.rsi.rsi1, colors.rsi.rsi2, colors.rsi.rsi3)
|
|
273
273
|
}
|
|
274
274
|
},
|
|
275
275
|
|
|
@@ -297,7 +297,9 @@ export function drawRSILinesWithCanvas2D(
|
|
|
297
297
|
rsi2Points: LinePoint[],
|
|
298
298
|
rsi3Points: LinePoint[],
|
|
299
299
|
params: { showRSI1: boolean; showRSI2: boolean; showRSI3: boolean },
|
|
300
|
-
|
|
300
|
+
rsi1Color: string,
|
|
301
|
+
rsi2Color: string,
|
|
302
|
+
rsi3Color: string
|
|
301
303
|
): void {
|
|
302
304
|
ctx.save()
|
|
303
305
|
ctx.translate(-scrollLeft, 0)
|
|
@@ -306,7 +308,7 @@ export function drawRSILinesWithCanvas2D(
|
|
|
306
308
|
ctx.lineCap = 'round'
|
|
307
309
|
|
|
308
310
|
if (params.showRSI1 && rsi1Points.length >= 2) {
|
|
309
|
-
ctx.strokeStyle =
|
|
311
|
+
ctx.strokeStyle = rsi1Color
|
|
310
312
|
ctx.beginPath()
|
|
311
313
|
ctx.moveTo(rsi1Points[0]!.x, rsi1Points[0]!.y)
|
|
312
314
|
for (let i = 1; i < rsi1Points.length; i++) {
|
|
@@ -317,7 +319,7 @@ export function drawRSILinesWithCanvas2D(
|
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
if (params.showRSI2 && rsi2Points.length >= 2) {
|
|
320
|
-
ctx.strokeStyle =
|
|
322
|
+
ctx.strokeStyle = rsi2Color
|
|
321
323
|
ctx.beginPath()
|
|
322
324
|
ctx.moveTo(rsi2Points[0]!.x, rsi2Points[0]!.y)
|
|
323
325
|
for (let i = 1; i < rsi2Points.length; i++) {
|
|
@@ -328,7 +330,7 @@ export function drawRSILinesWithCanvas2D(
|
|
|
328
330
|
}
|
|
329
331
|
|
|
330
332
|
if (params.showRSI3 && rsi3Points.length >= 2) {
|
|
331
|
-
ctx.strokeStyle =
|
|
333
|
+
ctx.strokeStyle = rsi3Color
|
|
332
334
|
ctx.beginPath()
|
|
333
335
|
ctx.moveTo(rsi3Points[0]!.x, rsi3Points[0]!.y)
|
|
334
336
|
for (let i = 1; i < rsi3Points.length; i++) {
|
|
@@ -348,9 +350,10 @@ export function getRSITitleInfo(
|
|
|
348
350
|
period3: number,
|
|
349
351
|
pluginHost: PluginHost,
|
|
350
352
|
paneId: string = 'sub_RSI',
|
|
351
|
-
theme:
|
|
353
|
+
theme: 'light' | 'dark' = 'light',
|
|
354
|
+
isAsiaMarket?: boolean
|
|
352
355
|
): { name: string; params: number[]; values: Array<{ label: string; value: number; color: string }> } | null {
|
|
353
|
-
const colors =
|
|
356
|
+
const colors = resolveThemeColors(theme, isAsiaMarket)
|
|
354
357
|
const stateKey = createRSIStateKey(paneId)
|
|
355
358
|
const state = pluginHost.getSharedState<RSIRenderState>(stateKey)
|
|
356
359
|
|
|
@@ -361,9 +364,9 @@ export function getRSITitleInfo(
|
|
|
361
364
|
const rsi3 = state.series[period3]?.[index]
|
|
362
365
|
|
|
363
366
|
const values: Array<{ label: string; value: number; color: string }> = []
|
|
364
|
-
if (rsi1 !== undefined) values.push({ label: `RSI${period1}`, value: rsi1, color: colors.
|
|
365
|
-
if (rsi2 !== undefined) values.push({ label: `RSI${period2}`, value: rsi2, color: colors.
|
|
366
|
-
if (rsi3 !== undefined) values.push({ label: `RSI${period3}`, value: rsi3, color: colors.
|
|
367
|
+
if (rsi1 !== undefined) values.push({ label: `RSI${period1}`, value: rsi1, color: colors.rsi.rsi1 })
|
|
368
|
+
if (rsi2 !== undefined) values.push({ label: `RSI${period2}`, value: rsi2, color: colors.rsi.rsi2 })
|
|
369
|
+
if (rsi3 !== undefined) values.push({ label: `RSI${period3}`, value: rsi3, color: colors.rsi.rsi3 })
|
|
367
370
|
|
|
368
371
|
if (values.length === 0) return null
|
|
369
372
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, PluginHost, RenderContext, BaseIndicatorState } from '../../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../../plugin'
|
|
3
3
|
import { createIndicatorStateKey } from '../../../../plugin/stateKeys'
|
|
4
|
-
import {
|
|
4
|
+
import { resolveThemeColors } from '../../../../tokens'
|
|
5
5
|
import { getFont, setCanvasFont } from '../../../theme/fonts'
|
|
6
6
|
import { calculateValueTickPositions, type ScaleType } from '../../../utils/tickPosition'
|
|
7
7
|
import { drawCrosshairPriceLabel } from '../../../../utils/kLineDraw/axis'
|
|
@@ -62,7 +62,7 @@ export interface DrawScaleTicksOptions {
|
|
|
62
62
|
const BASELINE_MIDDLE = 'middle' as const
|
|
63
63
|
const ALIGN_CENTER = 'center' as const
|
|
64
64
|
|
|
65
|
-
export function drawScaleTicks(options: DrawScaleTicksOptions & {
|
|
65
|
+
export function drawScaleTicks(options: DrawScaleTicksOptions & { tickColor: string }): void {
|
|
66
66
|
const {
|
|
67
67
|
ctx,
|
|
68
68
|
dpr,
|
|
@@ -85,7 +85,7 @@ export function drawScaleTicks(options: DrawScaleTicksOptions & { colors: ThemeC
|
|
|
85
85
|
setCanvasFont(ctx, font)
|
|
86
86
|
ctx.textBaseline = BASELINE_MIDDLE
|
|
87
87
|
ctx.textAlign = ALIGN_CENTER
|
|
88
|
-
ctx.fillStyle = options.
|
|
88
|
+
ctx.fillStyle = options.tickColor
|
|
89
89
|
|
|
90
90
|
const centerX = axisWidth / 2
|
|
91
91
|
const centerXPx = roundToPhysicalPixel(centerX, dpr)
|
|
@@ -148,7 +148,7 @@ export function createIndicatorScaleRendererPlugin(options: IndicatorScaleRender
|
|
|
148
148
|
|
|
149
149
|
const effectiveScaleType: ScaleType = pane.yAxis.getScaleType() ?? scaleType
|
|
150
150
|
const effectiveAxisWidth = yAxisCtx.canvas ? (yAxisCtx.canvas.width / dpr) : axisWidth
|
|
151
|
-
const
|
|
151
|
+
const tokenColors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
152
152
|
|
|
153
153
|
const displayRange = pane.yAxis.getDisplayRange({
|
|
154
154
|
minPrice: state.valueMin,
|
|
@@ -156,7 +156,7 @@ export function createIndicatorScaleRendererPlugin(options: IndicatorScaleRender
|
|
|
156
156
|
})
|
|
157
157
|
|
|
158
158
|
drawScaleTicks({
|
|
159
|
-
|
|
159
|
+
tickColor: tokenColors.text.secondary,
|
|
160
160
|
ctx: yAxisCtx,
|
|
161
161
|
dpr,
|
|
162
162
|
axisWidth: effectiveAxisWidth,
|
|
@@ -198,7 +198,7 @@ export function createIndicatorScaleRendererPlugin(options: IndicatorScaleRender
|
|
|
198
198
|
priceOffset: 0,
|
|
199
199
|
price: displayPrice,
|
|
200
200
|
formatPrice: formatCrosshairLabel,
|
|
201
|
-
})
|
|
201
|
+
}, context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
202
202
|
},
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RendererPluginWithHost, RenderContext, PluginHost } from '../../../plugin'
|
|
2
2
|
import { RENDERER_PRIORITY } from '../../../plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { resolveThemeColors } from '../../../tokens'
|
|
4
4
|
import { alignToPhysicalPixelCenter } from '../../draw/pixelAlign'
|
|
5
5
|
import type { STOCHRenderState } from '../../indicators/stochState'
|
|
6
6
|
import { createSTOCHStateKey } from '../../indicators/stochState'
|
|
@@ -152,7 +152,7 @@ export function createSTOCHRendererPlugin(options: STOCHRendererOptions = {}): R
|
|
|
152
152
|
|
|
153
153
|
draw(context: RenderContext) {
|
|
154
154
|
const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = context
|
|
155
|
-
const colors =
|
|
155
|
+
const colors = resolveThemeColors(context.theme, context.isAsiaMarket, context.colorPresetSettings)
|
|
156
156
|
|
|
157
157
|
const stateKey = resolveKey()
|
|
158
158
|
if (!stateKey) return
|
|
@@ -238,10 +238,10 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
238
238
|
if (enableWebGL && lineWebGLSurface?.isAvailable()) {
|
|
239
239
|
const lines: Array<{ points: LinePoint[]; width: number; color: string }> = []
|
|
240
240
|
if (params.showK && cachedKPoints.length >= 2) {
|
|
241
|
-
lines.push({ points: cachedKPoints, width: 1, color: colors.
|
|
241
|
+
lines.push({ points: cachedKPoints, width: 1, color: colors.kdj.k })
|
|
242
242
|
}
|
|
243
243
|
if (params.showD && cachedDPoints.length >= 2) {
|
|
244
|
-
lines.push({ points: cachedDPoints, width: 1, color: colors.
|
|
244
|
+
lines.push({ points: cachedDPoints, width: 1, color: colors.kdj.d })
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
const allOk = lines.length > 0 && lineWebGLSurface.drawLineStrips(lines, scrollLeft)
|
|
@@ -279,7 +279,7 @@ function drawSTOCHLinesWithCanvas2D(
|
|
|
279
279
|
kPoints: LinePoint[],
|
|
280
280
|
dPoints: LinePoint[],
|
|
281
281
|
params: { showK: boolean; showD: boolean },
|
|
282
|
-
colors: {
|
|
282
|
+
colors: { kdj: { k: string; d: string } }
|
|
283
283
|
): void {
|
|
284
284
|
ctx.save()
|
|
285
285
|
ctx.translate(-scrollLeft, 0)
|
|
@@ -288,7 +288,7 @@ function drawSTOCHLinesWithCanvas2D(
|
|
|
288
288
|
ctx.lineCap = 'round'
|
|
289
289
|
|
|
290
290
|
if (params.showK && kPoints.length >= 2) {
|
|
291
|
-
ctx.strokeStyle = colors.
|
|
291
|
+
ctx.strokeStyle = colors.kdj.k
|
|
292
292
|
ctx.beginPath()
|
|
293
293
|
ctx.moveTo(kPoints[0]!.x, kPoints[0]!.y)
|
|
294
294
|
for (let i = 1; i < kPoints.length; i++) {
|
|
@@ -299,7 +299,7 @@ function drawSTOCHLinesWithCanvas2D(
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
if (params.showD && dPoints.length >= 2) {
|
|
302
|
-
ctx.strokeStyle = colors.
|
|
302
|
+
ctx.strokeStyle = colors.kdj.d
|
|
303
303
|
ctx.beginPath()
|
|
304
304
|
ctx.moveTo(dPoints[0]!.x, dPoints[0]!.y)
|
|
305
305
|
for (let i = 1; i < dPoints.length; i++) {
|
|
@@ -321,9 +321,10 @@ export function getSTOCHTitleInfo(
|
|
|
321
321
|
m: number,
|
|
322
322
|
pluginHost: PluginHost,
|
|
323
323
|
paneId: string = 'sub_STOCH',
|
|
324
|
-
theme:
|
|
324
|
+
theme: 'light' | 'dark' = 'light',
|
|
325
|
+
isAsiaMarket?: boolean
|
|
325
326
|
): { name: string; params: number[]; values: Array<{ label: string; value: number; color: string }> } | null {
|
|
326
|
-
const colors =
|
|
327
|
+
const colors = resolveThemeColors(theme, isAsiaMarket)
|
|
327
328
|
const state = pluginHost.getSharedState<STOCHRenderState>(createSTOCHStateKey(paneId))
|
|
328
329
|
if (!state) return null
|
|
329
330
|
|
|
@@ -331,8 +332,8 @@ export function getSTOCHTitleInfo(
|
|
|
331
332
|
if (!point || point.k === undefined) return null
|
|
332
333
|
|
|
333
334
|
const values = []
|
|
334
|
-
if (state.params.showK) values.push({ label: 'K', value: point.k, color: colors.
|
|
335
|
-
if (state.params.showD) values.push({ label: 'D', value: point.d, color: colors.
|
|
335
|
+
if (state.params.showK) values.push({ label: 'K', value: point.k, color: colors.kdj.k })
|
|
336
|
+
if (state.params.showD) values.push({ label: 'D', value: point.d, color: colors.kdj.d })
|
|
336
337
|
|
|
337
338
|
if (values.length === 0) return null
|
|
338
339
|
|