From 4dfc420535c6b0dbd77e5717c23125f1eaf01753 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 31 Oct 2025 17:57:32 +0100 Subject: [PATCH] Make pie chart responsive and reduce label text size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reduce label font sizes: 10px name, 9px details (was 14px/12px) - Add print-friendly smaller sizes: 7px/6px - Make container fully responsive with max-width constraints - Reduce label extension distance from ±50px to ±30px - Reduce label radius from outerRadius+60 to outerRadius+35 - Use fixed pie dimensions (80/50) instead of calculated sizes - Reduce connector line width from 2px to 1.5px - Add print-specific max-width and height constraints Fixes text overflow and makes chart fit properly on page while maintaining readability and print quality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/RechartsPortfolioPieChart.tsx | 102 ++++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/src/components/RechartsPortfolioPieChart.tsx b/src/components/RechartsPortfolioPieChart.tsx index ed1f223..f89bf6a 100644 --- a/src/components/RechartsPortfolioPieChart.tsx +++ b/src/components/RechartsPortfolioPieChart.tsx @@ -50,13 +50,13 @@ export function RechartsPortfolioPieChart({ } = props; const RADIAN = Math.PI / 180; - const radius = outerRadius + 60; + const radius = outerRadius + 35; const x = cx + radius * Math.cos(-midAngle * RADIAN); const y = cy + radius * Math.sin(-midAngle * RADIAN); const textAnchor = x > cx ? 'start' : 'end'; // Calculate line endpoint for label connector - const lineEndX = x > cx ? x + 50 : x - 50; + const lineEndX = x > cx ? x + 30 : x - 30; const labelStartX = cx + (outerRadius + 10) * Math.cos(-midAngle * RADIAN); const labelStartY = cy + (outerRadius + 10) * Math.sin(-midAngle * RADIAN); @@ -69,7 +69,7 @@ export function RechartsPortfolioPieChart({ x2={x} y2={y} stroke={fill} - strokeWidth="2" + strokeWidth="1.5" className="print:stroke-gray-400" /> - {/* Three-line label text */} + {/* Three-line label text - smaller sizes */} {name} {tons} tons {percentage.toFixed(1)}% @@ -115,42 +115,44 @@ export function RechartsPortfolioPieChart({ }; return ( -
- {/* SVG Chart */} - - - - {chartData.map((entry, index) => ( - - ))} - {/* Center label showing total */} - - - +
+ {/* SVG Chart - Responsive container */} +
+ + + + {chartData.map((entry, index) => ( + + ))} + {/* Center label showing total */} + + + +
{/* Legend below chart (for print clarity) */}