Example #1
0
#Transfer the temps (needs to be separate in order to parse these into floats)
for i in range (2,9):
    for h in range(2, 5):
        a = i-1
        b = h-1
        ws.cell(row=i, column=h).value = float(exampleData[a][b])

ws = wb.active

#Create Chart object
c1 = LineChart()

#Edit Chart details 
c1.title = "Weekly Temps"
c1.y_axis_title = "Temp"
c1.x_axis_title = "Date"
c1.height = 20
c1.width = 40

#Collect Reference points for the chart
data = Reference(ws, min_col=2, min_row=1, max_col=4, max_row=8)
dates = Reference(ws, min_col=1, min_row=2, max_col=1, max_row=8)

#Add Everything to the chart
c1.add_data(data, titles_from_data=True)
c1.set_categories(dates)

#Add Chart to sheet
ws.add_chart(c1)