Frontend School

Interactive Campaign Timeline (Gantt Chart)

Machine Coding
medium

Interactive Campaign Timeline (Gantt Chart)

Medium
React
TypeScript
UI
Gantt Chart
Timeline

Overview

Clevertap's platform empowers marketers to orchestrate complex campaigns across various channels. A critical aspect of campaign management is visualizing scheduled activities over time. This problem focuses on building a simplified, interactive timeline component, often referred to as a Gantt Chart, to help users understand campaign schedules, identify overlaps, and manage their marketing initiatives efficiently. This visualization is key for planning and operational oversight.

What you need to do / Task

Your task is to build a React component that displays a list of marketing campaigns on a timeline. The component should visually represent each campaign as a bar, positioned and sized according to its start and end dates. The timeline should span a predefined period, and include an indicator for the current date.

  1. Render the Timeline Structure: Create a container for the timeline, with a clear horizontal axis displaying days for a fixed period (e.g., 14 days).
  2. Display Campaign Bars: For each provided campaign, render a visual bar element within the timeline.
  3. Position and Size Campaign Bars: Each bar's horizontal position and width must accurately reflect its startDate and endDate relative to the overall timeline view.
  4. Handle Overlapping Campaigns: Implement a strategy to visually separate overlapping campaigns. A common approach is to assign them to distinct horizontal 'tracks' or rows to prevent direct visual collision and maintain readability.
  5. Current Date Indicator: Display a vertical line or marker on the timeline indicating the current date.
  6. Interactive Tooltip: When a user hovers over a campaign bar, display a small tooltip showing the campaign's name, startDate, and endDate.

UI/UX expectations

  • Layout: The timeline should have a clear header for dates (e.g., 'Day 1', 'Day 2' or actual dates) and a main area for campaign bars.
  • Campaign Bars: Each bar should be visually distinct (e.g., using its assigned color). Text labels (campaign name) should be visible on the bars if space permits.
  • Responsiveness: The component should be reasonably responsive, adapting to different container widths (within the constraints of a fixed date range).
  • Interactions: The hover tooltip should appear and disappear smoothly.
  • Clarity: The overall visualization should be easy to read and interpret, allowing users to quickly grasp campaign durations and overlaps.

Acceptance criteria

  • The timeline component renders correctly with a visible date axis.
  • All provided mock campaigns are displayed as distinct bars on the timeline.
  • Campaign bars are accurately positioned and sized according to their startDate and endDate relative to the timeline's visible range.
  • Overlapping campaigns are visually separated (e.g., placed on different vertical tracks/rows).
  • A clear 'current date' indicator is present and correctly positioned on the timeline.
  • Hovering over any campaign bar displays a tooltip with its name, startDate, and endDate.
  • The application is free of console errors and warnings.

Constraints

Constraints & assumptions

  • Technology Stack: React with TypeScript.
  • Data: Campaign data will be provided as a static array of objects (see App.tsx). You do not need to fetch data from an API.
  • Timeline Range: The timeline should display a fixed period, for instance, 14 days starting from a specific date (e.g., July 1, 2024, or the earliest campaign start date).
  • Date Handling: Basic JavaScript Date objects are sufficient; no external date libraries (like date-fns or moment.js) are required.
  • Styling: Use plain CSS or CSS modules. No pre-processor or UI library (e.g., Material-UI, Ant Design) is needed.
  • Environment: Modern browser environment.

Out of scope

  • Drag-and-drop functionality for campaigns.
  • Dynamic date range selection, zooming, or panning.
  • Complex filtering or sorting of campaigns.
  • Persistence of campaign data.
  • Full accessibility compliance beyond basic semantic HTML and hover states.

What interviewers evaluate

  • Component Design: How well the solution is structured into logical React components, managing state and props effectively.
  • Algorithmic Thinking: The approach taken to calculate bar positions, widths, and especially the strategy for handling overlapping campaigns.
  • Date Manipulation: Correctness in using JavaScript Date objects to calculate durations and relative positions.
  • CSS & Layout: Proficiency in using CSS to achieve the desired visual layout and interactivity.
  • Code Quality: Readability, maintainability, and adherence to best practices for React and TypeScript.

Loading editor...