This section learns how to make a tree chart. The tree chart is made in the same way as the cluster diagram, and the data after the two layout transformations is similar.
My personal blog is: www.ourd3js.com
CSDN Blog for: blog.csdn.net/lzhlzz
Reprint please indicate the source, thank you.
A tree chart is typically used to represent hierarchies, subordinates, inclusions, and contained relationships. The production of the tree chart is almost identical to the code of the 9.4-section cluster diagram. Yes, you're right, almost exactly the same. So why separate the two diagrams, and how are they different? Let's take a look at the different results for the same set of data. The data are:
{"Name": "China", "children": [{ "name": "Zhejiang", "Children": [{"Name": " Hangzhou"}, {"name": "Ningbo"}, {" Name ":" "Wenzhou"}, {"name": "Shaoxing"} ] }, {"name": "Guangxi", "Children": [{"Name": "Guilin", "children": [{"Name": "Xiufeng District "},{" name ":" Diecai District "},{" name ":" Xiangshan District "},{" name ":" Qixing District "}]},{" name ":" Nanning "},{" name ":" Liuzhou "},{" name ":" Fangchenggang "}]},{" name ":" Heilongjiang "," Children ": [{" Name ":" Harbin "},{" name ":" Qiqihar "},{" name ":" Mudanjiang "},{" name ":" Daqing "}]},{" name ":" Xinjiang "," children ": [{" Name ":" Urumqi "},{" name ":" Karamay "},{" name ":" Turpan "},{" name ":" Hami "}]}
The result of the cluster diagram is:
The result of the tree chart is:
Do you know what the difference is? Here is the code for the tree chart:
This code is exactly the same as the code in section 9.4. Except for 33 rows, the defined layout is changed from cluster to tree, and the others are the same.