Will1
September 2, 2022, 2:39pm
1
Hello,
I am trying to display a Pandas table on the client side. I have tried to display the table with RichText, but I can’t display all the columns of the dataframe, it cuts…
I attach the image.
This is the code:
Server:
@anvil.server.callable
def pd_tab():
download_url = ("https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/recent-grads.csv")
df = pd.read_csv(download_url)
return df.to_markdown()
Client:
self.rich_text_1.content = anvil.server.call('pd_tab')
I would like to use the Pandas style function, or something similar, to get this result:
Any suggestions?
Thanks in advance.
ianb
September 2, 2022, 2:43pm
2
Do you have a clone link, or a stripped down version of this you can turn into a clone link? I think there are easier solutions than setting the scroll bars in markdown.
Will1
September 2, 2022, 2:54pm
3
Yes, this is the simplified clone of the application: Anvil | Login
ianb
September 2, 2022, 3:58pm
4
Here is what I got:
https://anvil.works/build#clone:ZAHW7IZXNIXSQA5J=DKRIEM4KZFS5KG5HIXKKWCFH
I added a role named horizontal_scroll
to the RichText box that contains the following css:
.anvil-role-horizontal_scroll {
max-height: calc(100vh - 9rem);
overflow-y: scroll;
overflow-x: scroll;
}
3 Likes
Will1
September 2, 2022, 4:03pm
5
It is perfect. Very good solution. Thank you very much!
1 Like
ianb
September 2, 2022, 4:07pm
6
Under Assets → theme.css
Just in case that wasn’t clear to someone reading later, if you have questions look here:
Roles Roles work by applying CSS classes to components. For example, a component with a role named foo will get the .anvil-role-foo CSS class applied to it.
If you’re new to CSS, we have an introductory guide, which explains how to use it to change...
1 Like