日历图
import datetimeimport randomfrom pyecharts.charts import Calendarfrom pyecharts import options as opts
#Calendar-微信步数情况def calendar_base():begin = datetime.date(, 1, 1)end = datetime.date(, 12, 31)data = [[str(begin + datetime.timedelta(days=i)), random.randint(1000, 25000)]for i in range((end - begin).days + 1)]c = (Calendar().add("", data, calendar_opts=opts.CalendarOpts(range_="")).set_global_opts(title_opts=opts.TitleOpts(title="Calendar-微信步数情况"),visualmap_opts=opts.VisualMapOpts(max_=20000,min_=500,orient="horizontal",is_piecewise=True,pos_top="230px",pos_left="100px",),))return ccalendar_base().render_notebook()
漏斗图
from pyecharts.charts import Funnelfrom pyecharts.faker import Fakerdef funnel_base() :c = (Funnel().add("商品", [list(z) for z in zip(Faker.choose(), Faker.values())]).set_global_opts(title_opts=opts.TitleOpts(title="Funnel-基本示例")))return cfunnel_base().render_notebook()
仪表盘
from pyecharts.charts import Gaugedef gauge_base() -> Gauge:c = (Gauge().add("", [("完成率", 66.6)]).set_global_opts(title_opts=opts.TitleOpts(title="Gauge-基本示例")))return cgauge_base().render_notebook()
def gauge_color() -> Gauge:c = (Gauge().add("业务指标",[("完成率", 55.5)],axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30)),).set_global_opts(title_opts=opts.TitleOpts(title="Gauge-不同颜色"),legend_opts=opts.LegendOpts(is_show=False),))return cgauge_color().render_notebook()
def gauge_splitnum_label() -> Gauge:c = (Gauge().add("业务指标",[("完成率", 75)],split_number=6,axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30)),label_opts=opts.LabelOpts(formatter="{value}"),).set_global_opts(title_opts=opts.TitleOpts(title="Gauge-分割段数-Label"),legend_opts=opts.LegendOpts(is_show=False),))return cgauge_splitnum_label().render_notebook()
水滴图
from pyecharts.charts import Liquidfrom pyecharts.globals import SymbolTypedef liquid_base() -> Liquid:c = (Liquid().add("lq", [0.66, 0.6]).set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例")))return cliquid_base().render_notebook()
def liquid_without_outline() -> Liquid:c = (Liquid().add("lq", [0.6, 0.7, 0.8], is_outline_show=False).set_global_opts(title_opts=opts.TitleOpts(title="Liquid-无边框")))return cliquid_without_outline().render_notebook()
def liquid_shape_diamond() -> Liquid:c = (Liquid().add("lq", [0.4, 0.7], is_outline_show=False, shape=SymbolType.DIAMOND).set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-diamond")))return cliquid_shape_diamond().render_notebook()
def liquid_shape_arrow() -> Liquid:c = (Liquid().add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.ARROW).set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-arrow")))return cliquid_shape_arrow().render_notebook()
def liquid_shape_rect() -> Liquid:c = (Liquid().add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.RECT).set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-rect")))return cliquid_shape_rect().render_notebook()