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

Row styles are not applied to rowname_col when rowname_col is specified #284

Open
rasmi opened this issue Apr 12, 2024 · 2 comments
Open

Comments

@rasmi
Copy link

rasmi commented Apr 12, 2024

I am trying to create a line that runs across the top of the last row of my table (to separate the "Total" row from the rest of the table). This works great using .tab_style, but when I also specify rowname_col, the style is removed from the rowname_col column. I would expect that that the defined tab_style still works regardless of whether rowname_col is specified.

Reproducible example

(adapted from the docs)

With rowname_col

Screenshot 2024-04-12 15 11 25

Without rowname_col

Screenshot 2024-04-12 15 11 44

import polars as pl
from great_tables import GT, md, html, style, loc
from great_tables.data import islands

islands_mini = (
    pl.from_pandas(islands).sort("size", descending=True)
    .head(10)
)

(
    GT(islands_mini,
       rowname_col="name" # Comment out this line to show intended style.
    )
    .tab_header(
        title="Large Landmasses of the World",
        subtitle="The top ten largest are presented"
    )
    .tab_source_note(source_note="Source: The World Almanac and Book of Facts, 1975, page 406.")
    .tab_source_note(
        source_note=md("Reference: McNeil, D. R. (1977) *Interactive Data Analysis*. Wiley.")
    )
    .tab_stubhead(label="landmass")
    .fmt_integer(columns="size")
    .tab_style(
      style=style.borders(sides=["top"], style="double", weight="4px"),
      locations=loc.body(rows=[-1])
    )
)

Development environment

  • Operating System: Colab notebook
  • great_tables: 479eb73 (v0.5.0)
@machow
Copy link
Collaborator

machow commented Apr 16, 2024

Thanks for raising -- this hits a tricky piece with how we've broken apart table structure. Basically, without rowname_col there is no row stub, just a table body. This means the line crosses the whole table.

With rowname_col specified, there is a row stub. So we need to also tell it to underline that row in the row stub. This should be supported once we complete #170, since it will allow you to use loc.stub() in addition to loc.body() for underlining.

@rasmi
Copy link
Author

rasmi commented Apr 16, 2024

Makes sense, thank you!

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

3 participants