tasks
Description
Defines tasks in GanttUsage
tasks?: [
{
id: string|number,
// start is mandatory in incoming data; end or duration is optional - but one of them must be
start: Date,
end?: Date,
duration?:number,
text?: string,
progress?: number,
parent?: string|number,
type?: "task" | "summary" | "milestone" | any, //can be custom type
open?:boolean,
lazy?:boolean,
// data for task baseline
// base_start is mandatory in incoming data; end or duration is optional - but one of them must be
base_start?: Date,
base_end?: Date,
base_duration?: number
}
];
Parameters
Each task object in the array of tasks has the following parameters:
id
- (required) the task IDstart
- (required) the start date of a taskend
- (optional) the end date of a task; you should specify either the end date or duration not bothduration
- (optional) task duration in daysbase_start
- (required) the start date of a baselinebase_end
- (optional) the end date of a baseline; you should specify either the base_end or base_duration not bothbase_duration
- (optional) baseline duration in daysopen
- (optional) if true, in case a task has subtasks, the branch is open at initialization; if false, then it's closed.lazy
- (optional) if true, enables dynamic loading of child tasks (when the task branch is opened, the request for tasks data is sent to the backend), which means their content will not be loaded during the initial loading; if false, all tasks data is loaded at the initializationtext
- (optional) a task name; in case of no text name, set to ""progress
- (optional) task progress which is the percentage value from 0 to 100parent
- (optional) the parent task ID; in case of no parent, set to 0type
- (required) the task type which can be one of the following: "task", "summary", "milestone" or a custom one
info
The date format should be one of the supported by date-fns
Example
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
import React, { useRef, useEffect } from "react";
const GanttComponent = () => {
const { links, scales, columns } = getData();
const tasks = [
{
id: 1,
open: true,
start: new Date(2020, 11, 6),
duration: 8,
text: "React Gantt Widget",
progress: 60,
type: "summary"
},
{
id: 2,
parent: 1,
start: new Date(2020, 11, 6),
duration: 4,
text: "Lib-Gantt",
progress: 80
},
];
return <Gantt tasks={tasks} links={links} scales={scales} columns={columns} />;
};
export default GanttComponent;