Package: netkiller-gantt
netkiller-ganttBest project gantt charts in PythonPython Gantt 工具安装依赖MacOS 环境brewinstallcairo
brewinstallpkg-config
pip3installpycairo-ihttps://pypi.tuna.tsinghua.edu.cn/simpleLinux 环境dnfinstall-ycairo-develpython3-cairopython3-pillow配置镜像pipconfigsetglobal.index-urlhttps://pypi.tuna.tsinghua.edu.cn/simple

root@netkiller~#cat/root/.config/pip/pip.conf[global]index-url=https://pypi.tuna.tsinghua.edu.cn/simple安装 netkiller-ganttpipinstallnetkiller-gantt-ihttps://pypi.tuna.tsinghua.edu.cn/simple命令帮助root@netkiller~#ganttUsage:gantt[options]Options:-h,--helpshowthishelpmessageandexit--stdincatgantt.json|gantt-sfile.svg-c/path/to/gantt.csv,--csv=/path/to/gantt.csv/path/to/gantt.csv-l/path/to/gantt.json,--load=/path/to/gantt.jsonloaddatafromfile.-d,--debugdebugmodeloadingdatafrommysql:-Hlocalhost,--host=localhost-uroot,--username=root-pPASSWORD,--password=PASSWORD-Dtest,--database=testCharts:-t项目甘特图,--title=项目甘特图甘特图标题-W5,--workweeks=5workweeksdefault5-g,--ganttGanttchart-w,--workloadWorkloadchart-s/path/to/gantt.svg,--save=/path/to/gantt.svgsavefile

Homepage:https://www.netkiller.cnAuthor:Neo<netkiller@msn.com>生成甘特图从标准输出载入json数据生成甘特图准备 json 文件{"1":{"id":1,"name":"开发需求排期","start":"2023-02-22","finish":"2023-03-03","subitem":{"11":{"id":11,"name":"用户登录开发","start":"2023-02-22","finish":"2023-02-24","progress":4,"resource":"陈景峰"},"12":{"id":12,"name":"权限角色开发","start":"2023-02-27","finish":"2023-03-03","resource":"Neo","progress":5,"predecessor":11},"2":{"id":"2","name":"测试任务排期","start":"2023-03-01","finish":"2023-03-15","subitem":{"21":{"id":21,"name":"用户登陆测试","start":"2023-03-01","finish":"2023-03-08","resource":"陈景峰","progress":4},"22":{"id":22,"name":"权限角色测试","start":"2023-03-09","finish":"2023-03-15","resource":"netkiller","progress":0,"predecessor":21}}}}},"3":{"id":3,"name":"任务组测试","start":"2023-02-25","finish":"2023-03-10","resource":"陈景峰","progress":3,"subitem":{"4":{"id":4,"name":"Java","start":"2023-02-24","finish":"2023-02-27","resource":"司空摘星","progress":2},"5":{"id":5,"name":"PHP","start":"2023-03-03","finish":"2023-03-15","resource":"阿不都沙拉木","progress":5,"predecessor":4,"subitem":{"83":{"id":83,"name":"V7.0","start":"2023-03-03","finish":"2023-03-05","predecessor":82,"subitem":{"83":{"id":83,"name":"V8.0","start":"2023-03-06","finish":"2023-03-10","predecessor":82,"subitem":{"83":{"id":83,"name":"V8.5","start":"2023-03-13","finish":"2023-03-16","predecessor":82}}}}}}},"6":{"id":"6","name":"Go","start":"2023-03-10","finish":"2023-03-20","milestone":true},"7":{"id":7,"name":"Python","start":"2023-03-06","finish":"2023-03-08","predecessor":5},"8":{"id":8,"name":"Swift","start":"2023-02-27","finish":"2023-03-16","subitem":{"81":{"id":81,"name":"LLVM","start":"2023-02-28","finish":"2023-03-06","predecessor":4},"82":{"id":82,"name":"Clang","start":"2023-03-07","finish":"2023-03-10","predecessor":81},"83":{"id":83,"name":"Rust","start":"2023-03-13","finish":"2023-03-16","predecessor":82}}}}}}开始生成 Gantt 甘特图neo@MacBook-Pro-M2~>catgantt.json|gantt--stdin
/Users/neo/workspace/GitHub/devops
Usage:gantt[options]message

