react 甘特图之旅

  1. react-gantt

    GitHub 仓库: https://github.com/clayrisser/react-gantt

  2. react-gantt-chart

    GitHub 仓库: https://github.com/MaTeMaTuK/gantt-task-react

  3. easy-gant-beta

    GitHub 仓库: https://github.com/web-widgets/react-gantt-demos

上面的版本不兼容

  1. dhtmlx-gantt
    官方网站: https://docs.dhtmlx.com/gantt/
    GitHub 仓库: https://github.com/dhtmlx/dhtmlx-gantt

试用版

npm install @dhx/trial-gantt 安装不了

npm install dhtmlx-gantt 标准版(免费)

可以参考:https://dhtmlx.com/blog/create-react-gantt-chart-component-dhtmlxgantt/

安装

javascript 复制代码
 npm install @bryntum/gantt-trial    

5、 syncfusion/ej2-react-gantt 收费, 30天免费试用
syncfusion/ej2-react-gantt

javascript 复制代码
npm install @syncfusion/ej2-react-gantt
npm list @syncfusion/ej2-buttons @syncfusion/ej2-base

6、kendo-react-ui 收费
kendo-react-ui

javascript 复制代码
npm install @progress/kendo-react-gantt 
 
npm install @progress/kendo-react-common
npm install @progress/kendo-react-grid 

综上,我推荐dhtmlx-gantt 免费版,

javascript 复制代码
import React, { useEffect, useRef } from 'react';
import { gantt } from 'dhtmlx-gantt';
import 'dhtmlx-gantt/codebase/dhtmlxgantt.css';
 


const Dhtmlx = () => {
  const container = useRef<HTMLDivElement>(null);

  const data = {
    data: [
      { id: 1, text: "Project #1", start_date: null, duration: null, parent: 0, progress: 0, open: true },
      { id: 2, text: "Task #1", start_date: "2024-08-01 00:00", duration: 1, parent: 1, progress: 1 },
      { id: 3, text: "Task #2", start_date: "2024-08-06 00:00", duration: 2, parent: 1, progress: 0.5 },
      { id: 4, text: "Task #3", start_date: null, duration: null, parent: 1, progress: 0.8, open: true },
      { id: 5, text: "Task #3.1", start_date: "2024-08-09 00:00", duration: 2, parent: 4, progress: 0.2 },
      { id: 6, text: "Task #3.2", start_date: "2024-08-11 00:00", duration: 1, parent: 4, progress: 0 }
    ],
    links: [
      { id: 1, source: 2, target: 3, type: "0" },
      { id: 2, source: 3, target: 4, type: "0" },
      { id: 3, source: 5, target: 6, type: "0" }
    ]

  };

  useEffect(() => {
    if (container.current) {
      gantt.config.date_format = "%Y-%m-%d %H:%i";
      gantt.init(container.current);
      gantt.parse(data);
    }

    return () => {
      gantt.clearAll();
    };
  }, []);
  return (
    <div>
      <div ref={container} style={{ width: '100%', height: '500px' }}></div>
    </div>
  )

}

export default Dhtmlx 
 
相关推荐
dleei1 小时前
彻底淘汰老旧 SVG 插件:unplugin-icons 与 Tailwind CSS v4 自定义图标最佳实践
前端·程序员·前端框架
LlNingyu1 小时前
文艺复兴,什么是XSS,常见形式(二)
前端·安全·xss
明君879971 小时前
说说我为什么放弃使用 GetX,转而使用 flutter_bloc + GetIt
前端·flutter
Jingyou1 小时前
用 Astro 搭建个人博客:从零到上线的完整实践
前端
吴声子夜歌1 小时前
JavaScript——call()、apply()和bind()
开发语言·前端·javascript
高桥凉介发量惊人2 小时前
质量与交付篇(2/6):CI/CD 实战——自动构建、签名、分发
前端
leafyyuki2 小时前
SSE 同域长连接排队问题解析与前端最佳实践
前端·javascript·人工智能
高桥凉介发量惊人2 小时前
质量与交付篇(3/6):崩溃分析与线上问题回溯机制
前端
angerdream2 小时前
最新版vue3+TypeScript开发入门到实战教程之路由详解三
前端·javascript·vue.js
毕设源码-郭学长2 小时前
【开题答辩全过程】以 基于Web的网上问诊系统的设计与实现为例,包含答辩的问题和答案
前端