htmlwidgets / sparkline

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

Unavailable plot options - Boxplots with minValue and maxValue #32

Closed tchiles closed 4 years ago

tchiles commented 4 years ago

Are there some options for given plots that are not available in the R version of sparklines? In particular I would like to plot minValue and maxValue for a box plot. The jQuery shows these options (they call the widget pre-computed box-plot). But when I try to include these options I do not see the endpoints.

`library(sparkline)

x = rnorm(20) sparkline(x, type = 'box') sparkline(x, type = 'box', minValue = '1', maxValue = '100')`

timelyportfolio commented 4 years ago

@tchiles I haven't looked at sparkline in quite a while, but let's see if we can get this working. I don't think minValue and maxValue work in the JavaScript library either since there is no effect on the box examples, but I honestly don't remember.

pre-calculated values

# we lose outliers
sparkline(fivenum(x), type = "box", raw = TRUE)

min and max range

I don't think this is the goal, but for min and max range, we can use the common options API.

sparkline(x, type = 'box', chartRangeMin = 0, chartRangeMax = 100)
tchiles commented 4 years ago

@timelyportfolio thanks! I think this is the solution I'm looking for. I have rows in a table I want to show box plots for each, but since I want to be able to compare between rows I wanted to keep the range the same for each row. I did some more digging into the latest version of jQuery and it looks like the min/mavValue for box plot are enabled when RAW is selected. Trying this in the javascript example does seem to work, but not any different then the the common API example you provide.

timelyportfolio commented 4 years ago

@tchiles sounds promising. I'll close this out but feel free to reopen if this is not sufficient. Happy to help.