import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values()).add_yaxis("商家B", Faker.values()).set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例")).render("line_base.html"))
2. 缺失值的平滑处理
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
y = Faker.values()
y[3], y[5]=None,None
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", y, is_connect_nones=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-连接空数据")).render("line_connect_null.html"))
3. markline
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A",
Faker.values(),
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),).add_yaxis("商家B",
Faker.values(),
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkLine")).render("line_markline.html"))
4. markpoint
4.1 markpoint自定义
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
x, y = Faker.choose(), Faker.values()
c =(
Line().add_xaxis(x).add_yaxis("商家A",
y,
markpoint_opts=opts.MarkPointOpts(
data=[opts.MarkPointItem(name="自定义标记点", coord=[x[2], y[2]], value=y[2])]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkPoint(自定义)")).render("line_markpoint_custom.html"))
4.2 markpoint(最大值最小值)
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A",
Faker.values(),
markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="min")]),).add_yaxis("商家B",
Faker.values(),
markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max")]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkPoint")).render("line_markpoint.html"))
5. 平滑曲线
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_smooth=True).add_yaxis("商家B", Faker.values(), is_smooth=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-smooth")).render("line_smooth.html"))
6. 阶梯状
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_step=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-阶梯图")).render("line_step.html"))
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), areastyle_opts=opts.AreaStyleOpts(opacity=0.5)).add_yaxis("商家B", Faker.values(), areastyle_opts=opts.AreaStyleOpts(opacity=0.5)).set_global_opts(title_opts=opts.TitleOpts(title="Line-面积图")).render("line_area_style.html"))
面积图紧贴y轴
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
c =(
Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_smooth=True).add_yaxis("商家B", Faker.values(), is_smooth=True).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="Line-面积图(紧贴 Y 轴)"),
xaxis_opts=opts.AxisOpts(
axistick_opts=opts.AxisTickOpts(is_align_with_label=True),
is_scale=False,
boundary_gap=False,),).render("line_areastyle_boundary_gap.html"))