Options:-h,--helpshowthishelpmessageandexit-l/path/to/gantt.json,--load=/path/to/gantt.jsonloaddatafromfile.-s/path/to/gantt.svg,--save=/path/to/gantt.svgsavefile--stdincatgantt.json|gantt-sfile.svg-d,--debugdebugmode从 CSV 文件生成从禅道导出 csv 文件selectid,parent,name,estStarted,deadline,assignedTofromzt_taskINTOOUTFILE'/tmp/project.csv'FIELDSENCLOSEDBY'"'TERMINATEDBY‘,’ESCAPEDBY'"'LINESTERMINATEDBY'\r\n';命令行执行方法rm-rf/tmp/project.csv
cat<<EOF | mysql -h127.0.0.1 -uroot -p123456 zentaoSELECT 'id','name','start','finish', 'resource', 'parent'UNIONselect id, name,estStarted,deadline,assignedTo, parent  from zt_taskINTO OUTFILE '/tmp/project.csv'FIELDS ENCLOSED BY '"'TERMINATED BY ','ESCAPED BY '"'LINES TERMINATED BY '\r\n';EOF如果导出指定的资源，可以通过查询 assignedTo 实现select id, name,estStarted as start, deadline as finish,  assignedTo as resource, parent from zt_task where `group` = 4 order by id desc limit 100;
select id, name,estStarted as start, deadline as finish,  assignedTo as resource, parent from zt_task where assignedTo in ('neo','netkiller','tom','jerry') order by id desc limit 100;从 MySQL 数据库生成甘特图注意：MySQL 5.7 和 MySQL 8.0 有略微差别MySQL 5.7CREATETABLE`project`(`id`bigint(20)NOTNULLAUTO_INCREMENT,`name`varchar(255)NOTNULLCOMMENT'任务名称',`start`dateNOTNULLCOMMENT'开始日期',`finish`dateNOTNULLCOMMENT'完成日期',`resource`varchar(255)DEFAULTNULLCOMMENT'资源',`predecessor`bigint(20)DEFAULTNULLCOMMENT'前置任务',`milestone`bit(1)DEFAULTNULLCOMMENT'里程碑',`parent`bigint(20)DEFAULTNULLCOMMENT'父任务',`status`enum('Enabled','Disabled')DEFAULT'Enabled'COMMENT'状态',PRIMARYKEY(`id`),KEY`project_has_subproject`(`parent`),CONSTRAINT`project_has_subproject`FOREIGNKEY(`parent`)REFERENCES`project`(`id`))ENGINE=InnoDBAUTO_INCREMENT=6DEFAULTCHARSET=utf8mb4MySQL 8.0CREATETABLE`project`(`id`bigintunsignedNOTNULLAUTO_INCREMENT,`name`varchar(255)CHARACTERSETutf8mb4COLLATEutf8mb4_general_ciNOTNULLCOMMENT'任务名称',`start`dateNOTNULLDEFAULT(curdate())COMMENT'开始日期',`finish`dateNOTNULLDEFAULT(curdate())COMMENT'完成日期',`resource`varchar(255)CHARACTERSETutf8mb4COLLATEutf8mb4_general_ciDEFAULTNULLCOMMENT'资源',`predecessor`bigintunsignedDEFAULTNULLCOMMENT'前置任务',`milestone`bit(1)DEFAULTb'0'COMMENT'里程碑',`parent`bigintunsignedDEFAULTNULLCOMMENT'父任务',PRIMARYKEY(`id`),KEY`project_has_subproject`(`parent`),KEY`task_has_predecessor_idx`(`predecessor`),CONSTRAINT`project_has_subproject`FOREIGNKEY(`parent`)REFERENCES`project`(`id`))ENGINE=InnoDBDEFAULTCHARSET=utf8mb4COLLATE=utf8mb4_general_ci插入测试数据INSERTINTO`project`(`id`,`name`,`start`,`finish`,`resource`,`predecessor`,`milestone`,`parent`)VALUES(1,'任务组','2023-03-26','2023-04-10','小明',NULL,'0',NULL);INSERTINTO`project`(`id`,`name`,`start`,`finish`,`resource`,`predecessor`,`milestone`,`parent`)VALUES(2,'任务A','2023-03-26','2023-03-29','小明',NULL,'0',1);INSERTINTO`project`(`id`,`name`,`start`,`finish`,`resource`,`predecessor`,`milestone`,`parent`)VALUES(3,'任务B','2023-03-31','2023-04-01','小张',2,'0',1);INSERTINTO`project`(`id`,`name`,`start`,`finish`,`resource`,`predecessor`,`milestone`,`parent`)VALUES(4,'任务C','2023-04-02','2023-04-08','小张',3,'0',1);INSERTINTO`project`(`id`,`name`,`start`,`finish`,`resource`,`predecessor`,`milestone`,`parent`)VALUES(5,'里程碑','2023-04-06','2023-04-06',NULL,NULL,'1',NULL);bit(1) 类型数据更新注意事项UPDATE`test`.`project`SET`milestone`=b'001'WHERE(`id`='11');生成甘特图gantt--hostmysql.netkiller.cn-uroot-ppassw0rd--databasetest-g