我使用go.Candlestick
创建了一个简单的烛台图。悬停烛台图表时,我想隐藏数据。我设置了hoverinfo='none'
,但仍像下面的屏幕截图一样在悬停时仍显示一个图标。我怎么藏起来?我的整个代码在图片下方。
这是我的完整代码:
def online_chart_1(sym_1):
data_for_chart = pd.read_csv('C:\\Users\\AF\\Desktop\\python\\results\\csv\\data_for_chart.csv')
historical_ha_vo = pd.read_csv('C:\\Users\\AF\\Desktop\\python\\results\\csv\\historical_ha_vo.csv')
historical_ha_vo = historical_ha_vo.loc[historical_ha_vo.sym == sym_1].tail(59)
data_for_chart = data_for_chart.loc[data_for_chart.sym == sym_1]
df_appended = historical_ha_vo.append(data_for_chart, ignore_index=True)
fig = make_subplots(rows=2, cols=1, row_heights=[0.8, 0.2], vertical_spacing=0)
fig.add_trace(go.Candlestick(open=df_appended['o'], high=df_appended['h'], low=df_appended['l'],
close=df_appended['c'],
increasing_line_color='#0384fc', decreasing_line_color='#e8482c', name=sym_1,
hoverinfo='none',
), row=1, col=1)
fig.add_trace(go.Scatter(y=df_appended['vo'], marker_color='#fae823', name='VO', hovertemplate=[]), row=2, col=1)
fig.update_layout({'plot_bgcolor': "#21201f", 'paper_bgcolor': "#21201f", 'legend_orientation': "h"},
legend=dict(y=1, x=0),
font=dict(color='#dedddc'), dragmode='pan', hovermode='x unified',
margin=dict(b=20, t=0, l=0, r=40))
fig.update_xaxes(showgrid=False, zeroline=False, rangeslider_visible=False, showticklabels=False,
showspikes=True, spikemode='across', spikesnap='data', showline=False, spikedash='solid'
)
fig.update_yaxes(showgrid=False, zeroline=False)
fig.update_traces(xaxis='x')
return fig
和破折号:
app = dash.Dash(__name__)
app.layout = html.Div([html.Div(dcc.Graph(id='chart', figure=online_chart_1('zob'),
config={'displayModeBar': False}))])
if __name__ == '__main__':
app.run_server(debug=True, dev_tools_ui=False, dev_tools_props_check=False)
如果我正确记住,应该可以使用:
hoverinfo='skip'