Hi all,
I was wondering whether there is an option to make the hover data on my plotly express sunburst diagram a bit more intelligent, and only display certain elements depending which segment my mouse is over. See the code I am using below to create the diagram:
import plotly.express as px
import pandas as pd
data = {'first_column': ['value_1', 'value_2', 'value_3', 'value_4', 'value_5', 'value_6'],
'second_column': ['North', 'East', 'South', 'West', 'North', 'North'],
'third_column': [11, 1, 7, 9, 5, 2],
'fourth_column':[9,9,7,6,5,4]
}
df = pd.DataFrame(data)
fig = px.sunburst(
data_frame=df,
path=["first_column", "second_column"],
color = "first_column",
values="third_column",
color_discrete_sequence=px.colors.qualitative.Pastel,
maxdepth=2,
custom_data=['fourth_column'],
hover_name="first_column",
# hover_data={"fourth_column":True},
template='ggplot2',
)
fig.update_traces(hovertemplate=('<br><b>The third_column is</b>: %{value}<br>'+\
'<br><b>The third_column is</b>: %{customdata[0]}<br>'))
fig.show()
Is there a way for instance to stop the hover data displaying the custom data, if the mouse is over a certain segment?
Thanks in advance for any help.