from pyecharts.charts import Line
from itertools import islice
x = []
y1 = []
y2 = []
with open(r'E:\Desktop\python\py\test\test1.txt',mode='r',encoding='utf-8') as f:
for lines in islice(f,1,None):
lines=lines.rstrip("\n")
lines1=lines.split(" ")[0]
lines2=lines.split(" ")[1]
lines3=lines.split(" ")[2]
x.append(lines1)
y1.append(float(lines2))
y2.append(float(lines3))
c = (
Line()
.add_xaxis(x)
.add_yaxis("A请求数", y1,is_smooth=True)
.add_yaxis("B请求数", y2,is_smooth=True)
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
title_opts=opts.TitleOpts(title="nginx请求", subtitle="time/request"),
)
.render(r"E:\Desktop\python\py\test\line_smooth.html")
)
test1.txt 内容
[i]
生产的html效果
[i]