0

How can I render a text column containing the output of {sparkline}s' spk_chr() with {reactable}?

Note that I do not want to use the way described in the docs (https://glin.github.io/reactable/articles/examples.html), but explicitly use spk_chr() output.

Here is a reprex:

library(dplyr)
library(sparkline)

data <- chickwts %>%
  count(feed)

summary_table <- data.frame(
  x = "obs 1",
  spark = spk_chr(
    data$n,
    barWidth = 500,
    barSpacing = 100,
    height = 50,
    width = 300,
    type = "bar",
    tooltipFormatter = htmlwidgets::JS(
      sprintf(
        "function(sparkline, options, field){
    debugger;
    return 'value=' + %s[field[0].offset] + '<br/> n=' + field[0].value;
  }",
        jsonlite::toJSON(
          data$feed
        )
      )
    )
  )

)

reactable(summary_table) #I want to render the spark column
Rob G.
  • 395
  • 1
  • 8
  • 1
    Please share some code and data using `dput(df)`? – Quinten May 05 '22 at 12:57
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 05 '22 at 13:01

0 Answers0