import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc =(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 Fakery = 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 Fakerc =(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 Fakerx, 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 Fakerc =(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 Fakerc =(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 Fakerc =(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"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=line-simple目前无法实现的功能:暂无
"""x_data =["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
y_data =[820,932,901,934,1290,1330,1320](Line().set_global_opts(tooltip_opts=opts.TooltipOpts(is_show=False),xaxis_opts=opts.AxisOpts(type_="category"),yaxis_opts=opts.AxisOpts(type_="value",axistick_opts=opts.AxisTickOpts(is_show=True),splitline_opts=opts.SplitLineOpts(is_show=True),),).add_xaxis(xaxis_data=x_data).add_yaxis(series_name="",y_axis=y_data,symbol="emptyCircle",is_symbol_show=True,label_opts=opts.LabelOpts(is_show=False),).render("basic_line_chart.html"))
11. 面积图
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc =(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 Fakerc =(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"))