首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在dhtmlx甘特图中设置日期、年份等行的自动高度

如何在dhtmlx甘特图中设置日期、年份等行的自动高度
EN

Stack Overflow用户
提问于 2020-12-27 02:33:47
回答 1查看 130关注 0票数 0

我有一些自定义的日期,月份等。在dhtmlx甘特图中的行。我想为每行设置固定的高度。我的意思是如果我也添加或删除行,高度不应该依赖于父height.It应该是constant.For示例-如果我也添加10行,每个单独行的高度应该是恒定的,但它保持减小以适合父高度。下面是代码

HTML/JAVASCRIPT

代码语言:javascript
运行
复制
<!DOCTYPE html>
<html>

<head>
  <link rel='stylesheet' type='text/css' href='http://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.css'>
  <script src='http://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js'></script>
  <style>
    .gantt_custom_button {
      background-color: rgb(206, 206, 206);
      position: absolute;
      right: -10px;
      top: 5px;
      width: 20px;
      height: 26px;
      border-radius: 0;
    }
  </style>


</head>
<div id='gantt_here' style='width:100%; height:500px;'></div>

<body>
  <script>
    var task1 = {
      'data': [{
          'id': 1,
          'text': 'Project #1',
          'start_date': '01-04-2019',
          'duration': 2,
          'order': 10,
          'progress': 0.4,
          'open': true
        },
        {
          'id': 2,
          'text': 'Task #1',
          'start_date': '02-04-2019',
          'duration': 1,
          'order': 10,
          'progress': 0.6,
          'parent': 1
        },
        {
          'id': 3,
          'text': 'Task #2',
          'start_date': '03-04-2019',
          'duration': 2,
          'order': 20,
          'progress': 0.6,
          'parent': 1
        },
        {
          'id': 4,
          'text': 'Task #3',
          'start_date': '05-04-2019',
          'duration': 1,
          'order': 10,
          '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.config['scales'] = [{
      unit: 'day',
      step: 1,
      format: '%d %M'
    },
    {unit: "year", step: 1, format: "%Y"},
    {unit: "month", step: 1, format: "%M"},
    {unit: "month", step: 1, format: "%M"},
    {unit: "month", step: 1, format: "%M"}
   //{unit: "month", step: 3, format: monthScaleTemplate},
    ];
    gantt.config.scale_height = 100; 
    
   
    gantt.init('gantt_here');
    gantt.parse(task1);
  </script>

</html>
EN

回答 1

Stack Overflow用户

发布于 2020-12-28 22:29:03

通常,无论图表中有多少任务,任务行高度都不会发生变化。并且有动态改变高度的内置功能。

您可以在代码片段中看到它是如何工作的:

http://snippet.dhtmlx.com/5/664877d50

如果这对您没有帮助,请在上面的代码片段中添加您的配置,并确保问题在那里重现。然后,单击Share按钮并将链接发送给我。或者给我一个所有必要的Javascript和CSS文件的现成演示,这样我就可以在本地重现这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65459480

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档