feat(mock): 完善涨停分析 Mock 数据结构

- 新增午盘、尾盘涨停数量统计
- 添加 chart_data 字段支持板块分布饼图

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-24 18:31:19 +08:00
parent f5dbdfa84c
commit 080dbdb26b

View File

@@ -216,24 +216,39 @@ const generateDailyAnalysis = (date) => {
// 统计数据 // 统计数据
const morningCount = Math.floor(totalStocks * 0.35); // 早盘涨停 const morningCount = Math.floor(totalStocks * 0.35); // 早盘涨停
const middayCount = Math.floor(totalStocks * 0.25); // 午盘涨停
const afternoonCount = totalStocks - morningCount - middayCount; // 尾盘涨停
const announcementCount = sectorData['公告']?.count || 0; const announcementCount = sectorData['公告']?.count || 0;
const topSector = sectorNames.filter(s => s !== '公告' && s !== '其他') const topSector = sectorNames.filter(s => s !== '公告' && s !== '其他')
.reduce((max, name) => .reduce((max, name) =>
(sectorData[name]?.count || 0) > (sectorData[max]?.count || 0) ? name : max (sectorData[name]?.count || 0) > (sectorData[max]?.count || 0) ? name : max
, '人工智能'); , '人工智能');
// 生成 chart_data板块分布饼图需要
const sortedSectors = Object.entries(sectorData)
.filter(([name]) => name !== '其他' && name !== '公告')
.sort((a, b) => b[1].count - a[1].count)
.slice(0, 10);
const chartData = {
labels: sortedSectors.map(([name]) => name),
counts: sortedSectors.map(([, info]) => info.count)
};
return { return {
date: date, date: date,
total_stocks: totalStocks, total_stocks: totalStocks,
total_sectors: Object.keys(sectorData).length, total_sectors: Object.keys(sectorData).length,
sector_data: sectorData, // 👈 SectorDetails 组件需要的数据 sector_data: sectorData, // 👈 SectorDetails 组件需要的数据
chart_data: chartData, // 👈 板块分布饼图需要的数据
summary: { summary: {
top_sector: topSector, top_sector: topSector,
top_sector_count: sectorData[topSector]?.count || 0, top_sector_count: sectorData[topSector]?.count || 0,
announcement_stocks: announcementCount, announcement_stocks: announcementCount,
zt_time_distribution: { zt_time_distribution: {
morning: morningCount, morning: morningCount,
afternoon: totalStocks - morningCount, midday: middayCount,
afternoon: afternoonCount,
} }
} }
}; };
@@ -382,6 +397,22 @@ const generateDailyJson = (date) => {
{ name: '区块链', value: Math.floor(Math.random() * 5) + 2 }, { name: '区块链', value: Math.floor(Math.random() * 5) + 2 },
]; ];
// 生成 chart_data板块分布饼图需要
const sortedSectors = Object.entries(sectorData)
.filter(([name]) => name !== '其他' && name !== '公告')
.sort((a, b) => b[1].count - a[1].count)
.slice(0, 10);
const chartData = {
labels: sortedSectors.map(([name]) => name),
counts: sortedSectors.map(([, info]) => info.count)
};
// 时间分布(早盘、午盘、尾盘)
const morningCount = Math.floor(stocks.length * 0.35);
const middayCount = Math.floor(stocks.length * 0.25);
const afternoonCount = stocks.length - morningCount - middayCount;
return { return {
date: date, date: date,
total_stocks: stocks.length, total_stocks: stocks.length,
@@ -389,13 +420,15 @@ const generateDailyJson = (date) => {
stocks: stocks, stocks: stocks,
sector_data: sectorData, sector_data: sectorData,
word_freq_data: wordFreqData, word_freq_data: wordFreqData,
chart_data: chartData, // 👈 板块分布饼图需要的数据
summary: { summary: {
top_sector: '人工智能', top_sector: '人工智能',
top_sector_count: sectorData['人工智能']?.count || 0, top_sector_count: sectorData['人工智能']?.count || 0,
announcement_stocks: sectorData['公告']?.count || 0, announcement_stocks: sectorData['公告']?.count || 0,
zt_time_distribution: { zt_time_distribution: {
morning: Math.floor(stocks.length * 0.4), morning: morningCount, // 早盘 9:30-11:30
afternoon: Math.floor(stocks.length * 0.6), midday: middayCount, // 午盘 11:30-13:00
afternoon: afternoonCount, // 尾盘 13:00-15:00
} }
} }
}; };