community增加事件详情
This commit is contained in:
@@ -37,17 +37,49 @@ const NOISE_WORDS = [
|
||||
];
|
||||
|
||||
/**
|
||||
* 从 public/data/zt 读取多日词频数据
|
||||
* 获取最近一个自然月内的所有交易日
|
||||
* @param {Array} dates - dates.json 中的日期列表
|
||||
* @returns {Array} - 筛选后的日期列表
|
||||
*/
|
||||
const fetchMultiDayWordFreq = async (days = 7) => {
|
||||
const getLastMonthTradingDays = (dates) => {
|
||||
if (!dates || dates.length === 0) return [];
|
||||
|
||||
// 获取最新日期作为基准
|
||||
const latestDateStr = dates[0].date; // 格式: YYYYMMDD
|
||||
const latestYear = parseInt(latestDateStr.slice(0, 4));
|
||||
const latestMonth = parseInt(latestDateStr.slice(4, 6));
|
||||
const latestDay = parseInt(latestDateStr.slice(6, 8));
|
||||
const latestDate = new Date(latestYear, latestMonth - 1, latestDay);
|
||||
|
||||
// 计算一个月前的日期
|
||||
const oneMonthAgo = new Date(latestDate);
|
||||
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
|
||||
|
||||
// 筛选在一个月内的交易日
|
||||
return dates.filter((dateInfo) => {
|
||||
const dateStr = dateInfo.date;
|
||||
const year = parseInt(dateStr.slice(0, 4));
|
||||
const month = parseInt(dateStr.slice(4, 6));
|
||||
const day = parseInt(dateStr.slice(6, 8));
|
||||
const date = new Date(year, month - 1, day);
|
||||
return date >= oneMonthAgo && date <= latestDate;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 从 public/data/zt 读取多日词频数据(最近一个自然月)
|
||||
*/
|
||||
const fetchMultiDayWordFreq = async () => {
|
||||
try {
|
||||
// 先获取日期列表
|
||||
const datesRes = await fetch('/data/zt/dates.json');
|
||||
const datesData = await datesRes.json();
|
||||
const recentDates = datesData.dates.slice(0, days);
|
||||
|
||||
// 获取最近一个自然月的交易日
|
||||
const monthDates = getLastMonthTradingDays(datesData.dates);
|
||||
|
||||
// 并行获取每日数据
|
||||
const dailyDataPromises = recentDates.map(async (dateInfo) => {
|
||||
const dailyDataPromises = monthDates.map(async (dateInfo) => {
|
||||
try {
|
||||
const res = await fetch(`/data/zt/daily/${dateInfo.date}.json`);
|
||||
if (!res.ok) return null;
|
||||
@@ -257,7 +289,9 @@ const generateChartOption = (themes, dates, onThemeClick) => {
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'rgba(255, 255, 255, 0.6)',
|
||||
fontSize: 11,
|
||||
fontSize: 10,
|
||||
interval: Math.max(0, Math.floor(dates.length / 8) - 1), // 动态间隔,约显示8个标签
|
||||
rotate: dates.length > 15 ? 30 : 0, // 数据多时旋转标签
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
@@ -299,7 +333,7 @@ const ThemeCometChart = ({ onThemeSelect }) => {
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const dailyData = await fetchMultiDayWordFreq(7);
|
||||
const dailyData = await fetchMultiDayWordFreq();
|
||||
const processed = processWordFreqData(dailyData);
|
||||
setData(processed);
|
||||
} catch (error) {
|
||||
@@ -403,7 +437,7 @@ const ThemeCometChart = ({ onThemeSelect }) => {
|
||||
题材热力追踪
|
||||
</Text>
|
||||
<Text fontSize="xs" color="whiteAlpha.500">
|
||||
核心主题词频演变 · 最近7个交易日
|
||||
核心主题词频演变 · 最近一个月
|
||||
</Text>
|
||||
</VStack>
|
||||
</HStack>
|
||||
|
||||
Reference in New Issue
Block a user