Change sparkline coloring in shiny DT table

Below is the code to develop sparkline in R. Wanted to check if we can change the color . I mean the negative values to be black and positive values to be red


## Create demo data sets
my_mtcars <- data.table(mtcars, keep.rownames = TRUE)
names(my_mtcars)[1] <- 'car_id'

data_for_sparklines <- data.table(car_id = rep(my_mtcars$car_id, 5),
                                  category = 1:5,
                                  value = c(runif(80),-runif(80)))

sparkline_html <- data_for_sparklines[, .(sparkbar = spk_chr(value, type = 'bar',barColor = "black")), by = 'car_id']
my_mtcars <- merge(my_mtcars, sparkline_html, by = 'car_id')

spk_add_deps(datatable(my_mtcars, escape = FALSE))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.