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

Feature Request: Support for Custom Font Family in gt_plt_bar() Function #135

Open
pradisteph opened this issue Sep 4, 2024 · 0 comments
Assignees

Comments

@pradisteph
Copy link

Prework
Searched for duplicates among the existing issues (both open and closed).

Proposal:

I would like to request the ability to specify a custom font family within the gt_plt_bar() function in the gtExtras package. Currently, the function allows for customisation of font_size and font_style, but it does not provide an option to set the font_family.

Use Case:
In my work, I frequently create tables using the gt package combined with the gtExtras::gt_plt_bar() function to display bar charts within table cells. However, I need to ensure consistency in font usage across my tables to adhere to organizational branding guidelines, which specify a particular font family. While I can change the font family for text in gt tables using tab_style(), I cannot apply this customization to the bar charts created by gt_plt_bar().

Minimal Example:

Here is an example of the current usage where I attempt to change the font family, but it doesn't take effect:

library(gt)
library(gtExtras)

# Sample data
data <- data.frame(
  Category = c("A", "B", "C"),
  Value = c(20, 50, 80)
)

# Desired font family (e.g., "Arial Narrow")
narrow_font_family <- "Arial Narrow"

# Create a gt table and add bars
gt_table <- data %>%
  gt() %>%
  gt_plt_bar(column = Value, fill = "lightblue", font_size = 12) %>%
  tab_style(
    style = cell_text(font = narrow_font_family),
    locations = cells_body(columns = "Value")
  )

# The font family does not change for the text within the bars

Desired Outcome:
The ability to set the font_family directly within the gt_plt_bar() function or have the function respect the global font family set for the gt table.

For example:

gt_plt_bar(
  column = Value,
  color = "lightblue",
  font_family = "Arial Narrow",  # New feature
  font_size = 12
)

This would allow for greater customization and consistency in tables created with the gtExtras package.

Conclusion:
Adding support for a custom font_family in gt_plt_bar() would greatly enhance the flexibility of the function, enabling users to create tables that are fully aligned with their desired styling and branding guidelines.

Thank you for considering this feature request!
Stephanie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants