Plotly:带有“href"的树形图元素不工作素不、工作、Plotly、href

由网友(南戈)分享简介:I have simple table whin href link inside the text. But clicking on it doesn't open the page.is there any easy way to do that?import plotly.express as pxdf =...

I have simple table whin href link inside the text. But clicking on it doesn't open the page. is there any easy way to do that?

import plotly.express as px
df = px.data.gapminder().query("year == 2007")

link_ref = '<a xlink:href="http://google.com" style="cursor: pointer" target="_blank" rel="noopener noreferrer">{}</a>'
df['country'] = df['country'].apply(lambda item: link_ref.format(item, "{}"))

fig = px.treemap(df, path=[ 'continent', 'country'], values='pop',
                  color='lifeExp', hover_data=['iso_alpha'])
fig.show()

解决方案 plotly CSDN

You just need to get rid of xlink: The following should work

import plotly.express as px
df = px.data.gapminder().query("year == 2007")

link_ref = '<a href="http://google.com" style="cursor: pointer" target="_blank" rel="noopener noreferrer">{}</a>'
df['country'] = df['country'].apply(lambda item: link_ref.format(item, "{}"))

fig = px.treemap(df,
                 path=[ 'continent', 'country'],
                 values='pop',
                 color='lifeExp',
                 hover_data=['iso_alpha'])

fig.show()

阅读全文

相关推荐

最新文章