def add_line_chart(self, title_info, coordinate="E2"): # D 列 2行 是位置标签:sheet,曲线图,title,max,chart,设置,active,line From: https://www.cnblogs.com/zyf531/p/17776526.html
"""
:param title:
:param x_title:
:param y_title:
:param coordinate:
:return:
"""
workbook = load_workbook(self.excel_name)
# active_sheet = self.wb.active
active_sheet = workbook[f'{title_info}']
line_chart = LineChart()
line_chart.title = title_info
line_chart.style = 5 # 样式18
line_chart.x_axis.title = u'时间'
line_chart.y_axis.title = u'大小'
line_chart.height = 18
line_chart.width = 35 # 25
# y 抽的 数据 ,从第二行开始,获取第1列数据
y_data = Reference(active_sheet, min_col=1, min_row=2, max_col=1, max_row=active_sheet.max_row)
# x抽 的从第二行开始,获取第2列数据
x_data = Reference(active_sheet, min_col=2, min_row=2, max_col=1, max_row=active_sheet.max_row)
line_chart.add_data(y_data)
line_chart.set_categories(x_data)
line_chart.series[0].graphicalProperties.line.width = 5 # 设置线条粗细,默认去掉就可以
active_sheet.add_chart(line_chart, coordinate)
workbook.save(self.excel_name)