Search code examples
graphchartspartitionvegahierarchical

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


I am creating a hierarchical representation of data in Vega. To do this I am using the stratify and partition transformations. The issue that is occurring lies with the x coordinates that are generated with the partition transformation. In the link, navigate to data viewer and select tree-map. The x0 and x1 for the initial id, the top most element, "completed stories" within the hierarchy ranges from 0 - 650. The next two elements, "testable" & "not testable", should have a combined x range of 0 - 650. But instead, they range from 0 - 455. The width should be based on their quantities, located in the "amount" field. Any suggestions as to why the rectangle that is generated is not commensurate with the quantities.

Link to Vega Editor with code shown enter image description here


Solution

  • For your dataset "rawNumbers", values should only be provided for the "leave" nodes when using stratify transform.

        {
      "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

    enter image description here