赞
踩
from pyecharts import options as opts from pyecharts.charts import * from pyecharts.globals import * x_data = ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"] y_data = [335, 310, 274, 235, 700] data_pair = [list(z) for z in zip(x_data, y_data)] data_pair.sort(key=lambda x: x[1]) p = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.WALDEN, page_title="Pie- Base")) .add( series_name="访问来源", data_pair=data_pair, radius="50%", center=["50%", "50%"], # is_clockwise=True, # 扇区排布方向 label_opts=opts.LabelOpts(is_show=True, position="center"), ) .set_global_opts( title_opts=opts.TitleOpts( title="Customized Pie", pos_left="center", pos_top="20", ), legend_opts=opts.LegendOpts(is_show=False) ) .set_series_opts( tooltip_opts=opts.TooltipOpts( trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)" ), label_opts=opts.LabelOpts(color="rgba(0, 0, 0, 0.5"), ) .render("Pie01.html") ) os.system("Pie01.html")
from pyecharts import options as opts from pyecharts.charts import * from pyecharts.globals import * x_data = ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"] y_data = [335, 310, 274, 235, 700] data_pair = [list(z) for z in zip(x_data, y_data)] data_pair.sort(key=lambda x: x[1]) p = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.INFOGRAPHIC, page_title="Pie- RoseType")) .add( series_name="访问来源", data_pair=data_pair, radius="50%", # 饼图 center=["50%", "50%"], # 是否展示成南丁格尔图,通过半径区分数据大小 rosetype="radius", # 通过半径区分数据大小 # rosetype="area", # 通过面积区分数据大小 is_clockwise=True, # 扇区排布方向 label_opts=opts.LabelOpts(is_show=True, position="center"), ) .set_global_opts( title_opts=opts.TitleOpts( title="Pie - Rosetype", pos_left="center", pos_top="20", ), legend_opts=opts.LegendOpts(is_show=False) ) .set_series_opts( tooltip_opts=opts.TooltipOpts( trigger="item", formatter="<b>{a}</b> <br/>{b}: {c} ({d}%)" ), label_opts=opts.LabelOpts(color="rgba(0, 0, 0, 0.5"), ) .render("Pie02.html") ) os.system("Pie02.html")
from pyecharts import options as opts from pyecharts.charts import * from pyecharts.globals import * x_data = ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"] y_data = [335, 310, 274, 235, 700] data_pair = [list(z) for z in zip(x_data, y_data)] data_pair.sort(key=lambda x: x[1]) p = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.WALDEN, page_title="Pie- Ring")) .add( series_name="访问来源", data_pair=data_pair, radius=["35%", "75%"], # 圆环图 center=["50%", "50%"], is_clockwise=True, # 扇区排布方向 label_opts=opts.LabelOpts(is_show=True, position="center"), ) .set_global_opts( title_opts=opts.TitleOpts( title="Pie - Ring", pos_left="center", pos_top="20", ), legend_opts=opts.LegendOpts(is_show=False) ) .set_series_opts( tooltip_opts=opts.TooltipOpts( trigger="item", formatter="<b>{a}</b> <br/>{b}: {c} ({d}%)" ), label_opts=opts.LabelOpts(color="rgba(0, 0, 0, 0.5", formatter="{b}: {c} ({d}%)", font_size=14, font_weight="bold", font_family="Courier New", ), ) .render("Pie03.html") ) os.system("Pie03.html")
from pyecharts import options as opts from pyecharts.charts import * from pyecharts.globals import * inner_x_data = ["直达", "营销广告", "搜索引擎"] inner_y_data = [335, 679, 1548] outer_x_data = ["直达", "营销广告", "搜索引擎", "邮件营销", "联盟广告", "视频广告", "百度", "谷歌", "必应", "其他"] outer_y_data = [335, 310, 234, 135, 1048, 251, 147, 102] p = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.WALDEN, page_title="Nested Pie with Rich Text")) .add( series_name="访问来源", data_pair=[list(z) for z in zip(inner_x_data, inner_y_data)], radius=[0, "30%"], label_opts=opts.LabelOpts(position="inner"), ) .add( series_name="访问来源2", data_pair=[list(z) for z in zip(outer_x_data, outer_y_data)], radius=["40%", "60%"], label_opts=opts.LabelOpts( position="outside", formatter="{a|{a}}{abg|}\n{hr|}\n {b|{b}} : {c} {per|{d}%} ", background_color="#eee", border_color="#aaa", border_width=1, border_radius=4, rich={ "a": { "color": "#999", "lineHeight": 22, "align": "center"}, "abg": { "backgroundColor": "#e3e3e3", "width": "100%", "align": "right", "height": 22, "borderRadius": [4, 4, 0, 0], }, "hr": {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。