|
|
@@ -1,5 +1,7 @@
|
|
|
import BarElement from './BarElement';
|
|
|
import BaseContainer from './BaseContainer';
|
|
|
+import ModuleHeader from './ModuleHeader';
|
|
|
+import ModuleHeaderBackground from './ModuleHeaderBackground';
|
|
|
|
|
|
interface ProfitMetricsProps {
|
|
|
className?: string;
|
|
|
@@ -13,16 +15,13 @@ const profitData = [
|
|
|
{ year: '2025年', profitTotal: 1.34, profitNet: 1.00 }
|
|
|
];
|
|
|
|
|
|
-const maxPositiveValue = Math.max(...profitData.map(d => Math.max(d.profitTotal, d.profitNet)));
|
|
|
-const minNegativeValue = Math.min(...profitData.map(d => Math.min(d.profitTotal, d.profitNet)));
|
|
|
-
|
|
|
-const calculateHeight = (value: number) => {
|
|
|
- const maxHeight = 100; // 最大柱形高度
|
|
|
- if (value >= 0) {
|
|
|
- return (value / maxPositiveValue) * maxHeight;
|
|
|
- } else {
|
|
|
- return (Math.abs(value) / Math.abs(minNegativeValue)) * maxHeight;
|
|
|
- }
|
|
|
+// 按照Figma设计规范中的精确柱形高度
|
|
|
+const barHeights = {
|
|
|
+ '2021年': { profitTotal: 60, profitNet: 68 },
|
|
|
+ '2022年': { profitTotal: 32, profitNet: 24 },
|
|
|
+ '2023年': { profitTotal: 51, profitNet: 24 },
|
|
|
+ '2024年': { profitTotal: 66, profitNet: 49 },
|
|
|
+ '2025年': { profitTotal: 54, profitNet: 40 }
|
|
|
};
|
|
|
|
|
|
export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
@@ -34,7 +33,7 @@ export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
<div className="absolute content-stretch flex flex-col gap-[20px] h-[388px] items-start left-[41.4px] top-[79px] w-[847.191px]">
|
|
|
{/* 顶部标题和说明 */}
|
|
|
<div className="content-stretch flex items-start justify-between relative shrink-0 w-[847px]">
|
|
|
- <div className="content-stretch flex gap-[20px] items-center relative shrink-0">
|
|
|
+ <div className="content-stretch flex gap-[20px] items-center relative shrink-0 w-[93px]">
|
|
|
<div className="content-stretch flex gap-[10px] h-[26px] items-center relative shrink-0">
|
|
|
<div className="flex items-center justify-center relative shrink-0">
|
|
|
<div className="flex-none rotate-[180deg]">
|
|
|
@@ -83,6 +82,18 @@ export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
</p>
|
|
|
))}
|
|
|
</div>
|
|
|
+
|
|
|
+ {/* 网格线背景 */}
|
|
|
+ <div className="col-[1] grid-cols-[max-content] grid-rows-[max-content] inline-grid justify-items-start ml-[52px] mt-0 relative row-[1]">
|
|
|
+ {/* 水平网格线 */}
|
|
|
+ <div className="col-[1] h-[2px] ml-[0.12px] mt-0 relative row-[1] w-[794.879px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[40px] relative row-[1] w-[795px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[80px] relative row-[1] w-[795px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[120px] relative row-[1] w-[795px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[160px] relative row-[1] w-[795px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[200px] relative row-[1] w-[795.191px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ <div className="col-[1] h-[2px] ml-0 mt-[240px] relative row-[1] w-[795px] bg-gradient-to-r from-[rgba(255,255,255,0.1)] to-[rgba(255,255,255,0.05)]" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
{/* 柱形图数据 */}
|
|
|
@@ -99,7 +110,7 @@ export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
<BarElement
|
|
|
variant="profit-total"
|
|
|
className={`w-[35px]`}
|
|
|
- style={{ height: `${calculateHeight(data.profitTotal)}px` }}
|
|
|
+ style={{ height: `${barHeights[data.year as keyof typeof barHeights].profitTotal}px` }}
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -115,7 +126,7 @@ export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
<BarElement
|
|
|
variant="profit-net"
|
|
|
className={`w-[35px] rounded-[2px]`}
|
|
|
- style={{ height: `${calculateHeight(data.profitNet)}px` }}
|
|
|
+ style={{ height: `${barHeights[data.year as keyof typeof barHeights].profitNet}px` }}
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -126,9 +137,8 @@ export function ProfitMetrics({ className }: ProfitMetricsProps) {
|
|
|
</div>
|
|
|
|
|
|
{/* 模块标题 */}
|
|
|
- <div className="absolute top-4 left-4">
|
|
|
- <p className="text-[20px] font-medium text-white">利润总额与净利润</p>
|
|
|
- </div>
|
|
|
+ <ModuleHeaderBackground className="absolute h-[38px] left-0 top-0 w-[594.001px]" />
|
|
|
+ <ModuleHeader className="absolute h-[38px] overflow-clip right-0 top-0 w-[594px]" title="利润总额与净利润" />
|
|
|
</div>
|
|
|
);
|
|
|
}
|