Convert Figma logo to code with AI

MaTeMaTuK logogantt-task-react

Gantt chart for React with Typescript

1,033
614
1,033
157

Top Related Projects

1,672

GPL version of Javascript Gantt Chart

Gantt Gantt Gantt Timeline Schedule Calendar [ javascript gantt, js gantt, projects gantt, timeline, scheduler, gantt timeline, reservation timeline, react gantt, angular gantt, vue gantt, svelte gantt, booking manager ]

🍞📅A JavaScript calendar that has everything you need.

A datepicker for twitter bootstrap (@twbs)

Quick Overview

Gantt-task-react is a React component library for creating interactive Gantt charts. It provides a customizable and feature-rich solution for visualizing project timelines, tasks, and dependencies in a Gantt chart format, making it ideal for project management and scheduling applications.

Pros

  • Highly customizable with numerous styling and configuration options
  • Supports task dependencies and linking
  • Includes features like zooming, scrolling, and task selection
  • Written in TypeScript, providing type safety and better developer experience

Cons

  • Limited documentation and examples for advanced use cases
  • May require additional styling effort to match specific design requirements
  • Performance might degrade with a large number of tasks
  • Lacks built-in support for some advanced Gantt chart features (e.g., resource allocation)

Code Examples

  1. Basic Gantt Chart:
import { Gantt, Task, ViewMode } from 'gantt-task-react';

const tasks: Task[] = [
  {
    start: new Date(2023, 0, 1),
    end: new Date(2023, 0, 15),
    name: 'Task 1',
    id: 'Task 1',
    progress: 45,
    type: 'task',
  },
  // Add more tasks...
];

function App() {
  return (
    <Gantt tasks={tasks} viewMode={ViewMode.Month} />
  );
}
  1. Customizing the Gantt Chart:
import { Gantt, Task, ViewMode } from 'gantt-task-react';

function App() {
  return (
    <Gantt
      tasks={tasks}
      viewMode={ViewMode.Week}
      onDateChange={(task, start, end) => {
        console.log(task, start, end);
      }}
      onProgressChange={(task, progress) => {
        console.log(task, progress);
      }}
      onSelect={(task, isSelected) => {
        console.log(task, isSelected);
      }}
      listCellWidth="200px"
      columnWidth={60}
    />
  );
}
  1. Adding Task Dependencies:
const tasks: Task[] = [
  {
    start: new Date(2023, 0, 1),
    end: new Date(2023, 0, 15),
    name: 'Task 1',
    id: 'Task 1',
    progress: 45,
    type: 'task',
    dependencies: ['Task 2'],
  },
  {
    start: new Date(2023, 0, 16),
    end: new Date(2023, 0, 31),
    name: 'Task 2',
    id: 'Task 2',
    progress: 0,
    type: 'task',
  },
];

Getting Started

  1. Install the package:

    npm install gantt-task-react
    
  2. Import and use the Gantt component in your React application:

    import React from 'react';
    import { Gantt, Task, ViewMode } from 'gantt-task-react';
    import 'gantt-task-react/dist/index.css';
    
    const tasks: Task[] = [
      // Define your tasks here
    ];
    
    function App() {
      return (
        <div className="App">
          <Gantt tasks={tasks} viewMode={ViewMode.Month} />
        </div>
      );
    }
    
    export default App;
    
  3. Customize the Gantt chart as needed using the available props and event handlers.

Competitor Comparisons

1,672

GPL version of Javascript Gantt Chart

Pros of DHTMLX/gantt

  • More comprehensive and feature-rich, offering a wide range of functionalities
  • Extensive documentation and examples available
  • Supports multiple views (Gantt, Grid, Timeline) and advanced features like resource management

Cons of DHTMLX/gantt

  • Steeper learning curve due to its complexity
  • Commercial license required for most use cases
  • Larger file size and potentially higher performance overhead

Code Comparison

gantt-task-react:

import { Gantt, Task, ViewMode } from 'gantt-task-react';

const App = () => (
  <Gantt tasks={tasks} viewMode={ViewMode.Day} />
);

DHTMLX/gantt:

gantt.init("gantt_here");
gantt.parse({
  data: [
    {id: 1, text: "Task #1", start_date: "2023-05-01", duration: 3},
    {id: 2, text: "Task #2", start_date: "2023-05-04", duration: 2}
  ]
});

Both libraries offer Gantt chart functionality, but DHTMLX/gantt provides a more comprehensive solution with additional features and customization options. gantt-task-react is simpler to use and integrate into React applications, while DHTMLX/gantt offers a broader range of capabilities at the cost of increased complexity and licensing requirements.

