diff --git a/src/pages/Analysis/Industrytrend/index.tsx b/src/pages/Analysis/Industrytrend/index.tsx index 46bbe89..d6cca3b 100644 --- a/src/pages/Analysis/Industrytrend/index.tsx +++ b/src/pages/Analysis/Industrytrend/index.tsx @@ -73,7 +73,7 @@ const IndustryTrendPage: React.FC = () => { let newStartTime = ''; if (value === '月') { - newStartTime = now.subtract(6, 'month').format('YYYY-MM'); + newStartTime = now.subtract(5, 'month').format('YYYY-MM'); } else if (value === '季度') { newStartTime = now.subtract(6, 'quarter').format('YYYY-Q'); } else { @@ -101,6 +101,18 @@ const IndustryTrendPage: React.FC = () => { } }; + const disabledDate = (current: dayjs.Dayjs) => { + const now = dayjs(); + + if (params.timeDimension === '月') { + return current.isAfter(now.endOf('month')); + } else if (params.timeDimension === '季度') { + return current.isAfter(now.endOf('quarter')); + } else { + return current.isAfter(now.endOf('year')); + } + }; + const currentIndustryData = useMemo(() => { if (!params.selectedIndustry || allData.length === 0) return []; @@ -108,16 +120,32 @@ const IndustryTrendPage: React.FC = () => { .filter(item => item.category === params.selectedIndustry) .map(item => ({ ...item, + originalDate: item.date, date: formatDateForDisplay(item.date, params.timeDimension) })) .sort((a, b) => { - const dateA = a.date.includes('第') - ? parseInt(a.date.split('第')[1]) - : dayjs(a.date).valueOf(); - const dateB = b.date.includes('第') - ? parseInt(b.date.split('第')[1]) - : dayjs(b.date).valueOf(); - return dateA - dateB; + if (params.timeDimension === '季度') { + // 处理中文季度格式,如 "2024-第一季度" -> ["2024", "第一"] + const [yearA, quarterA] = a.originalDate.split('-'); + const [yearB, quarterB] = b.originalDate.split('-'); + + // 转换中文季度为数字("第一" -> 1, "第二" -> 2...) + const quarterToNumber = (q: string) => { + if (q.includes('第一')) return 1; + if (q.includes('第二')) return 2; + if (q.includes('第三')) return 3; + if (q.includes('第四')) return 4; + return 0; + }; + + return yearA === yearB + ? quarterToNumber(quarterA) - quarterToNumber(quarterB) + : parseInt(yearA) - parseInt(yearB); + } else if (params.timeDimension === '年') { + return parseInt(a.originalDate) - parseInt(b.originalDate); + } else { + return dayjs(a.originalDate).valueOf() - dayjs(b.originalDate).valueOf(); + } }); }, [allData, params.selectedIndustry, params.timeDimension]); @@ -143,16 +171,17 @@ const IndustryTrendPage: React.FC = () => { seriesField: 'category', xAxis: { type: 'cat', + label: { formatter: (text: string) => text, + }, }, yAxis: { label: { - formatter: (val: string) => `${val}${params.type === '招聘增长率' ? '%' : '个'}`, + formatter: (val: string) => `${val}${params.type === '招聘增长率' ? '%' : ''}`, }, }, - tooltip: false, point: { size: 4, shape: 'circle', @@ -164,6 +193,48 @@ const IndustryTrendPage: React.FC = () => { }, }, smooth: true, + interactions: [ + { + type: 'tooltip', + cfg: { + render: (e, { title, items }) => { + const list = items.filter((item) => item.value); + return ( +