Frontend School

Interactive Project Timeline (Gantt Chart)

Machine Coding
medium

Interactive Project Timeline (Gantt Chart)

Medium
Gantt Chart
React
Frontend
Data Visualization
Timeline
CSS Grid

Overview

In project management, visualizing task timelines is crucial for tracking progress and identifying dependencies. For our internal project management tool, we need a simple, interactive Gantt chart component to display the duration and schedule of various tasks. This problem focuses on building the core rendering logic for such a component.

What you need to do / Task

Your goal is to build a React component that displays a list of project tasks on a timeline, resembling a basic Gantt chart.

  1. Render a Date Header: Display a daily header for a predefined two-week period. Each day should be clearly visible.
  2. List Tasks: On the left side, list the names of all provided tasks.
  3. Visualize Task Durations: For each task, render a horizontal bar on the timeline corresponding to its startDate and endDate. The bar's position and width should accurately reflect the task's duration and placement within the two-week timeline.
  4. Highlight Today: Visually distinguish the current date on the timeline header.

UI/UX expectations

  • The overall layout should be a grid-like structure, with task names on the left and the timeline visualization on the right.
  • Each day in the header should have a consistent width.
  • Task bars should be easily distinguishable (e.g., different background color).
  • The "Today" column should have a distinct background or border to highlight it.
  • The component should be responsive enough to display all elements clearly within a reasonable viewport.

Acceptance criteria

  • The date header shows all days from START_DATE to END_DATE (inclusive).
  • Each task from mockTasks is listed on the left.
  • Each task has a corresponding visual bar on the timeline.
  • Task bars accurately start and end at their respective dates.
  • The width of a task bar correctly represents its duration (e.g., a 3-day task is three times wider than a 1-day task).
  • The current day's column in the header is visually distinct.

Constraints

Constraints & assumptions

  • The timeline will cover a fixed period of 14 days (two weeks), defined by FIXED_START_DATE and FIXED_END_DATE constants.
  • Tasks will always have valid startDate and endDate strings in YYYY-MM-DD format.
  • All task dates will fall within or partially overlap the FIXED_START_DATE and FIXED_END_DATE of the chart.
  • No drag-and-drop functionality is required.
  • No task editing or creation is required.
  • The component should handle a small number of tasks (e.g., 5-10 tasks).
  • Use React functional components and hooks.

Out of scope

  • Scrolling horizontally for longer timelines.
  • Zooming in/out on the timeline.
  • Handling task dependencies or complex relationships.
  • Backend integration or data fetching.
  • Extensive error handling for invalid dates.

What interviewers evaluate

  • Correctness and Accuracy: Does the Gantt chart accurately represent task durations and positions on the timeline? Is today's date correctly highlighted?
  • Code Structure and Readability: Is the code well-organized, modular, and easy to understand? Are appropriate React patterns used?
  • Problem Decomposition: How effectively is the problem broken down into manageable parts (e.g., date calculation, rendering logic)?
  • Styling and UI Implementation: Does the UI meet the basic expectations for layout and visual clarity using CSS?

Loading editor...