@@ -4,7 +4,7 @@ import { useI18n } from '../i18n/index.js';
44
55// ─── Mini Canvas Bar Chart ──────────────────────────────────────────────────
66
7- function BarChart ( { data, colors, height = 160 } : { data : { label : string ; value : number } [ ] ; colors : string [ ] ; height ?: number } ) {
7+ function BarChart ( { data, colors, height = 220 } : { data : { label : string ; value : number } [ ] ; colors : string [ ] ; height ?: number } ) {
88 const canvasRef = useRef < HTMLCanvasElement > ( null ) ;
99
1010 useEffect ( ( ) => {
@@ -23,7 +23,7 @@ function BarChart({ data, colors, height = 160 }: { data: { label: string; value
2323 ctx . strokeStyle = 'rgba(255,255,255,0.05)' ;
2424 ctx . lineWidth = 1 ;
2525 for ( let i = 0 ; i <= 4 ; i ++ ) {
26- const y = 20 + ( H - 50 ) * ( 1 - i / 4 ) ;
26+ const y = 20 + ( H - 90 ) * ( 1 - i / 4 ) ;
2727 ctx . beginPath ( ) ; ctx . moveTo ( 30 , y ) ; ctx . lineTo ( W - 10 , y ) ; ctx . stroke ( ) ;
2828 ctx . fillStyle = '#71717a' ;
2929 ctx . font = '10px system-ui' ;
@@ -33,11 +33,11 @@ function BarChart({ data, colors, height = 160 }: { data: { label: string; value
3333
3434 data . forEach ( ( d , i ) => {
3535 const x = startX + i * ( barW + 10 ) ;
36- const barH = ( d . value / max ) * ( H - 50 ) ;
37- const y = H - 30 - barH ;
36+ const barH = ( d . value / max ) * ( H - 90 ) ;
37+ const y = H - 70 - barH ;
3838
3939 // Bar with gradient
40- const grad = ctx . createLinearGradient ( x , y , x , H - 30 ) ;
40+ const grad = ctx . createLinearGradient ( x , y , x , H - 70 ) ;
4141 grad . addColorStop ( 0 , colors [ i % colors . length ] ! ) ;
4242 grad . addColorStop ( 1 , colors [ i % colors . length ] ! + '44' ) ;
4343 ctx . fillStyle = grad ;
@@ -51,10 +51,15 @@ function BarChart({ data, colors, height = 160 }: { data: { label: string; value
5151 ctx . textAlign = 'center' ;
5252 ctx . fillText ( String ( d . value ) , x + barW / 2 , y - 6 ) ;
5353
54- // Label
54+ // Label (rotated 45°)
5555 ctx . fillStyle = '#71717a' ;
56- ctx . font = '11px system-ui' ;
57- ctx . fillText ( d . label , x + barW / 2 , H - 10 ) ;
56+ ctx . font = '10px system-ui' ;
57+ ctx . save ( ) ;
58+ ctx . translate ( x + barW / 2 , H - 18 ) ;
59+ ctx . rotate ( - Math . PI / 4 ) ;
60+ ctx . textAlign = 'right' ;
61+ ctx . fillText ( d . label , 0 , 0 ) ;
62+ ctx . restore ( ) ;
5863 } ) ;
5964 } , [ data , colors , height ] ) ;
6065
@@ -188,7 +193,7 @@ export default function Stats() {
188193 ] ;
189194
190195 const catData = Object . entries ( categories ) . map ( ( [ cat , cnt ] ) => ( {
191- label : cat . length > 10 ? cat . slice ( 0 , 9 ) + '.' : cat ,
196+ label : cat ,
192197 value : cnt as number ,
193198 } ) ) ;
194199
0 commit comments