You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Highcharter R包WBS图布局问题:任务垂直对齐与排序异常

使用Highcharter R包制作对齐的WBS工作分解结构图

我正在用Highcharter R包制作WBS(工作分解结构)图,需要让每个行动下的任务垂直对齐在其父节点正下方,而非分散排列。已查阅Highcharts官方文档,但未找到合适的配置选项。

目前我的代码生成的图表接近预期,但存在两个问题:

  • 已实现列位置控制,但无法控制行位置
  • 第8列的任务排序混乱,不符合预期

现有代码

library(highcharter)

highchart() %>%
  hc_chart(type = 'organization', inverted = TRUE) %>%
  hc_title(text = 'WBS') %>%
  hc_add_series(
    name = 'WBS',
    data = list(
        #Liste action
        list(from = 'T', to = 'A1'),
        list(from = 'T', to = 'A2'),
        list(from = 'T', to = 'A3'),
        list(from = 'T', to = 'A4'),
            
            #A1
            list(from = 'A1', to = 'b1'),
            list(from = 'b1', to = 'P'),
            list(from = 'P', to = 'F1'),
            list(from = 'F1', to = 'AqDo'),
            list(from = 'AqDo', to = 'Ay1'),
            list(from = 'Ay1', to = 'R1'),
            list(from = 'R1', to = 'Ar1'),
            
            #A2
            list(from = 'A2', to = 'b2'),
            list(from = 'b2', to = 'Cx'),
            list(from = 'Cx', to = 'F2'),
            list(from = 'F2', to = 'Pr'),
            list(from = 'Pr', to = 'Ay2'),
            list(from = 'Ay2', to = 'R2'),
            list(from = 'R2', to = 'Ar2'),
            
            #A3
            list(from = 'A3', to = 'b3'),
            list(from = 'b3', to = 'Cx'),
            list(from = 'Cx', to = 'F3'),
            list(from = 'F3', to = 'Pr'),
            list(from = 'Pr', to = 'Ay4'),
            list(from = 'Ay4', to = 'R3'),
            list(from = 'R3', to = 'Ar3'),
            
            #A4
            list(from = 'A4', to = 'Ar4')
    ),
    nodes = list(
        #task list
        list(id = 'T', name = "name", title = "title", color = '#081358', dataLabels = list(color = 'white'), column = 0),
        list(id = 'A1', title = 'action1', color = '#2D2F51', dataLabels = list(color = 'white'), column = 1),
        list(id = 'A2', title = 'action2', color = '#2D2F51', dataLabels = list(color = 'white'), column = 1),
        list(id = 'A3', title = 'action3', color = '#2D2F51', dataLabels = list(color = 'white'), column = 1),      
        list(id = 'A4', title = 'action4', color = '#2D2F51', dataLabels = list(color = 'white'), column = 1),
            
            #A1
            list(id = 'b1', title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 2),
            list(id = 'P',  title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 3),
            list(id = 'F1', title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 4),
            list(id = 'AqDo', title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 5),
            list(id = 'Ay1', title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 6),
            list(id = 'R1', title = 'A1', color = '#9EC3E7', dataLabels = list(color = 'black'), column = 7),
            list(id = 'Ar1', title = 'A1', color = '#B94331', dataLabels = list(color = 'white'), column = 8),
            
            #A2
            list(id = 'b2', title = 'A2', color = '#2491A9', dataLabels = list(color = 'black'), column = 2),
            list(id = 'Cx', title = 'A2 + A3', color = '#2BA8C4', dataLabels = list(color = 'black'), column = 3),
            list(id = 'F2', title = 'A2', color = '#2491A9', dataLabels = list(color = 'black'), column = 4),
            list(id = 'Pr', title = 'A2 + A3', color = '#2BA8C4', dataLabels = list(color = 'black'), column = 5),
            list(id = 'Ay2', title = 'A2', color = '#2491A9', dataLabels = list(color = 'black'), column = 6),
            list(id = 'R2', title = 'A2', color = '#2491A9', dataLabels = list(color = 'black'), column = 7),
            list(id = 'Ar2', title = 'A2', color = '#B94331', dataLabels = list(color = 'white'), column = 8),
           
            #A3
            list(id = 'b3', title = 'A3', color = '#34D1F4', dataLabels = list(color = 'black'), column = 2),
            list(id = 'F3', title = 'A3', color = '#34D1F4', dataLabels = list(color = 'black'), column = 4),
            list(id = 'Ay4', title = 'A3', color = '#34D1F4', dataLabels = list(color = 'black'), column = 6),
            list(id = 'R3', title = 'A3', color = '#34D1F4', dataLabels = list(color = 'black'), column = 7),
            list(id = 'Ar3', title = 'A3', color = '#B94331', dataLabels = list(color = 'white'), column = 8),
            
            #A4
            list(id = 'Ar4', title = 'A4', color = '#B94331', dataLabels = list(color = 'white'), column = 8)
    )
  )

当前图表效果

WBS图效果

我考虑过修改CSS、HTML或JavaScript代码,但作为R包,Highcharter应该提供对应的配置选项,因此希望找到无需修改底层代码的解决方案。


内容的提问来源于stack exchange,提问作者VincentP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 20:40:46