jthomasmock / gtExtras

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

Put some numbers in gt_sparkline #15

Closed IvoVillanueva closed 2 years ago

IvoVillanueva commented 2 years ago

Hello I would like to put in the points the numbers to which it refers, as Max and Min for exemple,. I'm doing this table but i think the sparkline doesn't explain much without the numbers in the points blue and reds thank you

final_df

jthomasmock commented 2 years ago

Hi @IvoVillanueva in the latest version of gtExtras, there is a number attached to the end of the sparkline to indicate the last value.

library(gt)
library(gtExtras)
packageVersion("gtExtras")
#> [1] '0.2.18'

mtcars %>%
    dplyr::group_by(cyl) %>%
    # must end up with list of data for each row in the input dataframe
    dplyr::summarize(mpg_data = list(mpg), .groups = "drop") %>%
    gt() %>%
    gt_sparkline(mpg_data) %>% 
  gtsave("test-img.png")

Created on 2021-10-13 by the reprex package (v2.0.1)

IvoVillanueva commented 2 years ago

thank you very much

rizqrama commented 2 years ago

Hi @IvoVillanueva in the latest version of gtExtras, there is a number attached to the end of the sparkline to indicate the last value.

library(gt)
library(gtExtras)
packageVersion("gtExtras")
#> [1] '0.2.18'

mtcars %>%
    dplyr::group_by(cyl) %>%
    # must end up with list of data for each row in the input dataframe
    dplyr::summarize(mpg_data = list(mpg), .groups = "drop") %>%
    gt() %>%
    gt_sparkline(mpg_data) %>% 
  gtsave("test-img.png")

Created on 2021-10-13 by the reprex package (v2.0.1)

However, is there any way to do the opposite? I mean, to remove the number at the end of the line. Thanks!

jthomasmock commented 2 years ago

Hi @rizqrama - I will be adding an argument to turn this off, but for your specific question on Twitter you may want to explore a gt_win_loss as a way to indicate, wins/losses/etc.

rizqrama commented 2 years ago

Hi @rizqrama - I will be adding an argument to turn this off, but for your specific question on Twitter you may want to explore a gt_win_loss as a way to indicate, wins/losses/etc.

Thank you very much!

IvoVillanueva commented 2 years ago

excuse me, there would be the possibility of being able to indicate a maximum and or minimum value ☺️?