Sankey Diagram data filter based on a variable in dropdown

Hi All, Need your expert advice. I want to filter my Sankey diagram source, target, and values based on an additional column in my table. I want to create a drop-down with some categories which filters my data on HTML and Sankey diagram reflects the update flow.

Is there any way to do it? I have attached the image which will help you to understand. Anyone who has prior experience with this and can help me, please share the email address so that I can send the files.

####### Codes i was exploring #########################
import plotly.graph_objects as go
import pandas as pd

data=pd.read_csv(r"C:\Users\AnkitSrivastava\Desktop\R_Studio_Example\final_Sankey_Data.csv")
list1=pd.read_excel(r"C:\Users\AnkitSrivastava\Desktop\R_Studio_Example\EngMovementData.xlsx",sheet_name="List")
Category=list1.iloc[:,0].tolist()
Source_data=data.iloc[:,-2].tolist()
target_data=data.iloc[:,-1].tolist()
score=data.iloc[:,-3].tolist()

#s1=data[(data["BU"]=="Other") & (data["GEO"]=="China")]["2018_code"].tolist()

#client_name=str(list1.loc[0][4])

fig = go.Figure(data=[go.Sankey(

node = dict(line = dict(color = "blue", width = 0.5), label = Category),
link = dict(source = Source_data, target = target_data, value = score )
)])

button_layer_1_height = 1.08
fig.update_layout(
updatemenus=[
dict(
buttons=list([
dict(
args=["Source_data", "E&U"],
label="E&U",
method="restyle"
),
dict(
args=["Source_data", "Other"],
label="Other",
method="restyle"
),
dict(
args=["Source_data", "Portfolio"],
label="Portfolio",
method="restyle"
),

        ]),
        direction="down",
        pad={"r": 2, "t": -20},
        showactive=True,
        x=0.1,
        xanchor="left",
        y=button_layer_1_height,
        yanchor="top"
    )  ]

)

fig.update_layout(
annotations=[
dict(text="BU", showarrow=False)
])

fig.show()
#fig.write_html(r"C:\Users\AnkitSrivastava\Desktop\R_Studio_Example\Engagement_Movement.html", auto_open=True)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.