jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

fix the issue with graphs not displaying when data contains only valu… #75

Closed paspvik closed 1 year ago

paspvik commented 1 year ago

…es less than 0.

jthomasmock commented 1 year ago

Hi @paspvik thanks for the PR - can you provide a reprex as to the issue you are facing?

paspvik commented 1 year ago

@jthomasmock

This code will not display a plot - PR will fix this.

If the values are positive, such as data.frame.values = c(1, 5, 10), or mixed values, such as data.frame.values = c(1, -5, 10), a plot will be displayed.

df_negative <- data.frame(values = c(-1, -5, -10))

negative_plot <- df_negative %>% gt() %>% gt_plt_bar(values)

negative_plot

jthomasmock commented 1 year ago

Thanks for reprex! Fixed with latest version:

#If the values are positive, such as data.frame.values = c(1, 5, 10), or mixed values, such as data.frame.values = c(1, -5, 10), a plot will be displayed.

library(gt)
library(gtExtras)

df_negative <- data.frame(values = c(-1, -5, -10))

negative_plot <- df_negative %>%
  gt() %>%
  gt_plt_bar(values)

negative_plot |> 
  gtsave("test.png")

knitr::include_graphics("test.png")

Created on 2023-02-04 by the reprex package (v2.0.1)