参数传递
pyecharts 对配置项基本上都采用 XXXOpts/XXXItems 以及 dict 两种数据形式,这两种是完全等价的。
比如下面三者效果是一致的
class InitOpts(BasicOpts):
def __init__(
self,
str = "900px",
height: str = "500px",
chart_id: Optional[str] = None,
renderer: str = RenderType.CANVAS,
page_title: str = CurrentConfig.PAGE_TITLE,
theme: str = ThemeType.WHITE,
bg_color: Union[str, dict] = None,
js_host: str = "",
animation_opts: Union[AnimationOpts, dict] = AnimationOpts(),
):
self.opts: dict = {
"width": width,
"height": height,
"chart_id": chart_id,
"renderer": renderer,
"page_title": page_title,
"theme": theme,
"bg_color": bg_color,
"js_host": js_host,
"animationOpts": animation_opts,
}
c = Bar(init_opts=opts.InitOpts(width="620px", height="420px"))
c = Bar(dict(width="620px", height="420px"))
c = Bar({"width": "620px", "height": "420px"})