style(ComparisonAnalysis): 应用黑金主题样式
- 图表配置:金色标题、深色 tooltip、金色坐标轴 - 净利润折线改为金色渐变填充 - 营收柱状图首个柱子使用金色 - 组件容器:透明背景 + 金色边框 - 移除外部重复标题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* 综合对比分析组件
|
* 综合对比分析组件 - 黑金主题
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card, CardBody } from '@chakra-ui/react';
|
import { Box } from '@chakra-ui/react';
|
||||||
import ReactECharts from 'echarts-for-react';
|
import ReactECharts from 'echarts-for-react';
|
||||||
import { formatUtils } from '@services/financialService';
|
import { formatUtils } from '@services/financialService';
|
||||||
import { getComparisonChartOption } from '../utils';
|
import { getComparisonChartOption } from '../utils';
|
||||||
import type { ComparisonAnalysisProps } from '../types';
|
import type { ComparisonAnalysisProps } from '../types';
|
||||||
|
|
||||||
|
// 黑金主题样式
|
||||||
|
const THEME = {
|
||||||
|
cardBg: 'transparent',
|
||||||
|
border: 'rgba(212, 175, 55, 0.2)',
|
||||||
|
};
|
||||||
|
|
||||||
export const ComparisonAnalysis: React.FC<ComparisonAnalysisProps> = ({ comparison }) => {
|
export const ComparisonAnalysis: React.FC<ComparisonAnalysisProps> = ({ comparison }) => {
|
||||||
if (!Array.isArray(comparison) || comparison.length === 0) return null;
|
if (!Array.isArray(comparison) || comparison.length === 0) return null;
|
||||||
|
|
||||||
@@ -29,11 +35,15 @@ export const ComparisonAnalysis: React.FC<ComparisonAnalysisProps> = ({ comparis
|
|||||||
const chartOption = getComparisonChartOption(revenueData, profitData);
|
const chartOption = getComparisonChartOption(revenueData, profitData);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Box
|
||||||
<CardBody>
|
bg={THEME.cardBg}
|
||||||
<ReactECharts option={chartOption} style={{ height: '400px' }} />
|
border="1px solid"
|
||||||
</CardBody>
|
borderColor={THEME.border}
|
||||||
</Card>
|
borderRadius="md"
|
||||||
|
p={4}
|
||||||
|
>
|
||||||
|
<ReactECharts option={chartOption} style={{ height: '350px' }} />
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -288,12 +288,7 @@ const FinancialPanorama: React.FC<FinancialPanoramaProps> = ({ stockCode: propSt
|
|||||||
|
|
||||||
{/* 营收与利润趋势 */}
|
{/* 营收与利润趋势 */}
|
||||||
{!loading && comparison && comparison.length > 0 && (
|
{!loading && comparison && comparison.length > 0 && (
|
||||||
<Box>
|
<ComparisonAnalysis comparison={comparison} />
|
||||||
<Text fontSize="lg" fontWeight="bold" mb={4} color="#D4AF37">
|
|
||||||
盈利与利润趋势
|
|
||||||
</Text>
|
|
||||||
<ComparisonAnalysis comparison={comparison} />
|
|
||||||
</Box>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 主营业务 */}
|
{/* 主营业务 */}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export const getMetricChartOption = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成营收与利润趋势图表配置
|
* 生成营收与利润趋势图表配置 - 黑金主题
|
||||||
* @param revenueData 营收数据
|
* @param revenueData 营收数据
|
||||||
* @param profitData 利润数据
|
* @param profitData 利润数据
|
||||||
* @returns ECharts 配置
|
* @returns ECharts 配置
|
||||||
@@ -101,34 +101,96 @@ export const getComparisonChartOption = (
|
|||||||
profitData: { period: string; value: number }[]
|
profitData: { period: string; value: number }[]
|
||||||
) => {
|
) => {
|
||||||
return {
|
return {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
title: {
|
title: {
|
||||||
text: '营收与利润趋势',
|
text: '营收与利润趋势',
|
||||||
left: 'center',
|
left: 'center',
|
||||||
|
textStyle: {
|
||||||
|
color: '#D4AF37',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
|
backgroundColor: 'rgba(26, 32, 44, 0.95)',
|
||||||
|
borderColor: 'rgba(212, 175, 55, 0.3)',
|
||||||
|
textStyle: {
|
||||||
|
color: '#E2E8F0',
|
||||||
|
},
|
||||||
axisPointer: {
|
axisPointer: {
|
||||||
type: 'cross',
|
type: 'cross',
|
||||||
|
crossStyle: {
|
||||||
|
color: 'rgba(212, 175, 55, 0.5)',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ['营业收入', '净利润'],
|
data: ['营业收入', '净利润'],
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
textStyle: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '3%',
|
||||||
|
right: '4%',
|
||||||
|
bottom: '12%',
|
||||||
|
top: '15%',
|
||||||
|
containLabel: true,
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: revenueData.map((d) => d.period),
|
data: revenueData.map((d) => d.period),
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: 'rgba(212, 175, 55, 0.3)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
axisLabel: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
yAxis: [
|
yAxis: [
|
||||||
{
|
{
|
||||||
type: 'value',
|
type: 'value',
|
||||||
name: '营收(亿)',
|
name: '营收(亿)',
|
||||||
position: 'left',
|
position: 'left',
|
||||||
|
nameTextStyle: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: 'rgba(212, 175, 55, 0.3)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
axisLabel: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: 'rgba(212, 175, 55, 0.1)',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'value',
|
type: 'value',
|
||||||
name: '利润(亿)',
|
name: '利润(亿)',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
|
nameTextStyle: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: 'rgba(212, 175, 55, 0.3)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
axisLabel: {
|
||||||
|
color: '#A0AEC0',
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
series: [
|
series: [
|
||||||
@@ -139,10 +201,10 @@ export const getComparisonChartOption = (
|
|||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: (params: { dataIndex: number; value: number }) => {
|
color: (params: { dataIndex: number; value: number }) => {
|
||||||
const idx = params.dataIndex;
|
const idx = params.dataIndex;
|
||||||
if (idx === 0) return '#3182CE';
|
if (idx === 0) return '#D4AF37'; // 金色作为基准
|
||||||
const prevValue = revenueData[idx - 1].value;
|
const prevValue = revenueData[idx - 1].value;
|
||||||
const currValue = params.value;
|
const currValue = params.value;
|
||||||
// 中国市场颜色
|
// 红涨绿跌
|
||||||
return currValue >= prevValue ? '#EF4444' : '#10B981';
|
return currValue >= prevValue ? '#EF4444' : '#10B981';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -153,8 +215,21 @@ export const getComparisonChartOption = (
|
|||||||
yAxisIndex: 1,
|
yAxisIndex: 1,
|
||||||
data: profitData.map((d) => d.value?.toFixed(2)),
|
data: profitData.map((d) => d.value?.toFixed(2)),
|
||||||
smooth: true,
|
smooth: true,
|
||||||
itemStyle: { color: '#F59E0B' },
|
itemStyle: { color: '#D4AF37' },
|
||||||
lineStyle: { width: 2 },
|
lineStyle: { width: 2, color: '#D4AF37' },
|
||||||
|
areaStyle: {
|
||||||
|
color: {
|
||||||
|
type: 'linear',
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
x2: 0,
|
||||||
|
y2: 1,
|
||||||
|
colorStops: [
|
||||||
|
{ offset: 0, color: 'rgba(212, 175, 55, 0.3)' },
|
||||||
|
{ offset: 1, color: 'rgba(212, 175, 55, 0.05)' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user