I have a stacked bar chart and I need to overlay a line across it. Anyone have any insight?
When I add go.Scatter to the list in the data value it does not show up.
Any help would be great.
@app.callback(
dash.dependencies.Output('indicator-graphic', 'figure'),
[dash.dependencies.Input('my-dropdown', 'value'),
dash.dependencies.Input('my-dropdown1', 'value')])
def update_output(value, value1):
df['Date'] = pd.to_datetime(df['Date'])
dff = df.set_index('Date')
dff = dff.loc[value:value1]
fr = dff.reset_index().pivot("Date", "Fund", "Strat_Ret")
br = dff.reset_index().pivot("Date", "Fund", "Bench_Ret")
fw = dff.reset_index().pivot("Date", "Fund", "Strat_Weight")
bw = dff.reset_index().pivot("Date", "Fund", "Bench_Weight")
_barfund_select = att.component(fr, br, fw, bw, 'asset')
_barasset_select = att.component(fr, br, fw, bw, 'ass')
fund_select = att.attribution(fr, br, fw, bw, 'asset')
return {'data' : [go.Bar(
{'x': _barfund_select.index, 'opacity':'.6'},
y = _barfund_select[i].values,
name = i) for i in _barfund_select.columns
],
'layout': {
'barmode':'stack',
'filename':'bar-line',
'showlegend': False,
'hovermode': 'closest',
"xaxis": {"tickfont": {"color": "rgb(68, 68, 68)"},
"title": "",
"ticks": "outside",
"gridcolor": "rgb(255, 255, 255)",
"showline": "true",
"type": "date",
"autorange": "false"},
"yaxis": {"title": "", "ticks": "outside", "gridcolor": "rgb(255, 255, 255)", "showline": "true", "nticks": 11, "type": "linear", "autorange": "false", "tickformat":".1%"},
"plot_bgcolor": "rgb(217, 224, 236)",
"font": {"family": "Raleway"},
"margin": {"r": 10, "b": 30, "pad": 0, "l": 40, "t": 30},
}
}