程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Visual presentation of Python pyecharts data

編輯:Python
from pyecharts import options as opts
from snapshot_selenium import snapshot as driver
def draw_chart(self, file, save_path):
"""
Front end playback performance use case data statistics chart
file: excel The full path
save_path: html and png Save the directory
"""
data = pandas.read_excel(file, engine='openpyxl')
shape = data.shape
nrows = shape[0]
ncols = shape[1]
# print(f' Current total rows :' + str(nrows)) # Get the number of lines
# print(f' Current total Columns :' + str(ncols)) # Get the number of columns
dt_dates = [] # date
dt_avg_fpss = [] # Average frame rate
dt_fat_fps_nums = [] # Number of fat frames
for i in range(nrows):
dt_date = data.iloc[i, 0]
dt_dates.append(dt_date)
dt_avg_fps = data.iloc[i, 1]
dt_avg_fpss.append(float(dt_avg_fps))
dt_fat_fps_num = data.iloc[i, 2]
dt_fat_fps_nums.append(float(dt_fat_fps_num))
# print(dt_fat_fps_nums)
line = (
Line(init_opts=opts.InitOpts(width='1850px', height='640px'))
.add_xaxis(dt_dates)
.add_yaxis(" Average frame rate ", dt_avg_fpss)
.add_yaxis(" Number of fat frames ", dt_fat_fps_nums)
.set_global_opts(title_opts=opts.TitleOpts(title=" Front end performance test "))
)
line.set_series_opts(
markpoint_opts=opts.MarkPointOpts(
data=[
opts.MarkPointItem(type_='average', name=' Average '),
opts.MarkPointItem(type_='max', name=' Maximum '),
opts.MarkPointItem(type_='min', name=' minimum value ')
]
)
)
# Set the title, etc
line.set_global_opts(title_opts=opts.TitleOpts(' Front end performance tracking curve '),
# show the toolbox
toolbox_opts=opts.ToolboxOpts(),
xaxis_opts=opts.AxisOpts(axislabel_opts={"rotate": 45, "interval": 0})
)
file_name = self.getTestCaseName(file)
html_name = file_name + ".html"
html_save_path = save_path + "\\" + html_name
line.render(html_save_path)
snapshot_save_path = save_path + "\\bar.png"
# Need to install snapshot-selenium perhaps snapshot-phantomjs
make_snapshot(driver, line.render(), snapshot_save_path)
# webbrowser.open(html_name)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved