import pyecharts.charts as pyec
x=['A','B','C']
y=[300,800,600]
bar=pyec.Bar()
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y)
bar.render()
import pyecharts.options as opts
bar.set_global_opts(title_opts=opts.TitleOpts(title='比较图'))
y1=[1200,500,200]
bar.add_yaxis(series_name='B',yaxis_data=y1)
bar.render_notebook()
bar.reversal_axis()
bar.render_notebook()
x1=['2017','2018','2019']
y1=[300,900,600]
line=pyec.Line()
line.add_xaxis(x1)
line.add_yaxis(series_name='A',y_axis=y1)
line.render_notebook()
y2=[1300,500,900]
line.add_yaxis(series_name='B',yaxis_data=y2)
line.set_global_opts(
tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross')
toolbox_opts=opts.ToolboxOpts(is_show=True,orient='horizontal'))
line.set_global_opts(
tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross'),
toolbox_opts=opts.ToolboxOpts(is_show=True,orient='horizontal')
datazoom_opts=opts.DataZoomOpts(type_='slider',range_start=(),range_end=2500))
line.render_notebook()
import pyecharts.charts as pyec
x=['A','B','C']
y=[300,800,600]
bar=pyec.Bar()
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y)
bar.render_notebook()
import pyecharts.options as opts
bar.set_global_opts(title_opts=opts.TitleOpts(title='比较图'))
y1=[1200,500,200]
y2=[400,900,300]
bar.add_yaxis(series_name='B',yaxis_data=y1)
bar.add_yaxis(series_name='c',yaxis_data=y2)
bar.render_notebook()
bar.reversal_axis()
bar.render_notebook()
x_data=['A','B','C','D']
y_data=[830,214,300,1100]
data_pair=list(zip(x_data,y_data))
print(data_pair)
pie=pyec.Pie()
pie.add(series_name='A',data_pair=data_pair)
import numpy as np
x=np.linspace(0,10,30)
y1=np.sin(x)
y2=np.cos(x)
scatter=pyec.Scatter()
scatter.add_xaxis(xaxis_data=x)
scatter.add_yaxis(series_name='sandiantu',y_axis=y1)
import pyecharts.charts as pyec
import pyecharts.options as opts
from pyecharts.globals import ThemeType
x = ['A','B','C','D','E','F']
y1=[50,200,150,100,30,60]
y2=[15,6,45,20,35,66]
y3=[60,35,90,20,15,33]
y4=[22,95,66,48,32,70]
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.render_notebook()
x = ['A','B','C','D','E','F']
y1=[50,200,150,100,30,60]
y2=[15,6,45,20,35,66]
y3=[60,35,90,20,15,33]
y4=[22,95,66,48,32,70]
bar=pyec.Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
bar.add_xaxis(x)
bar.add_yaxis(series_name='A',yaxis_data=y1)
bar.add_yaxis(series_name='B',yaxis_data=y2)
bar.add_yaxis(series_name='C',yaxis_data=y3)
bar.add_yaxis(series_name='D',yaxis_data=y4)
bar.render_notebook()
import datetime
import random
from pyecharts import options as opts
from pyecharts.charts import Calendar
def calendar_base() -> Calendar:
begin = datetime.date(2017, 1, 1)
end = datetime.date(2017, 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_="2017"))
.set_global_opts(
title_opts=opts.TitleOpts(title="Calendar-2017年微信步数情况"),
visualmap_opts=opts.VisualMapOpts(
max_=20000,
min_=500,
orient="horizontal",
is_piecewise=True,
pos_top="230px",
pos_left="100px",
),
)
)
return c
calendar_base().render_notebook()
class Gauge(
# 初始化配置项,参考 `global_options.InitOpts`
init_opts: opts.InitOpts = opts.InitOpts()
)
from pyecharts import options as opts
from pyecharts.charts import Gauge, Page
def gauge_splitnum_label() -> Gauge:
c = (
Gauge()
.add(
"业务指标",
[("完成率", 55.5)],
split_number=5,
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[(0.3, "#67e0e3"), (0.6, "#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 c