I am reading from MySQL database this kind of data:
('c9', 2862, datetime.datetime(2016, 4, 30, 22, 34, 38))
('f2', 2862, datetime.datetime(2016, 4, 30, 22, 35, 38))
('f3', 2864, datetime.datetime(2016, 4, 30, 22, 36, 38))
('f4', 2863, datetime.datetime(2016, 4, 30, 22, 37, 38))
('c9', 2880, datetime.datetime(2016, 4, 30, 22, 38, 38))
('f2', 2862, datetime.datetime(2016, 4, 30, 22, 39, 38))
# and so on!
I want to use the library pygal
to make a graph that will combine all of the nodes in column 1 (c9, f2, f3...) in one graph, each with its respective time. So I tried the following:
time = []
y_c9 = []
y_f3 = []
y_f2 = []
for row in data:
time.append(row[2])
if row[0] == 'c9':
y_c9.append(row[1])
if row[0] == 'f2':
y_f2.append(row[1])
if row[0] == 'f3':
y_f3.append(row[1])
# and the same for the rest
graph.x_labels = time
graph.add('c9', y_c9)
graph.add('f2', y_f2)
graph.add('f3', y_f3
However, this doesn't cut it because I will get short lines for c9, f2 ,f3, while the time (x axis) will be of a longer value (The length of y_c9, y_f2, y_f3 is < length of time) I tried several other combinations of if statements but it didn't work as well.
What should I do to produce a proper graph?