Files
zhixing-system/zhixing-web/src/features/sector-radar/components/radar-rank-chart-option.ts
T
yuxuanhui 7f93d6b0f5 feat(sector_radar): enhance sector radar functionality with active moneyflow and detailed metrics
- Introduced ActiveMoneyflowSource to fetch optional active-order flow, enhancing the sector radar's data capabilities.
- Updated StockFactRecord and DailyAggregateRecord to include pct_change and active_buy_net_amount_yuan for improved financial insights.
- Modified the build process to incorporate active moneyflow data without invalidating main rankings on failure.
- Enhanced the HTTP API to return detailed sector history and metrics, including pct_change and active buy metrics for members.
- Updated tests to validate the new functionality and ensure data integrity across various scenarios.
2026-09-06 16:06:17 +08:00

52 lines
1.4 KiB
TypeScript

import type {
RadarHistoryPoint,
RadarMetricKind,
} from "../api/sector-radar.types"
/** Produce a chronological ranking series; missing observations break the line and rank 1 stays on top. */
export function buildRadarRankChartOption(
points: RadarHistoryPoint[],
metric: RadarMetricKind,
) {
const ordered = [...points].sort((a, b) =>
a.trade_date.localeCompare(b.trade_date),
)
return {
animation: false,
grid: { left: 48, right: 20, top: 24, bottom: 36 },
tooltip: {
trigger: "axis" as const,
renderMode: "richText" as const,
valueFormatter: (value: unknown) =>
value == null ? "缺失" : `第 ${String(value)} 名`,
},
xAxis: {
type: "category" as const,
data: ordered.map((point) => point.trade_date),
boundaryGap: false,
},
yAxis: {
type: "value" as const,
inverse: true,
min: 1,
max: Math.max(2, ...ordered.map((point) => point[metric].pool_size)),
minInterval: 1,
name: "排名",
},
series: [
{
name: "排名",
type: "line" as const,
connectNulls: false,
showSymbol: true,
showAllSymbol: true,
data: ordered.map((point) =>
point[metric].missing ? null : point[metric].rank_position,
),
lineStyle: { color: "#2563eb" },
itemStyle: { color: "#2563eb" },
},
],
}
}