Hello, I have a relative bar graph and I would like to be able to show above each bar the result of the sum of the three values and I can’t find how to do it.
I am reading the values from mysql data base with php.
can anybody help me?
Thank you
HI @calpanxo .
Maybe this will help:
a=[1,2,3,4,5,6,7]
b=[2,4,6,8,10,12,14]
c=[6,9,1,3,5,12,15]
x=[i for i in range(0,len(a))]
total=[i+j+k for i,j,k in zip(a,b,c)]
fig=go.Figure()
fig.add_trace(go.Bar(y=a,text=a,textposition='auto'))
fig.add_trace(go.Bar(y=b,text=b,textposition='auto'))
fig.add_trace(go.Bar(y=c,text=c,textposition='auto'))
fig.update_layout(barmode='stack')
for i in range(len(a)):
fig.add_annotation(x=i,y=total[i],text=str(total[i]),showarrow=True)
fig.show()
Thank you but I have the values in php arrays, i pass it to json and extract all in script.
but i don’t know how to integer your reply in my script…
Maybe creating a fourth array with the sum of the other three. And finally using annotation function for php
OK, i will try it.
Thanks again
Hi again, in wich language is your script?
I am using javascript…
Hi , this script is in Python