Closed lyndess closed 9 months ago
Pre-computed box plot values (by, for example boxplot.stats
) have to be sent to sparkline
as the values
argument. In other words, you won't send the vector of observations to sparkline
at all. There's an example here:
https://stackoverflow.com/questions/40123559/inline-boxplots-using-sparkline
Ahh, OK—so "low_outlier", "low_whisker", "q1", etc. are actually not arguments to sparkline
, but instead one must store these values in a vector that is passed as the values
argument.
So my simple example code would be updated as follows:
library(sparkline)
low_outlier <- 382.000
low_whisker <- 412.000
q1 <- 444.750
median <- 487.000
target <- 487.140
q3 <- 516.250
high_whisker <- 592.000
high_outlier <- 605.000
# low_outlier, low_whisker, q1, median, q3, high_whisker, high_outlier
raw_values = c(low_outlier, low_whisker, q1, median, q3, high_whisker, high_outlier)
sparkline(
values = raw_values,
raw = TRUE,
type = "box",
# format the boxplot
outlierLineColor = "#15607a",
outlierFillColor = "#b5f0fa",
boxLineColor = "#15607a",
boxFillColor = "#b5f0fa",
whiskerColor = "#15607a",
medianColor = "#15607a",
targetColor = "#15607a",
width = 400,
height = 100
)
... which correctly produces this (including the hover tip):
Thank you for clarifying!
Issue resolved.
When creating a boxplot spark graph in R and manually specifying the boxplot parameters (as described here: https://omnipotent.net/jquery.sparkline/#boxplot), it doesn't produce the desired output. As a simple example:
In the code above, I pass the 'x' data source to sparkline because it is required, but I want to manually specify the boxplot parameters—as indicated above. The resulting boxplot looks like this (including the hover tooltip):
Setting raw = FALSE results in this:
The expected result would be a boxplot with the specified parameters; neither setting produces the prescribed boxplot.