Frontend School

Configurable Bar Chart Builder

Machine Coding
medium

Configurable Bar Chart Builder

Medium
React
UI
State Management
CSS

Overview

Our internal analytics dashboard needs a flexible way for users to quickly visualize data. This problem focuses on building a core component of a 'Chart Builder' tool: a configurable bar chart. The goal is to allow users to dynamically adjust key properties of the chart, such as its title and axis labels, and see these changes reflected in real-time.

What you need to do / Task

Your primary task is to create a React component that displays a simple bar chart and allows for its basic configuration.

  1. Initial Render: Display a bar chart using the provided mock data.
  2. Configuration Controls: Implement input fields for the user to configure the following chart properties:
    • Chart Title: A text input for the main title of the chart.
    • X-Axis Label: A text input for the label displayed along the X-axis.
    • Y-Axis Label: A text input for the label displayed along the Y-axis.
  3. Dynamic Updates: As the user types into the configuration input fields, the corresponding chart elements (title, X-axis label, Y-axis label) must update instantaneously.
  4. Bar Styling: Ensure the bars are rendered with heights proportional to their values and have a distinct color. You can use a single, configurable color for all bars (e.g., a color input or a simple dropdown with a few options).

UI/UX expectations

  • The application should have a clear layout, separating the configuration controls from the rendered chart. A common pattern is controls on one side/top and the chart display area on the other side/bottom.
  • Input fields should be clearly labeled and functional.
  • The bar chart itself should be visually distinct, with bars clearly representing data values. Basic styling for labels and bars is sufficient.

Acceptance criteria

  • The application loads and displays an initial bar chart with the mock data.
  • The chart includes an initial title, X-axis label, and Y-axis label.
  • Changing the text in the 'Chart Title' input field immediately updates the chart's title.
  • Changing the text in the 'X-Axis Label' input field immediately updates the X-axis label on the chart.
  • Changing the text in the 'Y-Axis Label' input field immediately updates the Y-axis label on the chart.
  • Bars are rendered with heights proportional to their values and a consistent, visible color.

Constraints

Constraints & assumptions

  • You should use React functional components and hooks for state management.
  • The mock data provided will be the only data source; no data fetching or external APIs are required.
  • Focus on building the chart using standard HTML elements (divs) and CSS, rather than integrating a third-party charting library (e.g., D3, Chart.js, Recharts). This is to evaluate your understanding of basic UI rendering and proportional scaling.
  • Assume all data values are positive numbers.
  • The chart should accommodate up to 10-15 data points efficiently.

Out of scope

  • Advanced chart types (e.g., line charts, pie charts, stacked bars).
  • Complex animations or transitions.
  • Extensive error handling for malformed input.
  • Backend integration or persistent storage of chart configurations.
  • Full accessibility implementation beyond standard form labels.

What interviewers evaluate

  • React Fundamentals: Effective use of React components, props, and state (useState).
  • Dynamic UI: Ability to implement real-time UI updates based on user interaction.
  • Component Design: Logical separation of concerns and component structure.
  • CSS & Layout: Competence in using CSS for basic layout, styling, and proportional rendering.
  • Code Quality: Readability, maintainability, and adherence to best practices.

Loading editor...