I’m using dropdowns to dynamically select the data plotted/number of y axes to use. For some reason the hover info only displays for the last axis that gets plotted. I’d like the blue trace to also be in the compare output, and have tried playing around with different hover properties, but I don’t think I’ve found exactly what I’m looking for.
Picture here:
Code here:
Any thoughts?
axesCount = 0
y1 = y3 = y5 = dict(title = '')
y2 = y4 = y6 = dict(title = '', overlaying = 'y', side = 'right')
for dataIndex, value in enumerate(assets): #loop thru dropdowns
if assets[dataIndex]:
axesCount += 1
print(axesCount)
for i in value: #Loop thru assets in dropdown
if y1s[dataIndex] != []: #if Y1 selected for this asset
for j in y1s[dataIndex]:
temp = []
for k in data[dataIndex][i]:
temp.append(k[j])
if dataIndex == 0:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j)))
y1 = dict(title = guess_units(j), anchor = 'x', overlaying = 'y')
elif dataIndex == 1:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j), yaxis='y3'))
y3 = dict(title = guess_units(j), anchor = 'free', position = 0.05, overlaying = 'y')
else:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j), yaxis='y5'))
y5 = dict(title = guess_units(j), anchor = 'free', position = 0.00, overlaying = 'y')
if y2s[dataIndex] != []:
for j in y2s[dataIndex]:
temp = []
for k in data[dataIndex][i]:
temp.append(k[j])
if dataIndex == 0:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j), yaxis='y2'))
y2 = dict(title = guess_units(j), side = 'right', anchor = 'x', overlaying = 'y')
elif dataIndex == 1:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j), yaxis='y4'))
y4 = dict(title = guess_units(j), side = 'right', anchor = 'free', position = 0.95, overlaying = 'y')
else:
data2plot.append(go.Scattergl(x = dts[dataIndex], y = temp, mode = 'lines', name = '{} {}'.format(i,j), yaxis='y6'))
y6 = dict(title = guess_units(j), side = 'right', anchor = 'free', position = 1.0, overlaying = 'y')
print(data2plot)
graphTitle = str(','.join(y1s[0]) + '--' + ','.join(y2s[0])) if not y1s[1] and not y2s[1] and not y1s[2] and not y2s[2] and y1s[0] else 'Data Graphed'
x = dict(domain = [0.10, 0.9])
layout = go.Layout( title = graphTitle,
legend=dict(orientation="h"),
hovermode= 'y',
xaxis = x,
yaxis = y1,
yaxis2 = y2,
yaxis3 = y3,
yaxis4 = y4,
yaxis5 = y5,
yaxis6 = y6)
return {'data': data2plot, 'layout': layout}