"D3.js Entry Series---9.5" Tree chart production

Source: Internet
Author: User

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.  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.