htmlwidgets / sparkline

jQuery Sparkline HTML Widget for R
Other
244 stars 40 forks source link

Use option colorMap with sparkline #24

Closed andrasberczi closed 6 years ago

andrasberczi commented 6 years ago

When I am drawing a sparkline I cannot seem to use the colorMap option of sparkline. This option is somehow passed to jQuery, I am probably trying with a wrong syntax, but I cannot figure out, how to do it properly! Other options listen on the website of jQuery Sparklines work:

library(sparkline)
sparkline::sparkline(round(runif(10,1,10)), type = "bar", spotRadius = 5)

But I cannot do the same with colorMap, this is one example how I have tried:

sparkline::sparkline(round(runif(10,1,10)), type = "bar", colorMap = {':5': '#ff0' })

I have also posted this question on stackoverflow.

My goal is to highlight a bar with a certain value.

What am I missing? Thanks for your help!

ramnathv commented 6 years ago

Does this give you what you want?

sparkline::sparkline(
  round(runif(10,1,10)), 
  type = "bar", 
  colorMap = list(`:5` = '#ff0')
)
andrasberczi commented 6 years ago

It does, thank you very much!