How to add (clickable) hyperlinks to a Sunburst in Plotly without using Dash?

I would need to add certain URL links to some segments of a Sunburst, similar to this example.

I have been looking into this problem for a while, but could not find a solution using Plotly only - is it even possible to make these links clickable with Plotly or Plotly express?

import pandas as pd
import plotly.express as px

data = {'site': {1: 'Site 1', 2: 'Site 2', },
        'link': {1: 'http://www.google.com', 2: 'http://www.facebook.com'},
        'popularity': {1: 50, 2: 50}}

df = pd.DataFrame(data)

fig = px.sunburst(df,
                  path=['site', 'link'],
                  values='popularity',
                  maxdepth=2,)

fig.show()

Hi @LouizZanjroz. You can use html.

import pandas as pd
import plotly.express as px

data = {'site': {1: 'Site 1', 2: 'Site 2', },
        'link': {1: '<a href="http://www.google.com">link text</a>', 2: 'http://www.facebook.com'},
        'popularity': {1: 50, 2: 50}}

df = pd.DataFrame(data)

fig = px.sunburst(df,
                  path=['site', 'link'],
                  values='popularity',
                  maxdepth=2,)

fig.show()
1 Like