https://gallery.pyecharts.org/#/Tree/tree_left_right
这个flare.json的结构是多层字典吗?
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)
.set_global_opts(title_opts=opts.TitleOpts(title="Tree-左右方向"))
.render("tree_left_right.html")
)
大概这样的形式
{
"children": [
{"name": "B"},
{
"children": [
{"children": [{"name": "I"}], "name": "E"},
{"name": "F"},
],
"name": "C",
},
{
"children": [
{"children": [{"name": "J"}, {"name": "K"}], "name": "G"},
{"name": "H"},
],
"name": "D",
},
],
"name": "A",
}