@@ -113,6 +113,23 @@ function buildHourlySeries(series: UsageSeriesPoint[], rangeHours?: number) {
113113 return filled ;
114114}
115115
116+ function buildHourlyLineStyle ( pointCount : number , baseStrokeWidth : number ) {
117+ const safeCount = Math . max ( 0 , pointCount ) ;
118+ const density = Math . min ( 1 , Math . max ( 0 , ( safeCount - 36 ) / 120 ) ) ;
119+ const minStrokeWidth = 1.2 ;
120+ const strokeWidth = Number ( ( baseStrokeWidth - ( baseStrokeWidth - minStrokeWidth ) * density ) . toFixed ( 2 ) ) ;
121+ const showDot = safeCount <= 72 ;
122+ const dotRadius = safeCount <= 24 ? 3 : safeCount <= 48 ? 2.5 : 2 ;
123+ const activeDotRadius = safeCount <= 72 ? 6 : safeCount <= 120 ? 5 : 4 ;
124+
125+ return {
126+ strokeWidth,
127+ showDot,
128+ dotRadius,
129+ activeDotRadius
130+ } ;
131+ }
132+
116133export default function DashboardPage ( ) {
117134 const [ mounted , setMounted ] = useState ( false ) ;
118135 const [ prices , setPrices ] = useState < ModelPrice [ ] > ( [ ] ) ;
@@ -746,6 +763,16 @@ export default function DashboardPage() {
746763 return buildHourlySeries ( overviewData . byHour , hours ) ;
747764 } , [ hourRange , overviewData ?. byHour ] ) ;
748765
766+ const hourlyLineStyle = useMemo (
767+ ( ) => buildHourlyLineStyle ( hourlySeries . length , 3 ) ,
768+ [ hourlySeries . length ]
769+ ) ;
770+
771+ const fullscreenHourlyLineStyle = useMemo (
772+ ( ) => buildHourlyLineStyle ( hourlySeries . length , fullscreenHourlyMode === "area" ? 2.3 : 3 ) ,
773+ [ hourlySeries . length , fullscreenHourlyMode ]
774+ ) ;
775+
749776 useEffect ( ( ) => {
750777 if ( fullscreenChart === "stacked" ) {
751778 setFullscreenHourlyMode ( "area" ) ;
@@ -1802,9 +1829,11 @@ export default function DashboardPage() {
18021829 dataKey = "requests"
18031830 name = "请求数"
18041831 stroke = { darkMode ? "#60a5fa" : "#3b82f6" }
1805- strokeWidth = { 3 }
1806- dot = { { r : 3 , fill : darkMode ? "#60a5fa" : "#3b82f6" , stroke : "#fff" , strokeWidth : 1 , fillOpacity : 0.2 } }
1807- activeDot = { { r : 6 , stroke : "#fff" , strokeWidth : 2 } }
1832+ strokeWidth = { hourlyLineStyle . strokeWidth }
1833+ dot = { hourlyLineStyle . showDot
1834+ ? { r : hourlyLineStyle . dotRadius , fill : darkMode ? "#60a5fa" : "#3b82f6" , stroke : "#fff" , strokeWidth : 1 , fillOpacity : 0.2 }
1835+ : false }
1836+ activeDot = { { r : hourlyLineStyle . activeDotRadius , stroke : "#fff" , strokeWidth : 2 } }
18081837 />
18091838 </ ComposedChart >
18101839 </ ResponsiveContainer >
@@ -2547,10 +2576,12 @@ export default function DashboardPage() {
25472576 dataKey = "requests"
25482577 name = "请求数"
25492578 stroke = { darkMode ? "#60a5fa" : "#3b82f6" }
2550- strokeWidth = { fullscreenHourlyMode === "area" ? 2.3 : 3 }
2579+ strokeWidth = { fullscreenHourlyLineStyle . strokeWidth }
25512580 strokeOpacity = { 1 }
2552- dot = { { r : 3 , fill : darkMode ? "#60a5fa" : "#3b82f6" , stroke : "#fff" , strokeWidth : 1 , fillOpacity : 0.2 } }
2553- activeDot = { { r : 6 , stroke : "#fff" , strokeWidth : 2 } }
2581+ dot = { fullscreenHourlyLineStyle . showDot
2582+ ? { r : fullscreenHourlyLineStyle . dotRadius , fill : darkMode ? "#60a5fa" : "#3b82f6" , stroke : "#fff" , strokeWidth : 1 , fillOpacity : 0.2 }
2583+ : false }
2584+ activeDot = { { r : fullscreenHourlyLineStyle . activeDotRadius , stroke : "#fff" , strokeWidth : 2 } }
25542585 />
25552586 </ ComposedChart >
25562587 </ ResponsiveContainer >
0 commit comments