AdeelK93 / collapsibleTree

Create Interactive Collapsible Tree Diagrams in R using D3.js
https://adeelk93.github.io/collapsibleTree/
158 stars 41 forks source link

[feature request] allow xml source as the input data #21

Closed xfdeng2008 closed 6 years ago

xfdeng2008 commented 6 years ago

Since xml itself is already represented as a nice tree, can collapsible tree display an xml file as it is?

It will be nice to allow XML as an input directly without transform it into a tabular form suppose someone already have the XML file and just would like to display it as it is (or allow certain level of modifications)

AdeelK93 commented 6 years ago

Haha I wouldn't exactly call xml a "nice tree", xml can present a lot more complexity as a data structure than a corresponding json, and many more ways of representing the same information.

Working with files directly is a bit out of scope for a charting library, but there is good news! You don't need to transform the data into tabular form if you don't want to, you can work with data.tree recursive structures directly!

What you could do is import the xml into R with a package like xml2, and once you're able get your xml parsed as a native R list, you can coerce it into a data.tree node and pass that directly to collapsibleTree. How does that sound?