from pyecharts.charts import Line
from pyecharts import options as opts
from pyecharts.globals import ThemeType
x = [1,2,3,4,5,6,7,8,9,10,11,12]
y = [10,15,20,16,30,10,12,20,20,18,36,24]
max_index = x.index(max(x))
print(max_index)
[x * x for x in range(1, 11)]
line = (
Line(init_opts=opts.InitOpts(theme=ThemeType.DARK))
.add_xaxis(["{}月".format(i) for i in x])
.add_yaxis('销量',y_axis=y,is_smooth=True,color='blue',symbol='rect',markline_opts=opts.MarkLineOpts(data=20),
markpoint_opts=opts.MarkPointOpts(
data=[
opts.MarkPointItem(type_="max", name="最大值"),
opts.MarkPointItem(type_="min", name="最小值"),
#opts.MarkPointItem(name="自定义标记点", coord=[x[len(x)-3], y[len(y)-3]], value=y[len(y)-3]),
]
),
# markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")])
)
.set_series_opts(
areastyle_opts=opts.AreaStyleOpts(opacity=0.5),
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(
title_opts=opts.TitleOpts(title="未来一周销量变化",pos_left="left"),
tooltip_opts=opts.TooltipOpts(trigger="axis"),
toolbox_opts=opts.ToolboxOpts(is_show=True),
xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
yaxis_opts=opts.AxisOpts(name="流量(m^3/s)")
)
# .render("temperature_change_line_chart.html")
)
print('完成')
line.render_notebook()
import pyecharts.options as opts
from pyecharts.charts import Gauge
"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.baidu.com/examples/editor.html?c=gauge
目前无法实现的功能:
1、暂无
"""
gauge=(
Gauge(init_opts=opts.InitOpts(width="800px", height="400px",theme=ThemeType.DARK))
.add(series_name="业务指标", data_pair=[["完成率", 55.5]],title_label_opts=opts.LabelOpts(
font_size=40, color="blue", font_family="Microsoft YaHei"
))
.set_global_opts(
legend_opts=opts.LegendOpts(is_show=False),
tooltip_opts=opts.TooltipOpts(is_show=True, formatter="{a} <br/>{b} : {c}%"),
title_opts=opts.TitleOpts(title="未来一周销量变化",pos_left="left"),
#tooltip_opts=opts.TooltipOpts(trigger="axis"),
toolbox_opts=opts.ToolboxOpts(is_show=True),
# xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
#yaxis_opts=opts.AxisOpts(name="流量(m^3/s)")
)
#.render("gauge.html")
)
gauge.render_notebook()