在HighCharts Gantt中垂直和水平分组

时间:2019-06-17 13:07:05

标签: highcharts

显然,我正在尝试做的一件简单的事情是将任务水平和垂直地分组。我已遵循以下官方文档: https://www.highcharts.com/docs/gantt/gantt-grouping-tasks

但是,在下面的小提琴中,任务部分甚至没有出现在我的“验收测试”任务中。我的选择如下:

Highcharts.ganttChart('container', {
  title: {
    text: 'Grouping in a hierarchy'
  }, 

  series: [{
    name: 'Project 1',
    data: [
      {
        // parent task
        name: 'Product Launch',
        id: 'launch',        
        // hide the subtasks
        // collapsed: true

        // use a smaller pointwidth for the parent task 
        pointWidth: 3
      }, {
        parent: 'launch',
        id: 'b',
        name: 'Develop',
        "start": 1560902400000,
            "end": 1561075200000
      }, {
        parent: 'launch',
        id: 'a',
        name: 'Run acceptance tests',
            data:[{start: 1560902400000,
            end: 1561075200000},{start: 1561507200000,
            end: 1561680000000}]


      }
    ]
  }]
});

https://jsfiddle.net/rdvaqgkh/

关于为什么会这样的任何想法? 谢谢!

1 个答案:

答案 0 :(得分:0)

您不能以这种方式嵌套数据。要在一行中包含多个点,您需要将yAxis.uniqueNames设置为true并定义相同名称的点:

yAxis: {
    uniqueNames: true
},

series: [{
    data: [{
        // parent task
        name: 'Product Launch',
        id: 'launch',
        ...
    }, {
        parent: 'launch',
        id: 'b',
        name: 'Develop',
        ...
    }, {
        parent: 'launch',
        id: 'a',
        name: 'Run acceptance tests',
        ...
    }, {
        parent: 'launch',
        id: 'b',
        name: 'Run acceptance tests',
        ...
    }]
}]

实时演示: https://jsfiddle.net/BlackLabel/9en0zq3L/

API参考: https://api.highcharts.com/gantt/yAxis.uniqueNames