I’m using this code for that task, the tsv file i’m reading in the code has a similar format to the dicts i pasted on the end of the code… The problem is, when i run the code, the last annotation the code makes is the only one that shows in the exported chart, also, how do i make the annotations go to the center of the block?
import plotly.plotly as py
import plotly.figure_factory as ff
import plotly.graph_objs as go
import plotly
import csv
def readtsv():
lista = []
with open('output.tsv') as csvfile:
reader = csv.reader(csvfile, delimiter="\t")
fields = ["Task", "Start", "Finish", "Resource"]
for row in reader:
lista.append({key: value for key, value in zip(fields, row)})
fig = ff.create_gantt(lista, index_col='Resource', show_colorbar=True, group_tasks=True)
#fig.layout.xaxis.tickformat = '%Y'
anotar(lista, fig)
plotly.offline.plot(fig, filename='dildo.html')
def anotar(basura, fig):
for i in basura:
c=0
print (i.get("Start"))
fig['layout']['annotations'] = [dict(x=i.get("Start"),y=c,text="labeled", showarrow=True, font=dict(color='black'))]
plotly.offline.plot(fig, filename='dildo.html')
c=c+1
'''def anotar(basura):
trash = []
for i in basura:
c=0
print (i.get("Start"))
trash.append= [dict(x=i.get("Start"),y=c,text="labeled", showarrow=True, font=dict(color='black'))]
c=c+1
layout = go.Layout(showlegend=False,annotations=[trash])
return layout
'''
if __name__ == "__main__":
df = [dict(Task='1', Start='0635', Finish='0785', Resource='Maquina 4'),
dict(Task='1', Start='0087', Finish='0334', Resource='Maquina 1'),
dict(Task='1', Start='0334', Finish='0457', Resource='Maquina 7')]
readtsv()