Component Location
Implemented in:src/components/VisualAnalytics.jsx:41-122
Chart Library
All charts are built using Recharts, a composable charting library built on React components:Chart 1: Financial Composition
Purpose
Shows the relationship between total revenue, RTO loss, and net profit in a single view, making it easy to visualize how RTO impacts your bottom line.Data Structure
VisualAnalytics.jsx:43-47
Visual Design
- Chart Type: Vertical bar chart
- Colors:
- Total Revenue: Blue (
#2563eb) - RTO Loss: Red (
#ef4444) - Net Profit: Green (
#10b981)
- Total Revenue: Blue (
- Dimensions: 350px height, 100% width (responsive)
- Bar Styling: Rounded top corners (
radius={[4, 4, 0, 0]})
Color coding helps users quickly identify positive (revenue, profit) and negative (loss) components.
Chart Features
- Responsive Container: Automatically adjusts to parent width
- Formatted Y-Axis: Currency values displayed in Crores (Cr) and Lakhs (L) for large numbers
- Interactive Tooltip: Hover over bars to see exact values
- No Vertical Grid Lines: Cleaner appearance with only horizontal gridlines
Chart 2: Impact of 10% RTO Reduction
Purpose
Compares current performance against a projected scenario where RTO is reduced by 10%, showing the direct impact on both RTO loss and net profit.Data Calculation
VisualAnalytics.jsx:50-67
Visual Design
- Chart Type: Grouped vertical bar chart
- Colors:
- Current Performance: Gray (
#94a3b8) - Optimized Performance: Blue (
#2563eb)
- Current Performance: Gray (
- Legend: Displays “Current Performance” vs “Optimized (-10% RTO)”
- Comparison: Side-by-side bars make improvement immediately visible
Currency Formatting for Charts
Compact Format Function
VisualAnalytics.jsx:15-23
Examples:
- 15,000,000 → ₹1.50Cr
- 500,000 → ₹5.00L
- 50,000 → ₹50,000
Custom Tooltip
Both charts use a custom tooltip component that displays formatted values on hover:VisualAnalytics.jsx:25-39
Tooltip Features
- Styled card with border matching the app theme
- Color-coded values matching bar colors
- Full currency formatting (not abbreviated)
- Only appears when actively hovering
Tooltips show exact values while the Y-axis uses abbreviated formatting—this provides both readability and precision.
Responsive Layout
The two charts are arranged in a responsive grid:- Mobile/Tablet: Single column (stacked vertically)
- Desktop: Two columns (side-by-side)
Chart Styling
Consistent Design Elements
- Grid: Dashed horizontal lines only (
strokeDasharray="3 3" vertical={false}) - Axes: No axis lines or tick marks for cleaner appearance
- Text Color: Uses CSS variable
var(--text-secondary)for theme consistency - Margins:
{ top: 20, right: 30, left: 20, bottom: 20 } - Bar Radius: Rounded top corners (
radius={[4, 4, 0, 0]})
Dark Mode Support
Charts automatically adapt to dark mode through CSS variables:var(--border-color)for grid linesvar(--text-secondary)for axis labelsvar(--surface-white)for tooltip background
Real-World Insights
Financial Composition Chart
Example interpretation:- Total Revenue: ₹1.50Cr (potential if all orders delivered)
- RTO Loss: ₹11.16L (money lost to returns)
- Net Profit: ₹1.39Cr (actual profit after RTO impact)
Impact of 10% Reduction Chart
Example interpretation:- RTO Loss: Current ₹11.16L → Projected ₹7.44L (33% reduction)
- Net Profit: Current ₹1.39Cr → Projected ₹1.51Cr (9% improvement)
Integration with Other Features
Visual Analytics complements:- Metrics Display: Provides visual representation of the numeric KPIs
- RTO Simulator: The comparison chart shows the same concept as the interactive slider but for a fixed 10% benchmark
- PDF Export: Charts are not included in PDF export (limitation of jsPDF), but the underlying data is shown in tables
Performance Considerations
- ResponsiveContainer: Efficiently handles window resizing without manual width calculations
- Animation: Recharts includes built-in animations when data changes
- Memoization: Consider wrapping in
React.memo()if experiencing performance issues with frequent input changes
Use Cases
- Executive Presentations: Visual charts are more persuasive than raw numbers when presenting to leadership
- Benchmarking: Quickly compare current vs. optimized scenarios
- Financial Planning: Visualize the relationship between revenue, losses, and profitability
- Investor Reporting: Professional charts demonstrate the impact of operational improvements