pycharm——树状图

from pyecharts import options as opts
from pyecharts.charts import Tree


data = [
    {
        "children": [
            {"name": "计算机"},
            {
                "children": [{"children": [{"name": "主机"}], "name": "硬盘"}, {"name": "鼠标和键盘"}],
                "name": "硬件",
            },
            {
                "children": [
                    {"children": [{"name": "操作系统"}, {"name": "数据结构"}], "name": "组成原理"},
                    {"name": "基础"},
                ],
                "name": "软件",
            },
        ],
        "name": "数学",
    }
]
c = (
    Tree()
    .add("", data)
    .set_global_opts(title_opts=opts.TitleOpts(title="Tree-基本示例"))
    .render("tree_base.html")
)
import json

from pyecharts import options as opts
from pyecharts.charts import Tree

with open("flare.json", "r", encoding="utf-8") as f:
    j = json.load(f)
c = (
    Tree()
    .add("", [j], collapse_interval=2, layout="radial")
    .set_global_opts(title_opts=opts.TitleOpts(title="Tree-Layout"))
    .render("tree_layout.html")
)

flare.json文件

复制代码
 {
    "name": "My Library",
    "children": [
        {
            "name": "Book",
            "children": [
                {"name": "Title", "value": "The Great Gatsby"},
                {"name": "Author", "value": "F. Scott Fitzgerald"},
                {"name": "Publication Date", "value": "1925-04-10"}
            ]
        },
        {
            "name": "Library",
            "children": [
                {"name": "Name", "value": "Central Library"},
                {"name": "Location", "value": "New York"}
            ]
        },
        {
            "name": "Characters",
            "children": [
                {"name": "Jay Gatsby", "value": "Wealthy Gambler"},
                {"name": "Nick Carraway", "value": "Narrator"},
                {"name": "Daisy Buchanan", "value": "Socialite"}
            ]
        },
        {
          "name": "competer",
          "children": [
            {"name": "数据结构","value": "50"},
            {"name": "数据库原理","value": "60"},
            {"name": "计算机组成网络","value": "40"}
          ]
         }
    ]
}
相关推荐
魔道不误砍柴功35 分钟前
Java 中如何巧妙应用 Function 让方法复用性更强
java·开发语言·python
_.Switch1 小时前
高级Python自动化运维:容器安全与网络策略的深度解析
运维·网络·python·安全·自动化·devops
测开小菜鸟2 小时前
使用python向钉钉群聊发送消息
java·python·钉钉
萧鼎3 小时前
Python并发编程库:Asyncio的异步编程实战
开发语言·数据库·python·异步
学地理的小胖砸3 小时前
【一些关于Python的信息和帮助】
开发语言·python
疯一样的码农3 小时前
Python 继承、多态、封装、抽象
开发语言·python
Python大数据分析@4 小时前
python操作CSV和excel,如何来做?
开发语言·python·excel
黑叶白树4 小时前
简单的签到程序 python笔记
笔记·python
Shy9604184 小时前
Bert完形填空
python·深度学习·bert
上海_彭彭4 小时前
【提效工具开发】Python功能模块执行和 SQL 执行 需求整理
开发语言·python·sql·测试工具·element