Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow images to be used as column headers #418

Closed
2 tasks done
minimav opened this issue Aug 17, 2024 · 1 comment
Closed
2 tasks done

Allow images to be used as column headers #418

minimav opened this issue Aug 17, 2024 · 1 comment

Comments

@minimav
Copy link

minimav commented Aug 17, 2024

Prework

Proposal

This can be achieved in a couple of ways already, although they both are very hacky. One is by using placeholder column names and replacing them appropriately in the HTML output created by as_raw_html with base64 encoded <img> tags (essentially the approach that is used in fmt_image).

A couple of approaches that might work for a proper implementation this:

  • A .fmt_column_header_image method that mimicks fmt_image and reuses FmtImage if possible.
df = pl.DataFrame([
    {"column_name": 1.0}
])

GT(df).fmt_column_header_image(
     column_name=<path to image>,
     # fmt_image kwargs
     height=...
)
  • Allow option in .col_labels to enable use of an image instead of a renaming label, or infer from argument type
df = pl.DataFrame([
    {"regular_name": 1.0, "image_column": "something"}
])

GT(df).col_labels(
    regular_name="some other name",
    # infer from Path type?
    image_column=Path(...),
)

I would be happy to try implementing something like this. Thank you 😄

@jrycw
Copy link
Collaborator

jrycw commented Nov 23, 2024

Thank you for bringing this issue to our attention. I'll close it now, as the vals.fmt_image() function is available to achieve the desired result.

@jrycw jrycw closed this as completed Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants