My Table cuts off text and breaks some links


#1

Hello,
I have been trying to put my data into a plot.ly table but I have been having trouble with getting the links to work.

My data consists of news articles and urls for the articles. res is a dataframe containing the article title, url, section, and source. Both the links and the titles can be extremely long. I’ve found that if I do not set the cell size to be unrealistically big then the links do not work. I suspect that this is because some of the text is being cut off (the last characters of some of the links are not being shown in the table).

Is there any solution to my problem? The code and a screenshot of the problem is attached.

Thanks !

Code:

import dash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go

app = dash.Dash(name)

links = '<a href = "' + res['url'] + '">' + res['title'] + '</a>'

#All the links start to work only if I make the cell size huge

trace = go.Table(
        columnorder = [1,2,3],
        columnwidth = [200,75,30],
        header = dict(values=['title','source','section']),
        cells = dict(values=[links,
                             res['source'],
                             res['section']],
                        height = 30))
data = [trace]
app.layout = html.Div([
    html.Div(html.A("test link", href = 'https://community.plot.ly/c/dash'), style={'color': 'black', 'fontSize': 18, 'font-family' : 'Arial', 'font-weight': 'bold'}),
    dcc.Graph(id='visitors1',figure = go.Figure(data=[trace]))
])

if name == ‘main’:
app.run_server()


#2

Hi, and thanks for writing in.

From the text showing up, it looks like there’s no </a> in your links. <a> tags should work perfectly in tables, so I’d check how you’re constructing these.


#3

Hi charleyferrari,

There is a</a> tag in my links, I am constructing them using

links = '<a href = "' + res['url'] + '">' + res['title'] + '</a>'

where res[‘url’] is a pandas dataframe column of urls.

When I make my table cells bigger all of the links seem to work but it ruins my formatting.

The problem seems to only occur for the links where the url or the article title is longer than the rest of the links.


#4

I am experiencing the same problem with my links if they are too long. Most of the links display in the table, but a few show up as the actual HTML text.
Also, the title that displays sometimes breaks into 2 lines in the beginning of the text, rather than at the end. Anyone have any suggestions for either of these problems.

I would prefer to use the new DataTable, but that does not support HTML links yet.

Thank you.


#5

Im having the same problem. Just wondering if anyone found a work around.
Thanks!!!


#6

Im actually applying to a url_shortner to my links to make them smaller so the links will show up.

Hope that helps someone in the same boat as I was.