4

I have simple table with href inside the text. The href points to relative path of local html file. But clicking on it doesn't open the page. is there any way to do that/ good workaround?

The folder structure is following. As the root will be changed, so the relative path is needed.

--root
--root/index.html
--root/files/file1.html
--root/files/file2.html



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

link_ref = '<a href="files/file1.html">{}</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.write_html("index.html")

Note: The link starting with http works. Plotly: treemap element with "href" not working

link_ref = '<a href="http://google.com">{}</a>'

enter image description here

Update:

The following link partially works.

link_ref = '<a href="http:///files/file1.html">{}</a>'
Oli
  • 1,313
  • 14
  • 31

1 Answers1

1

File links are an issue for security reasons. I tested this code with IE 11 and it worked fine, no issues. For Firefox, Chrome, and Edge it does not work.

You may be able to disable this security check in your browser or use an extension. http://kb.mozillazine.org/Links_to_local_pages_do_not_work

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

link_ref = '<a href="./text.html">{}</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.write_html("index.html")
Joshua Lowry
  • 1,075
  • 3
  • 11
  • 30