gpt4 book ai didi

javascript - 如何更改 dhtmlx 甘特图中的日期格式?

转载 作者:行者123 更新时间:2023-11-28 05:19:58 24 4
gpt4 key购买 nike

我有一个从 Gantt Docs 下载的甘特图模板

好吧,我调用了我的甘特图,但我想将时间范围设置为 2015-2023 年,而不是让它默认为天/月,但我不知道在哪里可以更改它。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Tooltip</title>
</head>
<script src="../../codebase/dhtmlxgantt.js" type="text/javascript" charset="utf-8"></script>
<script src="../../codebase/ext/dhtmlxgantt_tooltip.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../../codebase/dhtmlxgantt.css" type="text/css" media="screen" title="no title" charset="utf-8">

<script type="text/javascript" src="../common/testdata.js"></script>
<style type="text/css">
html, body{ height:100%; padding:0px; margin:0px; overflow: hidden;}
</style>
<body>
<div id="gantt_here" style='width:100%; height:100%;'></div>

<script type="text/javascript">

var tasks = {
data:[
{id:1, text:"Project #2", start_date:"01-04-2013", duration:18,order:10,
progress:0.4, open: true},
{id:2, text:"Task #1", start_date:"02-04-2013", duration:8, order:10,
progress:0.6, parent:1},
{id:3, text:"Task #2", start_date:"11-04-2013", duration:8, order:20,
progress:0.6, parent:1}
],
links:[
{ id:1, source:1, target:2, type:"1"},
{ id:2, source:2, target:3, type:"0"},
{ id:3, source:3, target:4, type:"0"},
{ id:4, source:2, target:5, type:"2"},
]
};

gantt.init("gantt_here");
gantt.parse(tasks);

gantt.init("gantt_here");
gantt.parse(demo_tasks);
</script>
</body>
</html>

最佳答案

将duration unit config的值设置为year:

gantt.config.duration_unit = "year";

默认值:“天”。

关于javascript - 如何更改 dhtmlx 甘特图中的日期格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40047864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com