mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
Update: tree example
This commit is contained in:
parent
86a8883cb6
commit
fb13ff4852
@ -42,13 +42,83 @@ def tree_base() -> Tree:
|
||||
|
||||
|
||||
@C.funcs
|
||||
def tree_official() -> Tree:
|
||||
def tree_lr() -> Tree:
|
||||
with open(os.path.join("fixtures", "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-官方示例"))
|
||||
.set_global_opts(title_opts=opts.TitleOpts(title="Tree-左右方向"))
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def tree_rl() -> Tree:
|
||||
with open(os.path.join("fixtures", "flare.json"), "r", encoding="utf-8") as f:
|
||||
j = json.load(f)
|
||||
c = (
|
||||
Tree()
|
||||
.add("", [j], collapse_interval=2, orient="RL")
|
||||
.set_global_opts(title_opts=opts.TitleOpts(title="Tree-右左方向"))
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def tree_tb() -> Tree:
|
||||
with open(os.path.join("fixtures", "flare.json"), "r", encoding="utf-8") as f:
|
||||
j = json.load(f)
|
||||
c = (
|
||||
Tree()
|
||||
.add(
|
||||
"",
|
||||
[j],
|
||||
collapse_interval=2,
|
||||
orient="TB",
|
||||
label_opts=opts.LabelOpts(
|
||||
position="top",
|
||||
horizontal_align="right",
|
||||
vertical_align="middle",
|
||||
rotate=-90,
|
||||
),
|
||||
)
|
||||
.set_global_opts(title_opts=opts.TitleOpts(title="Tree-上下方向"))
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def tree_bt() -> Tree:
|
||||
with open(os.path.join("fixtures", "flare.json"), "r", encoding="utf-8") as f:
|
||||
j = json.load(f)
|
||||
c = (
|
||||
Tree()
|
||||
.add(
|
||||
"",
|
||||
[j],
|
||||
collapse_interval=2,
|
||||
orient="BT",
|
||||
label_opts=opts.LabelOpts(
|
||||
position="top",
|
||||
horizontal_align="right",
|
||||
vertical_align="middle",
|
||||
rotate=-90,
|
||||
),
|
||||
)
|
||||
.set_global_opts(title_opts=opts.TitleOpts(title="Tree-下上方向"))
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def tree_layout() -> Tree:
|
||||
with open(os.path.join("fixtures", "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"))
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@ -12,18 +12,22 @@ class LabelOpts:
|
||||
font_style: Optional[str] = None,
|
||||
font_weight: Optional[str] = None,
|
||||
font_family: Optional[str] = None,
|
||||
align: Optional[str] = None,
|
||||
rotate: Optional[Numeric] = None,
|
||||
horizontal_align: Optional[str] = None,
|
||||
vertical_align: Optional[str] = None,
|
||||
formatter: Optional[str] = None,
|
||||
):
|
||||
self.opts: dict = {
|
||||
"show": is_show,
|
||||
"position": position,
|
||||
"color": color,
|
||||
"rotate": rotate,
|
||||
"fontSize": font_size,
|
||||
"fontStyle": font_style,
|
||||
"fontWeight": font_weight,
|
||||
"fontFamily": font_family,
|
||||
"align": align,
|
||||
"align": horizontal_align,
|
||||
"verticalAlign": vertical_align,
|
||||
"formatter": formatter,
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user