Hi everyone,
I have a graph mixing vertical bars and a scatter on top. The hover works perfectly fine on the scatter however, the hover of both bars wonât pop.
Please find below a reproducible example of the matter before mentioned :
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go
import pandas as pd
d = {âyearâ:[1, 2, 3], âfield_1â: [0.1, 0.2, 0.3], âfield_2â: [3, 4, 5], âfield_3â: [1, 2, 3]}
df = pd.DataFrame(data=d)
app = dash.Dash(name)
server = app.server
app.config.suppress_callback_exceptions = True
app.layout = html.Div(
dcc.Graph(
figure=go.Figure(
data=[
go.Scatter(
name=âRendement Net Net (%)â,
x=df[âyearâ],
y=df[âfield_1â],
yaxis=ây2â,
mode=âlines+markers+textâ,
marker=dict(size=30),
text=df[âfield_1â].round(1),
textfont={âcolorâ:âwhiteâ},
hovertemplate = 'Année : %{x}
Rendement Net Net : %{y:.} ',
line={âshapeâ:âsplineâ},
),
go.Bar(
name=âCash-Flow Netâ,
x=df[âyearâ],
y=df[âfield_2â],
yaxis=ây1â,
customdata=df[âfield_2â].round(1),
hovertemplate = 'Année : %{x}
Cash-Flow Net : %{y:.} ',
),
go.Bar(
name=âActif Immobilier Acquisâ,
x=df[âyearâ],
y=df[âfield_3â],
yaxis=ây1â,
hovertemplate = 'Année : %{x}
Actif Immobilier : %{y:.} ',
),
],
layout=go.Layout(
shapes=[
dict(
type="line",
x0=0,
y0=0,
x1=max(df['year']) + 1,
y1=0,
line=dict(
color="grey",
width=1,
),
),
],
xaxis=dict(title='Années'),
yaxis1=dict(title='Euros (000)'),
yaxis2=dict(
showgrid=False,
rangemode="tozero",
showticklabels=False,
),
barmode='relative',
showlegend=True,
legend=dict(orientation='h',
yanchor='top',
xanchor='center',
y=1.2, x=0.5),
font=dict(size=10),
margin=go.layout.Margin(l=10, t=10, b=10, r=10),
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)'),
),
id='rev_graph',
config={'displayModeBar': False},
style={
'height':'300px',
'display':'inline-block',
'width':'93%',
}
),
)
if name == âmainâ:
app.run_server(debug=False)
Iâd be grateful if anyone can bring some help !!
Thanks in advance,
Antoine