Gantt Gantt Gantt Timeline Schedule Calendar [ javascript gantt, js gantt, projects gantt, timeline, scheduler, gantt timeline, reservation timeline, react gantt, angular gantt, vue gantt, svelte gantt, booking manager ]

Pros of gantt-schedule-timeline-calendar

  • More feature-rich with advanced scheduling capabilities
  • Supports multiple views (timeline, calendar, resource)
  • Highly customizable with extensive API and event handling

Cons of gantt-schedule-timeline-calendar

  • Steeper learning curve due to complexity
  • Larger bundle size, potentially impacting performance
  • Less focused on simple Gantt chart functionality

Code Comparison

gantt-schedule-timeline-calendar:

import { GSTCResult } from 'gantt-schedule-timeline-calendar';
const App = () => (
  <GSTCResult config={config}>
    <GSTC />
  </GSTCResult>
);

gantt-task-react:

import { Gantt } from 'gantt-task-react';
const App = () => (
  <Gantt tasks={tasks} />
);

gantt-schedule-timeline-calendar offers more configuration options and flexibility, while gantt-task-react provides a simpler, more straightforward implementation for basic Gantt chart functionality.

🍞📅A JavaScript calendar that has everything you need.

Pros of tui.calendar

  • More comprehensive calendar functionality, including various view modes (daily, weekly, monthly)
  • Extensive customization options and theming capabilities
  • Robust documentation and examples

Cons of tui.calendar

  • Steeper learning curve due to its complexity
  • Larger bundle size, which may impact performance for simpler use cases
  • Less focused on Gantt chart-specific features

Code Comparison

tui.calendar:

import Calendar from '@toast-ui/react-calendar';

const MyCalendar = () => (
  <Calendar
    view="week"
    events={[
      { id: '1', calendarId: 'cal1', title: 'Event 1', start: '2023-05-01T10:00:00', end: '2023-05-01T12:00:00' },
    ]}
  />
);

gantt-task-react:

import { Gantt, Task, ViewMode } from 'gantt-task-react';

const tasks: Task[] = [
  { start: new Date(2023, 4, 1), end: new Date(2023, 4, 2), name: 'Task 1', id: '1', progress: 45, type: 'task' },
];

const MyGantt = () => <Gantt tasks={tasks} viewMode={ViewMode.Day} />;

tui.calendar offers a more feature-rich calendar component with various view options, while gantt-task-react provides a simpler, Gantt chart-focused solution. The code examples demonstrate the different approaches: tui.calendar uses a more complex event structure, while gantt-task-react focuses on task-specific properties.

A datepicker for twitter bootstrap (@twbs)

Pros of bootstrap-datepicker

  • Widely adopted and well-established library with extensive documentation
  • Seamless integration with Bootstrap, providing consistent styling
  • Supports a wide range of date formats and localization options

Cons of bootstrap-datepicker

  • Limited to date selection functionality, lacking task management features
  • May require additional libraries for more complex project management needs
  • Less suitable for visualizing project timelines or Gantt charts

Code Comparison

bootstrap-datepicker:

$('#datepicker').datepicker({
    format: 'mm/dd/yyyy',
    startDate: '-3d'
});

gantt-task-react:

<Gantt
  tasks={tasks}
  viewMode={ViewMode.Day}
  onDateChange={onTaskChange}
  onProgressChange={onProgressChange}
/>

The code snippets highlight the different focus of each library. bootstrap-datepicker is centered around date selection, while gantt-task-react provides a more comprehensive task management and visualization solution.

bootstrap-datepicker is ideal for simple date input needs, especially in Bootstrap-based projects. However, for project management and timeline visualization, gantt-task-react offers more specialized features and a richer set of components tailored for Gantt chart creation and task management.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

gantt-task-react

Interactive Gantt Chart for React with TypeScript.

example

Live Demo

Install

npm install gantt-task-react

How to use it

import { Gantt, Task, EventOption, StylingOption, ViewMode, DisplayOption } from 'gantt-task-react';
import "gantt-task-react/dist/index.css";

let tasks: Task[] = [
    {
      start: new Date(2020, 1, 1),
      end: new Date(2020, 1, 2),
      name: 'Idea',
      id: 'Task 0',
      type:'task',
      progress: 45,
      isDisabled: true,
      styles: { progressColor: '#ffbb54', progressSelectedColor: '#ff9e0d' },
    },
    ...
];
<Gantt tasks={tasks} />

You may handle actions

<Gantt
  tasks={tasks}
  viewMode={view}
  onDateChange={onTaskChange}
  onTaskDelete={onTaskDelete}
  onProgressChange={onProgressChange}
  onDoubleClick={onDblClick}
  onClick={onClick}
