|
| 1 | +import React, { useRef, useEffect } from 'react' |
| 2 | +import { Gantt, Willow } from 'wx-react-gantt' |
| 3 | +import 'wx-react-gantt/dist/gantt.css' |
| 4 | +const ReactGantt = () => { |
| 5 | + const tasks = [ |
| 6 | + { |
| 7 | + id: 20, |
| 8 | + text: 'New Task', |
| 9 | + start: new Date(2024, 5, 11), |
| 10 | + end: new Date(2024, 6, 12), |
| 11 | + duration: 1, |
| 12 | + progress: 2, |
| 13 | + type: 'task', |
| 14 | + lazy: false, |
| 15 | + }, |
| 16 | + { |
| 17 | + id: 47, |
| 18 | + text: '[1] Master project', |
| 19 | + start: new Date(2024, 5, 12), |
| 20 | + end: new Date(2024, 7, 12), |
| 21 | + duration: 8, |
| 22 | + progress: 0, |
| 23 | + parent: 0, |
| 24 | + type: 'summary', |
| 25 | + }, |
| 26 | + { |
| 27 | + id: 22, |
| 28 | + text: 'Task', |
| 29 | + start: new Date(2024, 7, 11), |
| 30 | + end: new Date(2024, 8, 12), |
| 31 | + duration: 8, |
| 32 | + progress: 0, |
| 33 | + parent: 47, |
| 34 | + type: 'task', |
| 35 | + }, |
| 36 | + { |
| 37 | + id: 21, |
| 38 | + text: 'New Task 2', |
| 39 | + start: new Date(2024, 7, 10), |
| 40 | + end: new Date(2024, 8, 12), |
| 41 | + duration: 3, |
| 42 | + progress: 0, |
| 43 | + type: 'task', |
| 44 | + lazy: false, |
| 45 | + }, |
| 46 | + ] |
| 47 | + |
| 48 | + const links = [{ id: 1, source: 20, target: 21, type: 'e2e' }] |
| 49 | + |
| 50 | + const scales = [ |
| 51 | + { unit: 'month', step: 1, format: 'MMMM yyy' }, |
| 52 | + { unit: 'day', step: 1, format: 'd' }, |
| 53 | + ] |
| 54 | + |
| 55 | + return ( |
| 56 | + <Willow> |
| 57 | + <Gantt tasks={tasks} links={links} scales={scales} /> |
| 58 | + </Willow> |
| 59 | + ) |
| 60 | +} |
| 61 | + |
| 62 | +export default ReactGantt |
0 commit comments