Update: tree example

This commit is contained in:
chenjiandongx 2019-03-26 13:22:40 +08:00
parent 86a8883cb6
commit fb13ff4852
2 changed files with 78 additions and 4 deletions

View File

@ -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

View File

@ -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,
}