Overview
At Shiprocket, understanding shipment trends is crucial for operational planning and business strategy. We need a flexible tool that allows our analysts to quickly visualize shipment volume over different time granularities. This problem challenges you to build a simplified, interactive chart builder component that dynamically displays shipment volume based on user-selected time periods.
What you need to do / Task
- Implement Data Aggregation: Given a mock dataset of individual shipments, process this data to aggregate total shipment volume based on a selected time granularity (Daily, Weekly, Monthly). Helper functions for generating date keys and labels are provided.
- Build Granularity Selector: Create a UI control (e.g., radio buttons) that allows users to switch between "Daily", "Weekly", and "Monthly" views.
- Render Bar Chart: Display the aggregated shipment volume as a simple bar chart. Each bar should represent a period (day, week, or month), and its height should correspond proportionally to the total volume for that period.
- Dynamic Updates: Ensure the chart updates immediately when the user changes the time granularity.
UI/UX expectations
- The granularity selector should be clearly visible and allow easy switching between options.
- The chart should be displayed prominently below the selector.
- Each bar in the chart should be visually distinct. Its height should be a clear visual representation of the volume.
- Labels for each bar (e.g., "Jan 1", "Week 1", "Jan 2023") and a Y-axis indicator for volume are expected.
- The overall layout should be clean and readable, even with minimal styling.
Acceptance criteria
- User can select "Daily", "Weekly", or "Monthly" granularity.
- Selecting a granularity correctly aggregates and displays shipment volume for that period from the mock data.
- The bar chart visually represents the aggregated data, with bar heights proportional to volume.
- Meaningful labels for each bar (e.g., date, week number, month name) are present and correctly formatted.
- The chart updates dynamically without a full page reload when granularity changes.
- No console errors are present during interaction.