/>

How to run example

cd ./example
npm install
npm start

Gantt Configuration

GanttProps

Parameter NameTypeDescription
tasks*TaskTasks array.
EventOptioninterfaceSpecifies gantt events.
DisplayOptioninterfaceSpecifies view type and display timeline language.
StylingOptioninterfaceSpecifies chart and global tasks styles

EventOption

Parameter NameTypeDescription
onSelect(task: Task, isSelected: boolean) => voidSpecifies the function to be executed on the taskbar select or unselect event.
onDoubleClick(task: Task) => voidSpecifies the function to be executed on the taskbar onDoubleClick event.
onClick(task: Task) => voidSpecifies the function to be executed on the taskbar onClick event.
onDelete*(task: Task) => void/boolean/Promise/PromiseSpecifies the function to be executed on the taskbar on Delete button press event.
onDateChange*(task: Task, children: Task[]) => void/boolean/Promise/PromiseSpecifies the function to be executed when drag taskbar event on timeline has finished.
onProgressChange*(task: Task, children: Task[]) => void/boolean/Promise/PromiseSpecifies the function to be executed when drag taskbar progress event has finished.
onExpanderClick*onExpanderClick: (task: Task) => void;Specifies the function to be executed on the table expander click
timeStepnumberA time step value for onDateChange. Specify in milliseconds.

* Chart undoes operation if method return false or error. Parameter children returns one level deep records.

DisplayOption

Parameter NameTypeDescription
viewModeenumSpecifies the time scale. Hour, Quarter Day, Half Day, Day, Week(ISO-8601, 1st day is Monday), Month, QuarterYear, Year.
viewDatedateSpecifies display date and time for display.
preStepsCountnumberSpecifies empty space before the fist task
localestringSpecifies the month name language. Able formats: ISO 639-2, Java Locale.
rtlbooleanSets rtl mode.

StylingOption

Parameter NameTypeDescription
headerHeightnumberSpecifies the header height.
ganttHeightnumberSpecifies the gantt chart height without header. Default is 0. It`s mean no height limitation.
columnWidthnumberSpecifies the time period width.
listCellWidthstringSpecifies the task list cell width. Empty string is mean "no display".
rowHeightnumberSpecifies the task row height.
barCornerRadiusnumberSpecifies the taskbar corner rounding.
barFillnumberSpecifies the taskbar occupation. Sets in percent from 0 to 100.
handleWidthnumberSpecifies width the taskbar drag event control for start and end dates.
fontFamilystringSpecifies the application font.
fontSizestringSpecifies the application font size.
barProgressColorstringSpecifies the taskbar progress fill color globally.
barProgressSelectedColorstringSpecifies the taskbar progress fill color globally on select.
barBackgroundColorstringSpecifies the taskbar background fill color globally.
barBackgroundSelectedColorstringSpecifies the taskbar background fill color globally on select.
arrowColorstringSpecifies the relationship arrow fill color.
arrowIndentnumberSpecifies the relationship arrow right indent. Sets in px
todayColorstringSpecifies the current period column fill color.
TooltipContentSpecifies the Tooltip view for selected taskbar.
TaskListHeaderSpecifies the task list Header view
TaskListTableSpecifies the task list Table view
  • TooltipContent: React.FC<{ task: Task; fontSize: string; fontFamily: string; }>;
  • TaskListHeader: React.FC<{ headerHeight: number; rowWidth: string; fontFamily: string; fontSize: string;}>;
  • TaskListTable: React.FC<{ rowHeight: number; rowWidth: string; fontFamily: string; fontSize: string; locale: string; tasks: Task[]; selectedTaskId: string; setSelectedTask: (taskId: string) => void; }>;

Task

Parameter NameTypeDescription
id*stringTask id.
name*stringTask display name.
type*stringTask display type: task, milestone, project
start*DateTask start date.
end*DateTask end date.
progress*numberTask progress. Sets in percent from 0 to 100.
dependenciesstring[]Specifies the parent dependencies ids.
stylesobjectSpecifies the taskbar styling settings locally. Object is passed with the following attributes:
- backgroundColor: String. Specifies the taskbar background fill color locally.
- backgroundSelectedColor: String. Specifies the taskbar background fill color locally on select.
- progressColor: String. Specifies the taskbar progress fill color locally.
- progressSelectedColor: String. Specifies the taskbar progress fill color globally on select.
isDisabledboolDisables all action for current task.
fontSizestringSpecifies the taskbar font size locally.
projectstringTask project name
hideChildrenboolHide children items. Parameter works with project type only

*Required

License

MIT

NPM DownloadsLast 30 Days