feat(selection): add Zhixing line indicators to selection chart and update related components

This commit is contained in:
yuxuanhui
2026-09-01 22:57:58 +08:00
parent 3da90f7df8
commit f41ad0915e
10 changed files with 100 additions and 25 deletions
@@ -16,6 +16,11 @@ import type { SelectionChartPoint } from "../api/selection.types"
const DEFAULT_VISIBLE_POINTS = 120
const zhixingLineSeries = [
{ color: "#a8a8a8", key: "trend_white", name: "知行白线" },
{ color: "#eab308", key: "trend_yellow", name: "知行黄线" },
] as const
export type SelectionChartOption = ComposeOption<
| BarSeriesOption
| CandlestickSeriesOption
@@ -30,7 +35,7 @@ export type SelectionChartOption = ComposeOption<
/**
* Build the three-grid financial chart configuration from aligned API points.
*
* @param points Ascending qfq OHLCV and KDJ points from the selection API.
* @param points Ascending qfq OHLCV, KDJ, and Zhixing-line points from the API.
* @returns One ECharts option with synchronized axes and an exact 120-point window.
*/
export function buildSelectionChartOption(
@@ -63,11 +68,18 @@ export function buildSelectionChartOption(
{ bottom: "28%", height: "14%", left: 64, right: 24 },
{ bottom: 48, height: "20%", left: 64, right: 24 },
],
legend: {
data: ["K", "D", "J"],
right: 20,
top: "73%",
},
legend: [
{
data: zhixingLineSeries.map((line) => line.name),
right: 20,
top: 8,
},
{
data: ["K", "D", "J"],
right: 20,
top: "73%",
},
],
series: [
{
data: points.map(toCandlestickValue),
@@ -82,6 +94,21 @@ export function buildSelectionChartOption(
xAxisIndex: 0,
yAxisIndex: 0,
},
...zhixingLineSeries.map((line): LineSeriesOption => ({
connectNulls: false,
data: points.map((point) => point[line.key]),
itemStyle: { color: line.color },
lineStyle: {
color: line.color,
width: 1.5,
},
name: line.name,
showSymbol: false,
smooth: false,
type: "line",
xAxisIndex: 0,
yAxisIndex: 0,
})),
{
data: points.map((point) => ({
itemStyle: {