1.0.13 • Published 6 months ago

react-gantt-antd-tokrak v1.0.13

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

React-gantt-antd-tokrak

A beautiful react gantt component with antd style. This is a fork of JSainsburyPLC/react-timelines

snapshot

Install

yarn add react-gantt-antd-tokrak

Example

import React from 'react'
import Gantt from 'react-gantt-antd-tokrak'
import 'react-gantt-antd-tokrak/lib/css/style.css'

export default function App() {
  const tasks_a = [
    {
      id: "task0",
      index: 0,
      title: "任务名称1",
      start: new Date('2020-06-01'),
      end: new Date('2020-08-02'),
      tooltip: "任务全称1";
    }
  ]

  const tasks_b = [
    {
      id: "task1",
      index: 1,
      title: "任务名称2",
      start: new Date('2020-07-01'),
      end: new Date('2020-09-02'),
    }
  ]

  const sub_projects = [
    {
      id: "sub_project1",
      index: 1,
      title: "子项目",
      tasks: tasks_b,
    }
  ]

  const projects = [
    {
      id: "project1",
      index: 0,
      title: "项目1",
      tasks: tasks_a,
      projects: sub_projects,
      isOpen: false,
    }
  ]

  const clickTask = e => {
    console.log(e);
  };

  const clickProject = e => {
    console.log(e);
  };

  return (
    <Gantt
      start={new Date('2020-06-01')}
      end={new Date('2020-10-01')}
      now={new Date('2020-7-01')}
      zoom={1}
      sidebarWidth={240}
      minWidth={800}
      projects={projects}
      enableSticky={true}
      scrollToNow={true}
      clickTask={clickTask}
      clickProject={clickProject}
    />
  )
}

export default App

API

Gantt

PropertyvaluedefaultDescriptions
startDateThe start date of the timeline
endDateThe start date of the timeline
nowDatenew Date()'now' marker position
zoomNumber1The scale of the timeline width
projectsList[]The project list
minWidthNumber800The min width of the timeline when resizing the window
sidebarWidthNumber240The width of the sidebar
clickProjectfunctionwhen click project element
clickTaskfunctionwhen click task element
enableStickyBooltrueDetermine whether the header is sticky or not
scrollToNowBooltrueDetermine whether to scroll to the now marker at first or not

Project

PropertyvaluedefaultDescriptions
maintPrjIdString/NumberThe id of the Project
indexNumberThe index of the Project
maintPrjNameString/ElementThe title of the Project
maintTasksListAll the tasks of the Project
projectsListAll the sub projects of the Project
isOpenBoolfalseDetermine whether the project is folded not

Task

PropertyvaluedefaultDescriptions
maintTaskIdString/NumberThe id of the Task
indexNumberThe index of the Task
taskNameString/ElementThe title of the Task
beginTimeDateThe start date of the Task
endTimeDateThe start date of the Task
tooltipStringThe tooltip of the Task

Development

yarn install
yarn watch
yarn build
npm config set registry=http://registry.npmjs.org
npm config set registry=https://registry.npm.taobao.org/