使用非常简单:
<!-- 1. 导入甘特图插件 -->
<link rel="stylesheet" type="text/css" href="../../gantt/mzgantt.css" />
<!-- 2. 定义甘特图容器 -->
<div id="GanttChartDIV" style="width:90%;height:500px;"></div>
const myGantt = MZGantt.init();
var taskData= [{"id":11,
"name":"任务名称1",
"plan":[{"start":"2023-07-05","end":"2023-07-06","dur":10}],
"resId":"刘德华",
"pctComp":40,}];
myGantt.createGantt("GanttChartDIV", "day", {}, taskData);
一个完整html例子:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
<!-- 导入甘特图插件 -->
<link rel="stylesheet" type="text/css" href="../../gantt/mzgantt.css" />
<script language="javascript" src="../../gantt/mzgantt.js"></script>
</head>
<body>
<!-- 第一步:定义甘特图容器 -->
<div id="GanttChartDIV" style="width:90%;height:500px;"></div>
<script language="javascript">
var taskData= [
{
"id":11,
"name":"任务名称1",
"plan":[{"start":"2023-07-05","end":"2023-07-06","dur":10}],
"resId":"刘德华",
"pctComp":40,
},
{ "id":12,
"name":"任务名称2",
"plan":[{"start":"2023-07-07","end":"2023-07-16","dur":10}],
"resId":"张曼玉",
"planBarColor":"#F5A9D0",
"pctComp":20,
},
{ "id":13,
"name":"任务名称3",
"plan":[{"start":"2023-07-17","end":"2023-07-26","dur":10}],
"resId":"周星驰",
"pctComp":50,
}
];
const myGantt = MZGantt.init();
myGantt.createGantt("GanttChartDIV", "day", {}, taskData);
</script>
</body>
</html>