Exemplo n.º 1
0
def create_avg_chart(workbook, worksheet, min_col, min_row, max_col, max_row):
    chart = LineChart()
    #Sets titles on graph
    chart.y_axis.title = '5S Audit Socre Average'
    chart.x_axis.title = '5S Weekly Audit Dates'
    chart.title = 'Past ' + string_weeks + ' Weeks Average Score For 539'

    #Gets the data from the table
    data = Reference(worksheet,
                     min_col=min_col,
                     min_row=min_row + 14,
                     max_col=max_col,
                     max_row=max_row)

    #Gets the Dates from the first row and stores them in a variable
    dates = Reference(worksheet,
                      min_col=min_col,
                      min_row=min_row,
                      max_col=max_col,
                      max_row=max_row - 14)

    #Creates a series using the data collected from the specified rows of the table
    series = Series(data, title='Building 539')
    #Sets the marker on the chart to be a triangle
    series.marker.symbol = "triangle"

    #Adds the data and date labels to the chart
    chart.append(series)
    chart.set_categories(dates)
    chart.dataLabels = DataLabelList()
    chart.dataLabels.showVal = True

    #Adds the chart to the worksheet at cell M18 and saves the file
    worksheet.add_chart(chart, 'K18')
    workbook.save(wb_name)
Exemplo n.º 2
0
                                                     column=_col_2).value
# 表4写数据
for _col_dst, _col_src in zip(range(3, 3 + week_num_r),
                              range(7, 7 + week_num_r)):
    for _row_dst, _row_src in zip(range(2, 11), range(1623, 1632)):
        datasheet_4.cell(row=_row_dst, column=_col_dst).value = _ws.cell(
            row=_row_src, column=_col_src).value
# 生成表4图标
chart4_1 = BarChart()
data1 = Reference(datasheet_4, min_col=4, min_row=7, max_col=9)
cats1 = Reference(datasheet_4, min_col=4, min_row=1, max_col=9)
chart4_1.add_data(data1, titles_from_data=False, from_rows=True)
chart4_1.y_axis.majorGridlines = None
chart4_1.set_categories(cats1)
chart4_1.title = '融合终端返修情况'

chart4_2 = LineChart()
data2 = Reference(datasheet_4, min_col=4, min_row=9, max_col=9)
chart4_2.add_data(data2, titles_from_data=False, from_rows=True)
chart4_2.y_axis.axId = 200

chart4_2.y_axis.crosses = "max"
chart4_1 += chart4_2

chart4_2.dataLabels = DataLabelList()
chart4_2.dataLabels.showVal = True

datasheet_4.add_chart(chart4_1, "C12")

# 保存文件
outwb.save("datasheet1.xlsx")