我在 Vega 中的分区转换是否正确编写,因为可视化的图形不准确

Is my partition transform in Vega written correctly because the graph that is visualized is not accurate

我正在 Vega 中创建数据的分层表示。为此,我使用了分层和分区转换。发生的问题在于分区转换生成的 x 坐标。在 link 中,导航至数据查看器和 select 树状图。初始 id 的 x0 和 x1 是最顶层的元素,层次结构中的“已完成的故事”范围为 0 - 650。接下来的两个元素“可测试”和“不可测试”的组合 x 范围应为 0 - 650。但是,它们的范围是 0 - 455。宽度应基于它们的数量,位于“数量”字段中。关于为什么生成的矩形与数量不相称的任何建议。

Link to Vega Editor with code shown

对于您的数据集“rawNumbers”,在使用分层变换时,只应为“离开”节点提供值。

    {
  "name": "rawNumbers",
  "values": [
    {"id": "completed stories", "parent": null},
    {"id": "testable", "parent": "completed stories"},
    {"id": "not testable", "parent": "completed stories", "amount": 1435},
    {"id": "sufficiently tested", "parent": "testable"},
    {"id": "insufficiently tested", "parent": "testable"},
    {"id": "integration tested", "parent": "sufficiently tested", "amount": 1758},
    {"id": "unit tested", "parent": "sufficiently tested", "amount": 36},
    {"id": "partial coverage", "parent": "insufficiently tested", "amount": 298},
    {"id": "no coverage", "parent": "insufficiently tested", "amount": 341}
  ]
},

Open in Vega Editor